Commit 906dd542 authored by Júda Ronén's avatar Júda Ronén
Browse files

Add YAML → Pollen+Anki scripts for the bilingual signs

parent 4bd2ff07
#!/usr/bin/env python
import dominate
from dominate import tags
import os
import yaml
data = list(yaml.load_all(open('/home/me/documents/anki/factory/Cymraeg/signs/deck.yaml'), Loader=yaml.SafeLoader))
def indent(level):
return " "*level
print('◊table[#:class "fullwidth signtable"]{')
for img in data[0]:
print(indent(1) + "◊tr{")
print(indent(2) + '◊td[#:class "thumbnail"]{◊a[#:href "' + os.path.join("images", img['file']) + '" #:class "barelink"]{◊img[#:src "' + os.path.join("thumbnails", img['file']) + '"]{}}}')
print(indent(2) + '◊td{')
print(indent(3) + '◊table[#:style "width: 100%"]{')
for line in img['text']:
print(indent(4) + '◊tr{')
print(indent(5) + '◊td[#:style "width: 45%"]{' + line['cy'] + '}')
print(indent(5) + '◊td[#:style "width: 45%"]{')
if 'en' in line:
print(indent(6) + '◊div{' + line['en'] + '}')
if 'en-translation' in line:
print(indent(6) + '◊div{(' + line['en-translation'] + ')}')
if 'verbatim' in line:
print(indent(6) + '◊div[#:class "verbatim"]{' + line['verbatim'] + '}')
print(indent(5) + '}')
print(indent(4) + '}')
print(indent(3) + '}')
print(indent(2) + '}')
print(indent(1) + "}")
print("}")
# with tags.table() as t:
# for img in data[0]:
# with tags.tr():
# tags.td(tags.img(src=os.path.join("thumbnails", img['file'])))
# with tags.table():
# for line in img['text']:
# with tags.tr():
# tags.td(line['cy'])
# with tags.td():
# if 'en' in line:
# tags.div(line['en'])
# if 'en-translation' in line:
# tags.div(line['en-translation'], cls="mytranslation")
# if 'verbatim' in line:
# tags.div("(" + line['verbatim'] + ")", cls="verbatim")
#!/usr/bin/env python
import dominate
from dominate import tags
import os
import yaml
data = list(yaml.load_all(open('/home/me/documents/anki/factory/Cymraeg/signs/deck.yaml'), Loader=yaml.SafeLoader))
id = 0
for img in data[0]:
for line in img['text']:
print(id, end="\t")
print("<img src=\"arwyddion-" + img['file'] + "\" />", end="\t")
print(line['cy'], end="\t")
if 'en' in line:
print(line['en'], end="\t")
else:
print("", end="\t")
if 'en-translation' in line:
print(line['en-translation'], end="\t")
else:
print("", end="\t")
if 'verbatim' in line:
print(line['verbatim'])
else:
print()
id = id + 1
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment