Loading filter_1.lua +2 −1 Original line number Diff line number Diff line Loading @@ -165,7 +165,8 @@ if FORMAT:match 'html' then local height = tonumber(el.attr.attributes.height:sub(1,-3)) local ratio = height/width -- set height el.attr = { style = "width: 100%; height: calc(100%*"..ratio..");"} -- TODO: need to check this one, it feels unnecessary -- el.attr = { style = "width: 100%; height: calc(100%*"..ratio..");"} local filePath, extension = el.src:match("(.*)%.(.*)$") -- image.png, jpeg or emf --fixes extensions Loading official.html +79 −75 Original line number Diff line number Diff line <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="$lang$" xml:lang="$lang$"$if(dir)$ dir="$dir$"$endif$> <html xmlns="http://www.w3.org/1999/xhtml" lang="$lang$" xml:lang="$lang$" $if(dir)$ dir="$dir$" $endif$ > <head> <meta charset="utf-8" /> <meta name="generator" content="pandoc" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> $for(author-meta)$ <meta name="author" content="$author-meta$" /> $endfor$ $if(date-meta)$ $endfor$ $if(date-meta)$ <meta name="dcterms.date" content="$date-meta$" /> $endif$ $if(keywords)$ $endif$ $if(keywords)$ <meta name="keywords" content="$for(keywords)$$keywords$$sep$, $endfor$" /> $endif$ $if(description-meta)$ $endif$ $if(description-meta)$ <meta name="description" content="$description-meta$" /> $endif$ <title>$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$</title> Loading @@ -22,37 +29,35 @@ $endif$ </style> $for(css)$ <link rel="stylesheet" href="../$css$" /> $endfor$ $for(header-includes)$ $header-includes$ $endfor$ $if(math)$ $endfor$ $for(header-includes)$ $header-includes$ $endfor$ $if(math)$ $if(mathjax)$ <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> $endif$ $math$ $endif$ $endif$ $math$ $endif$ <!--[if lt IE 9]> <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script> <![endif]--> <script> const links = document.getElementsByTagName("link"); // link[0] should be styiling.css if (links[1].getAttribute("rel") === "stylesheet") { if (styleToggle) { links[1].href = "API.css"; } else { links[1].href = "background_highlight.css"; } } </script> </head> <body> $for(include-before)$ $include-before$ $endfor$ $if(title)$ $for(include-before)$ $include-before$ $endfor$ $if(title)$ <header id="title-block-header"> <h1 class="title">$title$</h1> $if(subtitle)$ <p class="subtitle">$subtitle$</p> $endif$ $for(author)$ $endif$ $for(author)$ <p class="author">$author$</p> $endfor$ $if(date)$ $endfor$ $if(date)$ <p class="date">$date$</p> $endif$ $if(abstract)$ $endif$ $if(abstract)$ <div class="abstract"> <div class="abstract-title">$abstract-title$</div> $abstract$ Loading @@ -64,14 +69,13 @@ $endif$ $if(toc-title)$ <h2 id="$idprefix$toc-title">$toc-title$</h2> $endif$ <ul><li><h1><a href="0--1.html">ETSI title</a></h1></li></ul> <ul> <li> <h1><a href="0--1.html">ETSI title</a></h1> </li> </ul> $table-of-contents$ </nav> <div id="editor"> $body$ $for(include-after)$ $include-after$ $endfor$ </div> <div id="editor">$body$ $for(include-after)$ $include-after$ $endfor$</div> </body> </html> preprocessing.py +69 −19 Original line number Diff line number Diff line import sys import docx from docx.shared import Pt from docx.enum.text import WD_ALIGN_PARAGRAPH from random import randint DEBUG = False #print debug info switch Loading @@ -23,12 +25,24 @@ class CSS: if name not in self.run_styles.keys(): self.run_styles[name] = CSS_Style(name, style, self.TESTING) def get_para(self, name): return self.para_styles[name] class CSS_Style: """class that converts a word style in a css style""" def __init__(self, name, style, TESTING): self.class_name = name self.TESTING = TESTING #None values means we have to resolve Word style hierarchy self.text_align = None self.first_indent = None self.left_indent = None self.right_indent = None self.space_before = None self.space_after = None self.display = None self.gap = None self.align_items = None if hasattr(style, 'font'): #this is a character style, a Paragraph style or an on_demand character style #font info Loading @@ -51,20 +65,39 @@ class CSS_Style: if hasattr(style, 'paragraph_format'): #this is a pragraph style or an on_demand paragraph style #paragraph format info self.align = self.inherit_property(style, 'paragraph_format.alignment') self.first_indent = self.inherit_property(style, 'paragraph_format.first_line_indent') self.left_indent = self.inherit_property(style, 'paragraph_format.left_indent') self.right_indent = self.inherit_property(style, 'paragraph_format.right_indent') self.space_before = self.inherit_property(style, 'paragraph_format.space_before') self.space_after = self.inherit_property(style, 'paragraph_format.space_after') else: #this is a character style or an on_demand character style self.align = None self.text_align = self.inherit_property(style, 'paragraph_format.alignment') # self.first_indent = self.inherit_property(style, 'paragraph_format.first_line_indent') # self.left_indent = self.inherit_property(style, 'paragraph_format.left_indent') # self.right_indent = self.inherit_property(style, 'paragraph_format.right_indent') self.first_indent = None self.left_indent = None self.right_indent = None self.space_before = None self.space_after = None self.space_before = self.inherit_property(style, 'paragraph_format.space_before') self.space_after = self.inherit_property(style, 'paragraph_format.space_after') # else: #this is a character style or an on_demand character style # self.text_align = None # self.first_indent = None # self.left_indent = None # self.right_indent = None # self.space_before = None # self.space_after = None # EXCEPTIONS if self.class_name == "NF": self.display = "flex" self.gap = Pt(4) self.align_items = "center" elif self.class_name == "FL": self.text_align = WD_ALIGN_PARAGRAPH.CENTER self.display = None self.gap = None self.align_items = None elif self.class_name == "TF": self.text_align = WD_ALIGN_PARAGRAPH.CENTER self.display = None self.gap = None self.align_items = None def inherit_property(self, style, property_path): """ Loading @@ -85,7 +118,6 @@ class CSS_Style: break #Exit if we found the property return property def generate_css(self): properties = "" Loading @@ -112,8 +144,8 @@ class CSS_Style: print(self.class_name, self.color.rgb) properties += f"color: #{self.color.rgb};\n\t" if self.align: #self.align is an enum and we use the name of the enum variable, but lower. e.g. WD_PARAGRAPH_ALIGNMENT.LEFT gives left properties += f"text-align: {self.align.name.lower()};\n\t" if self.text_align: #self.text_align is an enum and we use the name of the enum variable, but lower. e.g. WD_PARAGRAPH_ALIGNMENT.LEFT gives left properties += f"text-align: {self.text_align.name.lower()};\n\t" if self.first_indent: properties += f"text-indent: {self.first_indent.pt}pt;\n\t" Loading @@ -130,6 +162,15 @@ class CSS_Style: if self.space_after: properties += f"margin-bottom: {self.space_after.pt}pt;\n\t" if self.align_items: properties += f"align-items: {self.align_items};\n\t" if self.display: properties += f"display: {self.display};\n\t" if self.gap: properties += f"gap: {self.gap.pt}pt;\n\t" if self.TESTING: if self.class_name.startswith("ondemand_"): #random color for ondemand styles # generates 3 different numbers between 0 and 240(with steps of 16 and shifted by 8) Loading @@ -149,7 +190,6 @@ class CSS_Style: }} """ return css def __eq__(self, __o: object) -> bool: Loading @@ -160,6 +200,9 @@ class CSS_Style: def __hash__(self) -> int: return hash(self.class_name) def __str__(self) -> str: return self.class_name + "\n" + self.generate_css() + "\n" def get_name(str): """returns a css-friendly style name""" return "_".join(str.split(" ")).replace("+","plus") Loading Loading @@ -314,6 +357,13 @@ if __name__ == "__main__": #mark paragraphs and runs style info mark_style(doc.paragraphs) #add some custom styles api_css.get_para("HTML_Code").font_size = Pt(12) api_css.get_para("HTML_Keyboard").font_size = Pt(12) api_css.get_para("HTML_Sample").font_size = Pt(12) api_css.get_para("HTML_Variable").font_size = Pt(12) api_css.get_para("PL").font_size = Pt(12) #save files api_css.write() background_highlight.write() Loading styling.css +11 −7 Original line number Diff line number Diff line Loading @@ -24,13 +24,14 @@ html { top: 0; left: 0; height: 100%; width: 25%; width: 275px; resize: horizontal; padding-right: 15px; position: fixed; background-color: rgba(100,100, 100, 0.6); overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none; } #TOC a { Loading Loading @@ -473,9 +474,12 @@ html { font-family: -apple-system, BlinkMacSystemFont,"Times New Roman", "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 12pt; line-height: 1.6; margin: auto; max-width: 920px; min-width: 360px; /* margin: auto; */ /* max-width: 920px; min-width: 360px; */ max-width: 75%; left: 275px; position: relative; padding: 2rem; word-wrap: break-word; } Loading Loading @@ -831,7 +835,7 @@ html { } /*lists highlighting*/ li p { /* li p { background-color: rgb(255,0,0); } } */ No newline at end of file Loading
filter_1.lua +2 −1 Original line number Diff line number Diff line Loading @@ -165,7 +165,8 @@ if FORMAT:match 'html' then local height = tonumber(el.attr.attributes.height:sub(1,-3)) local ratio = height/width -- set height el.attr = { style = "width: 100%; height: calc(100%*"..ratio..");"} -- TODO: need to check this one, it feels unnecessary -- el.attr = { style = "width: 100%; height: calc(100%*"..ratio..");"} local filePath, extension = el.src:match("(.*)%.(.*)$") -- image.png, jpeg or emf --fixes extensions Loading
official.html +79 −75 Original line number Diff line number Diff line <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="$lang$" xml:lang="$lang$"$if(dir)$ dir="$dir$"$endif$> <html xmlns="http://www.w3.org/1999/xhtml" lang="$lang$" xml:lang="$lang$" $if(dir)$ dir="$dir$" $endif$ > <head> <meta charset="utf-8" /> <meta name="generator" content="pandoc" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> $for(author-meta)$ <meta name="author" content="$author-meta$" /> $endfor$ $if(date-meta)$ $endfor$ $if(date-meta)$ <meta name="dcterms.date" content="$date-meta$" /> $endif$ $if(keywords)$ $endif$ $if(keywords)$ <meta name="keywords" content="$for(keywords)$$keywords$$sep$, $endfor$" /> $endif$ $if(description-meta)$ $endif$ $if(description-meta)$ <meta name="description" content="$description-meta$" /> $endif$ <title>$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$</title> Loading @@ -22,37 +29,35 @@ $endif$ </style> $for(css)$ <link rel="stylesheet" href="../$css$" /> $endfor$ $for(header-includes)$ $header-includes$ $endfor$ $if(math)$ $endfor$ $for(header-includes)$ $header-includes$ $endfor$ $if(math)$ $if(mathjax)$ <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> $endif$ $math$ $endif$ $endif$ $math$ $endif$ <!--[if lt IE 9]> <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script> <![endif]--> <script> const links = document.getElementsByTagName("link"); // link[0] should be styiling.css if (links[1].getAttribute("rel") === "stylesheet") { if (styleToggle) { links[1].href = "API.css"; } else { links[1].href = "background_highlight.css"; } } </script> </head> <body> $for(include-before)$ $include-before$ $endfor$ $if(title)$ $for(include-before)$ $include-before$ $endfor$ $if(title)$ <header id="title-block-header"> <h1 class="title">$title$</h1> $if(subtitle)$ <p class="subtitle">$subtitle$</p> $endif$ $for(author)$ $endif$ $for(author)$ <p class="author">$author$</p> $endfor$ $if(date)$ $endfor$ $if(date)$ <p class="date">$date$</p> $endif$ $if(abstract)$ $endif$ $if(abstract)$ <div class="abstract"> <div class="abstract-title">$abstract-title$</div> $abstract$ Loading @@ -64,14 +69,13 @@ $endif$ $if(toc-title)$ <h2 id="$idprefix$toc-title">$toc-title$</h2> $endif$ <ul><li><h1><a href="0--1.html">ETSI title</a></h1></li></ul> <ul> <li> <h1><a href="0--1.html">ETSI title</a></h1> </li> </ul> $table-of-contents$ </nav> <div id="editor"> $body$ $for(include-after)$ $include-after$ $endfor$ </div> <div id="editor">$body$ $for(include-after)$ $include-after$ $endfor$</div> </body> </html>
preprocessing.py +69 −19 Original line number Diff line number Diff line import sys import docx from docx.shared import Pt from docx.enum.text import WD_ALIGN_PARAGRAPH from random import randint DEBUG = False #print debug info switch Loading @@ -23,12 +25,24 @@ class CSS: if name not in self.run_styles.keys(): self.run_styles[name] = CSS_Style(name, style, self.TESTING) def get_para(self, name): return self.para_styles[name] class CSS_Style: """class that converts a word style in a css style""" def __init__(self, name, style, TESTING): self.class_name = name self.TESTING = TESTING #None values means we have to resolve Word style hierarchy self.text_align = None self.first_indent = None self.left_indent = None self.right_indent = None self.space_before = None self.space_after = None self.display = None self.gap = None self.align_items = None if hasattr(style, 'font'): #this is a character style, a Paragraph style or an on_demand character style #font info Loading @@ -51,20 +65,39 @@ class CSS_Style: if hasattr(style, 'paragraph_format'): #this is a pragraph style or an on_demand paragraph style #paragraph format info self.align = self.inherit_property(style, 'paragraph_format.alignment') self.first_indent = self.inherit_property(style, 'paragraph_format.first_line_indent') self.left_indent = self.inherit_property(style, 'paragraph_format.left_indent') self.right_indent = self.inherit_property(style, 'paragraph_format.right_indent') self.space_before = self.inherit_property(style, 'paragraph_format.space_before') self.space_after = self.inherit_property(style, 'paragraph_format.space_after') else: #this is a character style or an on_demand character style self.align = None self.text_align = self.inherit_property(style, 'paragraph_format.alignment') # self.first_indent = self.inherit_property(style, 'paragraph_format.first_line_indent') # self.left_indent = self.inherit_property(style, 'paragraph_format.left_indent') # self.right_indent = self.inherit_property(style, 'paragraph_format.right_indent') self.first_indent = None self.left_indent = None self.right_indent = None self.space_before = None self.space_after = None self.space_before = self.inherit_property(style, 'paragraph_format.space_before') self.space_after = self.inherit_property(style, 'paragraph_format.space_after') # else: #this is a character style or an on_demand character style # self.text_align = None # self.first_indent = None # self.left_indent = None # self.right_indent = None # self.space_before = None # self.space_after = None # EXCEPTIONS if self.class_name == "NF": self.display = "flex" self.gap = Pt(4) self.align_items = "center" elif self.class_name == "FL": self.text_align = WD_ALIGN_PARAGRAPH.CENTER self.display = None self.gap = None self.align_items = None elif self.class_name == "TF": self.text_align = WD_ALIGN_PARAGRAPH.CENTER self.display = None self.gap = None self.align_items = None def inherit_property(self, style, property_path): """ Loading @@ -85,7 +118,6 @@ class CSS_Style: break #Exit if we found the property return property def generate_css(self): properties = "" Loading @@ -112,8 +144,8 @@ class CSS_Style: print(self.class_name, self.color.rgb) properties += f"color: #{self.color.rgb};\n\t" if self.align: #self.align is an enum and we use the name of the enum variable, but lower. e.g. WD_PARAGRAPH_ALIGNMENT.LEFT gives left properties += f"text-align: {self.align.name.lower()};\n\t" if self.text_align: #self.text_align is an enum and we use the name of the enum variable, but lower. e.g. WD_PARAGRAPH_ALIGNMENT.LEFT gives left properties += f"text-align: {self.text_align.name.lower()};\n\t" if self.first_indent: properties += f"text-indent: {self.first_indent.pt}pt;\n\t" Loading @@ -130,6 +162,15 @@ class CSS_Style: if self.space_after: properties += f"margin-bottom: {self.space_after.pt}pt;\n\t" if self.align_items: properties += f"align-items: {self.align_items};\n\t" if self.display: properties += f"display: {self.display};\n\t" if self.gap: properties += f"gap: {self.gap.pt}pt;\n\t" if self.TESTING: if self.class_name.startswith("ondemand_"): #random color for ondemand styles # generates 3 different numbers between 0 and 240(with steps of 16 and shifted by 8) Loading @@ -149,7 +190,6 @@ class CSS_Style: }} """ return css def __eq__(self, __o: object) -> bool: Loading @@ -160,6 +200,9 @@ class CSS_Style: def __hash__(self) -> int: return hash(self.class_name) def __str__(self) -> str: return self.class_name + "\n" + self.generate_css() + "\n" def get_name(str): """returns a css-friendly style name""" return "_".join(str.split(" ")).replace("+","plus") Loading Loading @@ -314,6 +357,13 @@ if __name__ == "__main__": #mark paragraphs and runs style info mark_style(doc.paragraphs) #add some custom styles api_css.get_para("HTML_Code").font_size = Pt(12) api_css.get_para("HTML_Keyboard").font_size = Pt(12) api_css.get_para("HTML_Sample").font_size = Pt(12) api_css.get_para("HTML_Variable").font_size = Pt(12) api_css.get_para("PL").font_size = Pt(12) #save files api_css.write() background_highlight.write() Loading
styling.css +11 −7 Original line number Diff line number Diff line Loading @@ -24,13 +24,14 @@ html { top: 0; left: 0; height: 100%; width: 25%; width: 275px; resize: horizontal; padding-right: 15px; position: fixed; background-color: rgba(100,100, 100, 0.6); overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none; } #TOC a { Loading Loading @@ -473,9 +474,12 @@ html { font-family: -apple-system, BlinkMacSystemFont,"Times New Roman", "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 12pt; line-height: 1.6; margin: auto; max-width: 920px; min-width: 360px; /* margin: auto; */ /* max-width: 920px; min-width: 360px; */ max-width: 75%; left: 275px; position: relative; padding: 2rem; word-wrap: break-word; } Loading Loading @@ -831,7 +835,7 @@ html { } /*lists highlighting*/ li p { /* li p { background-color: rgb(255,0,0); } } */ No newline at end of file