summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMischa Untaga <99098079+MischaU8@users.noreply.github.com>2023-11-06 17:02:27 +0100
committerMischa Untaga <99098079+MischaU8@users.noreply.github.com>2023-11-06 17:02:27 +0100
commitc31e8c8052386de10ef85626f508d608c6a55df1 (patch)
tree866e60b8a17657a14894c75e71aeb47e31891ddc /tools
parent992163947dfc755b3e52e17442c18a10bbbcb1cb (diff)
downloadvotes-for-women-c31e8c8052386de10ef85626f508d608c6a55df1.tar.gz
events WIP
Diffstat (limited to 'tools')
-rw-r--r--tools/gencards.py10
-rw-r--r--tools/gencode.js4
2 files changed, 8 insertions, 6 deletions
diff --git a/tools/gencards.py b/tools/gencards.py
index 87fd401..2cb04d0 100644
--- a/tools/gencards.py
+++ b/tools/gencards.py
@@ -9,7 +9,7 @@ cards = [None]
card = {
'id': 1,
'type': "",
- 'title': "",
+ 'name': "",
'era': "",
'text': [],
'attrs': {}
@@ -19,7 +19,7 @@ kv_pattern = r'<!--\s*(?P<key>[^:]+):\s*(?P<value>[^->]+)\s*-->'
file_format = "tools/{}_cards.md"
def flush():
- if card['title']:
+ if card['name']:
output = card.copy()
# Combine text into a single string
output['text'] = " ".join(output['text'])
@@ -35,10 +35,10 @@ def flush():
cards.append(output)
- # print("CARD {} - {}\n# {}\n".format(output['id'], output['title'], output['text']))
+ # print("CARD {} - {}\n# {}\n".format(output['id'], output['name'], output['text']))
# Reset card attributes for the next entry
- card['title'] = ""
+ card['name'] = ""
card['text'] = []
card['attrs'] = {}
card['id'] += 1
@@ -57,7 +57,7 @@ def read_cards(_card_type):
card['era'] = line[2:].strip()
elif line.startswith("## "):
flush()
- card['title'] = line[3:].strip()
+ card['name'] = line[3:].strip()
elif match := re.match(kv_pattern, line):
key = match.group('key').strip()
value = match.group('value').strip()
diff --git a/tools/gencode.js b/tools/gencode.js
index e2522e7..39c87bd 100644
--- a/tools/gencode.js
+++ b/tools/gencode.js
@@ -30,7 +30,9 @@ for (let line of fs.readFileSync("events.txt", "utf-8").split("\n")) {
continue
if (line === "EOF")
break
- line = line.split(" ")
+ // line = line.split(" ")
+ // split by spaces unless those spaces are within double quotes.
+ line = line.match(/(?:[^\s"]+|"[^"]*")+/g)
switch (line[0]) {
case "CARD":
if (first++) {