diff --git a/md2cf/confluence_renderer.py b/md2cf/confluence_renderer.py index 44be072..b0bdb3c 100644 --- a/md2cf/confluence_renderer.py +++ b/md2cf/confluence_renderer.py @@ -49,8 +49,10 @@ def append(self, child): self.children.append(child) -class ConfluenceRenderer(mistune.Renderer): - def __init__(self, strip_header=False, remove_text_newlines=False, **kwargs): +class ConfluenceRenderer(mistune.HTMLRenderer): + def __init__(self, strip_header=False, + remove_text_newlines=False, + **kwargs): super().__init__(**kwargs) self.strip_header = strip_header self.remove_text_newlines = remove_text_newlines @@ -61,14 +63,14 @@ def reinit(self): self.attachments = list() self.title = None - def header(self, text, level, raw=None): + def heading(self, text, level, raw=None): if self.title is None and level == 1: self.title = text # Don't duplicate page title as a header if self.strip_header: return "" - return super(ConfluenceRenderer, self).header(text, level, raw=raw) + return super(ConfluenceRenderer, self).heading(text, level, raw=raw) def structured_macro(self, name): return ConfluenceTag("structured-macro", attrib={"name": name}) @@ -87,7 +89,7 @@ def text(self, text): if self.remove_text_newlines: text = text.replace("\n", " ") - return super().text(text) + return text def block_code(self, code, lang=None): root_element = self.structured_macro("code") diff --git a/md2cf/document.py b/md2cf/document.py index 4419852..77b4304 100644 --- a/md2cf/document.py +++ b/md2cf/document.py @@ -180,7 +180,9 @@ def get_pages_from_directory( def get_page_data_from_file_path( - file_path: Path, strip_header: bool = False, remove_text_newlines: bool = False + file_path: Path, + strip_header: bool = False, + remove_text_newlines: bool = False, ) -> Page: if not isinstance(file_path, Path): file_path = Path(file_path) @@ -234,17 +236,22 @@ def parse_page( markdown_lines: List[str], strip_header: bool = False, remove_text_newlines: bool = False, + escape: bool = False, + allow_harmful_protocols: bool = False ) -> Page: renderer = ConfluenceRenderer( - use_xhtml=True, strip_header=strip_header, remove_text_newlines=remove_text_newlines, + escape=escape, + allow_harmful_protocols=allow_harmful_protocols ) confluence_mistune = mistune.Markdown(renderer=renderer) confluence_content = confluence_mistune("".join(markdown_lines)) page = Page( - title=renderer.title, body=confluence_content, attachments=renderer.attachments + title=renderer.title, + body=confluence_content, + attachments=renderer.attachments ) return page diff --git a/setup.py b/setup.py index 5713f00..a367e91 100644 --- a/setup.py +++ b/setup.py @@ -21,10 +21,10 @@ ], keywords="markdown confluence", install_requires=[ - "mistune==0.8.4", + "mistune==3.0.1", "tortilla==0.5.0", - "PyYAML==6.0", - "gitignore_parser==0.0.8", + "PyYAML==6.0.1", + "gitignore_parser==0.1.6", ], python_requires=">=3.6", entry_points={"console_scripts": ["md2cf=md2cf.__main__:main"]}, diff --git a/tests/functional/result.xml b/tests/functional/result.xml index ca22230..ded83c6 100644 --- a/tests/functional/result.xml +++ b/tests/functional/result.xml @@ -1,27 +1,27 @@

Markdown: Syntax