From 3edbd4fbcf4bc8e74004c46fe5b0d68db330f260 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 22 Mar 2024 01:27:20 +0100 Subject: parse names directly --- tools/parse-layout.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'tools') diff --git a/tools/parse-layout.js b/tools/parse-layout.js index 5ee91c7..dba68af 100644 --- a/tools/parse-layout.js +++ b/tools/parse-layout.js @@ -4,6 +4,7 @@ let points = {} let rects = {} let edges = {} let mode, name, x, y, w, h, cx, cy, rx, ry, x2, y2 +let labels = [] function add_point(x, y) { if (name in points) @@ -155,19 +156,14 @@ for (let line of fs.readFileSync("tools/layout.svg", "utf-8").split("\n")) { name = line.split('"')[1] else if (line.startsWith('d="')) parse_path_data(line.split('"')[1].split(/[ ,]/)) + if (line.includes("")) { + let name = line.replace(/^[^>]*>/, "").replace(/<\/tspan.*/, "") + labels.push({x, y, name}) + } } flush() -let labels = [] - -// names.txt is layout.svg cleaned up by svgo and filtered to only include text nodes -for (let line of fs.readFileSync("tools/names.txt", "utf-8").split("\n")) { - let m = line.match(/([^<]*)