diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-03-22 01:27:20 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-03-22 01:27:20 +0100 |
commit | 3edbd4fbcf4bc8e74004c46fe5b0d68db330f260 (patch) | |
tree | 669a1e6cc9c3875f37b39ff06bbd54a61cda21f5 /tools | |
parent | f7355a98cfab087a72513c6be0120f53b6159954 (diff) | |
download | maria-3edbd4fbcf4bc8e74004c46fe5b0d68db330f260.tar.gz |
parse names directly
Diffstat (limited to 'tools')
-rw-r--r-- | tools/parse-layout.js | 14 |
1 files changed, 5 insertions, 9 deletions
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("</tspan>")) { + 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(/<tspan x="([\d.]*)" y="([\d.]*)">([^<]*)</) - if (m) - labels.push({x: Number(m[1]), y: Number(m[2]), name: m[3]}) -} - function find_closest_node(list, x, y) { let nd = Infinity, nn = null |