8 DC = "{http://purl.org/dc/elements/1.1/}"
9 RDF = "{http://www.w3.org/1999/02/22-rdf-syntax-ns#}"
11 ABOUT = "http://redakcja.wolnelektury.pl/documents/book/test-icm/"
12 WLURI = "http://wolnelektury.pl/katalog/lektura/test-icm/"
17 "Author": DC + "creator",
18 "Title": DC + "title",
19 "Publisher": DC + "publisher",
21 "Editor": DC + "contributor.editor",
22 "Copyright holder": DC + "rights",
28 "Autor": "autor_utworu",
29 "Title": "nazwa_utworu",
30 "Subtitle": "podtytul",
31 "Heading 1": "naglowek_czesc",
32 "Heading 2": "naglowek_rozdzial",
33 "Heading 3": "naglowek_podrozdzial",
34 "Heading 4": "srodtytul",
35 "Heading 5": "srodtytul",
41 if r.font.italic is not None or r.font.bold is not None or r.font.underline is not None: return r.font.italic or r.font.bold or r.font.underline
42 if r.style.font.italic is not None or r.style.font.bold is not None or r.style.font.underline is not None: return r.style.font.italic or r.style.font.bold or r.style.font.underline
49 t = etree.Element("utwor")
50 rdf = etree.SubElement(t, RDF + "RDF")
51 meta = etree.SubElement(rdf, RDF + "Description")
52 meta.attrib[RDF + "about"] = ABOUT
54 etree.SubElement(meta, DC + "language").text = "pol"
55 etree.SubElement(meta, DC + "identifier.url").text = WLURI
57 m = etree.SubElement(t, "powiesc")
60 for p in d.paragraphs:
62 if p.style.name == 'Title':
64 if p.style.name in META_STYLES:
65 item = etree.SubElement(meta, META_STYLES[p.style.name])
68 if p.style.name not in P_STYLES and not can_ignore:
69 print(p.style.name, file=sys.stderr)
70 if p.style.name in P_STYLES or not can_ignore:
71 tag = P_STYLES.get(p.style.name, "akap")
72 a = etree.SubElement(m, tag)
76 etree.SubElement(a, "wyroznienie").text = r.text
79 a[-1].tail = (a[-1].tail or '') + r.text
81 a.text = (a.text or '') + r.text
83 if DEBUG and p.style.name not in P_STYLES:
84 a.text += f" [{p.style.name}]"
86 return etree.tostring(t, pretty_print=True, encoding='unicode'), md