Enhance markdown conversion and add print styles
This commit is contained in:
parent
6e909840d4
commit
5919a2895d
14
convert.py
14
convert.py
|
|
@ -22,9 +22,9 @@ def convert_markdown_to_html(md_path: Path, html_path: Path):
|
||||||
'meta',
|
'meta',
|
||||||
])
|
])
|
||||||
html = md.convert(md_path.read_text(encoding="utf-8"))
|
html = md.convert(md_path.read_text(encoding="utf-8"))
|
||||||
title = md.Meta["title"][0] # type: ignore
|
title = md.Meta.get("title", (md_path.name,))[0] # type: ignore
|
||||||
prev_page = md.Meta["prev"][0] # type: ignore
|
prev_page = md.Meta.get("prev", ("",))[0] # type: ignore
|
||||||
next_page = md.Meta["next"][0] # type: ignore
|
next_page = md.Meta.get("next", ("",))[0] # type: ignore
|
||||||
|
|
||||||
prev_link = f'<a href="/{my_url_builder(prev_page, './', '.html')}">Prev</a>'
|
prev_link = f'<a href="/{my_url_builder(prev_page, './', '.html')}">Prev</a>'
|
||||||
next_link = f'<a href="/{my_url_builder(next_page, './', '.html')}">Next</a>'
|
next_link = f'<a href="/{my_url_builder(next_page, './', '.html')}">Next</a>'
|
||||||
|
|
@ -102,6 +102,10 @@ def convert_all(source_dir: Path, output_dir: Path):
|
||||||
rel_path = md_file.relative_to(source_dir)
|
rel_path = md_file.relative_to(source_dir)
|
||||||
html_path = output_dir / rel_path.with_suffix(".html")
|
html_path = output_dir / rel_path.with_suffix(".html")
|
||||||
convert_markdown_to_html(md_file, html_path)
|
convert_markdown_to_html(md_file, html_path)
|
||||||
|
for md_file in (source_dir / '..' / "stack_lang_spec.md",):
|
||||||
|
rel_path = md_file.relative_to(source_dir / '..')
|
||||||
|
html_path = output_dir / rel_path.with_suffix(".html")
|
||||||
|
convert_markdown_to_html(md_file, html_path)
|
||||||
|
|
||||||
def convert_all_watch_files(source_dir: Path, output_dir: Path):
|
def convert_all_watch_files(source_dir: Path, output_dir: Path):
|
||||||
import time
|
import time
|
||||||
|
|
@ -136,5 +140,7 @@ def convert_all_watch_files(source_dir: Path, output_dir: Path):
|
||||||
observer.join()
|
observer.join()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
from sys import argv
|
||||||
convert_all(SOURCE_DIR, OUTPUT_DIR)
|
convert_all(SOURCE_DIR, OUTPUT_DIR)
|
||||||
# convert_all_watch_files(SOURCE_DIR, OUTPUT_DIR)
|
if 'watch' in argv:
|
||||||
|
convert_all_watch_files(SOURCE_DIR, OUTPUT_DIR)
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,12 @@ Next: Overview
|
||||||
- G. [Examples and Tutorials](./examples_and_tutorials.html)
|
- G. [Examples and Tutorials](./examples_and_tutorials.html)
|
||||||
- H. [Complete Type Reference](./complete_type_reference.html)
|
- H. [Complete Type Reference](./complete_type_reference.html)
|
||||||
|
|
||||||
**Addendum**:
|
---
|
||||||
|
|
||||||
|
**Other**:
|
||||||
- [Missing Features](./missing_features.html)
|
- [Missing Features](./missing_features.html)
|
||||||
- [SE 3250 Assignment Details](./se_3250_assignment_details.html)
|
- [SE 3250 Assignment Details](./se_3250_assignment_details.html)
|
||||||
- [Changed](./changes.html)
|
- [Changed](./changes.html)
|
||||||
|
- [Full Specification](./stack_lang_spec.html)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
|
||||||
|
|
@ -232,3 +232,54 @@ body[mode="dark"] div.logo > a {
|
||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media print {
|
||||||
|
header, footer, a.headerlink {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
main {
|
||||||
|
padding: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
body a {
|
||||||
|
color: black !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
/* overflow-x: visible; */
|
||||||
|
word-wrap: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* pre, blockquote {
|
||||||
|
break-inside: avoid-page;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4 {
|
||||||
|
break-after: avoid-page;
|
||||||
|
} */
|
||||||
|
|
||||||
|
body[mode="dark"] {
|
||||||
|
background-color: white;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
body[mode="dark"] a {
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
body[mode="dark"] code {
|
||||||
|
background-color: #eeeeee;
|
||||||
|
}
|
||||||
|
|
||||||
|
body[mode="dark"] pre {
|
||||||
|
border-color: black;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
body[mode="dark"] blockquote {
|
||||||
|
border-color: black;
|
||||||
|
border-left-color: #888888;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue