Loading pyproject.toml +1 −1 Original line number Diff line number Diff line [project] name = "coliverter" version = "0.3.2" version = "0.3.3" authors = [ { name="Jakob Moser", email="moser@cl.uni-heidelberg.de" }, ] Loading src/coliverter/steps/md_to_html.py +15 −7 Original line number Diff line number Diff line Loading @@ -5,6 +5,9 @@ from pathlib import Path import pandoc from pandoc.types import Block, BulletList, Header, Pandoc, Plain, Para, Str, Emph from coliverter.toc.Node import Node from coliverter.toc.make_toc import make_toc def _get_filter(name: str) -> Path: with resources.path("coliverter.resources", f"pandoc-{name}.lua") as path: Loading @@ -24,15 +27,20 @@ TOC_PLACEHOLDER = Para([Str("[["), Emph([Str("TOC")]), Str("]]")]) def _get_table_of_contents(document: Pandoc) -> BulletList: toc = BulletList( [ [Plain(element[2])] for element in pandoc.iter(document) if isinstance(element, Header) ] headers = ( element for element in pandoc.iter(document) if isinstance(element, Header) ) table_of_contents = make_toc( (level, content) for (level, attrs, content) in headers ) def make_bullet_list(node: Node[list[Block]]) -> BulletList: return BulletList( [[Plain(child.content), make_bullet_list(child)] for child in node.children] ) return toc return make_bullet_list(table_of_contents) def _replace(document: Pandoc, old: Block, new: Block) -> None: Loading Loading
pyproject.toml +1 −1 Original line number Diff line number Diff line [project] name = "coliverter" version = "0.3.2" version = "0.3.3" authors = [ { name="Jakob Moser", email="moser@cl.uni-heidelberg.de" }, ] Loading
src/coliverter/steps/md_to_html.py +15 −7 Original line number Diff line number Diff line Loading @@ -5,6 +5,9 @@ from pathlib import Path import pandoc from pandoc.types import Block, BulletList, Header, Pandoc, Plain, Para, Str, Emph from coliverter.toc.Node import Node from coliverter.toc.make_toc import make_toc def _get_filter(name: str) -> Path: with resources.path("coliverter.resources", f"pandoc-{name}.lua") as path: Loading @@ -24,15 +27,20 @@ TOC_PLACEHOLDER = Para([Str("[["), Emph([Str("TOC")]), Str("]]")]) def _get_table_of_contents(document: Pandoc) -> BulletList: toc = BulletList( [ [Plain(element[2])] for element in pandoc.iter(document) if isinstance(element, Header) ] headers = ( element for element in pandoc.iter(document) if isinstance(element, Header) ) table_of_contents = make_toc( (level, content) for (level, attrs, content) in headers ) def make_bullet_list(node: Node[list[Block]]) -> BulletList: return BulletList( [[Plain(child.content), make_bullet_list(child)] for child in node.children] ) return toc return make_bullet_list(table_of_contents) def _replace(document: Pandoc, old: Block, new: Block) -> None: Loading