diff --git a/src/pyladoc/__init__.py b/src/pyladoc/__init__.py index e30d379..b2c0be7 100644 --- a/src/pyladoc/__init__.py +++ b/src/pyladoc/__init__.py @@ -336,7 +336,7 @@ class DocumentWriter(): def inline_repl(match: re.Match[str]) -> str: content = match.group(1) return f'{content}' - + return inline_pattern.sub(inline_repl, result) def _get_equation_html(self, latex_equation: str, caption: str, reference: str, block: bool = False) -> str: @@ -385,8 +385,8 @@ class DocumentWriter(): self.block = attr_dict.get('type') == 'block' elif not self.in_latex: tag_text = self.get_starttag_text() - self.self_closing = tag_text.endswith('/>') if tag_text: + self.self_closing = tag_text.endswith('/>') self.modified_html.write(tag_text) if tag == 'p': self.p_tags += 1 diff --git a/src/pyladoc/svg_tools.py b/src/pyladoc/svg_tools.py index 35eda24..8b3d9b4 100644 --- a/src/pyladoc/svg_tools.py +++ b/src/pyladoc/svg_tools.py @@ -1,7 +1,7 @@ -import xml.etree.ElementTree as ET import re from re import Match + def update_svg_ids(input_svg: str, unique_id: str) -> str: """Add a unique ID part to all svg IDs and update references ti these IDs""" id_mapping: dict[str, str] = {} @@ -35,4 +35,4 @@ def clean_svg(svg_text: str) -> str: svg_text = re.sub(r'.*?', '', svg_text, flags=re.DOTALL) # remove illegal path-tags without d attribute: - return re.sub(r']*\sd=)\s.*?/>', '', svg_text, flags=re.DOTALL) \ No newline at end of file + return re.sub(r']*\sd=)\s.*?/>', '', svg_text, flags=re.DOTALL) diff --git a/tests/test_svg.py b/tests/test_svg.py index faa4c84..4c9fac1 100644 --- a/tests/test_svg.py +++ b/tests/test_svg.py @@ -1,13 +1,14 @@ import pyladoc + def test_update_svg_ids(): test_str = r""" - @@ -16,7 +17,7 @@ def test_update_svg_ids(): - @@ -27,10 +28,9 @@ def test_update_svg_ids(): - - @@ -39,16 +39,16 @@ def test_update_svg_ids(): - + - @@ -57,77 +57,77 @@ def test_update_svg_ids(): - - - - @@ -148,4 +148,4 @@ def test_update_svg_ids(): print(result) - assert result.replace(f"svg-{unique_id}-", '') == test_str \ No newline at end of file + assert result.replace(f"svg-{unique_id}-", '') == test_str