diff --git a/test/markdown_builder.py b/test/markdown_builder.py index 450a52b..c232dc2 100644 --- a/test/markdown_builder.py +++ b/test/markdown_builder.py @@ -7,6 +7,7 @@ def __init__(self, delimiter='```uml'): self._end_delimiter = '::end-uml::' if delimiter == '::uml::' else re.sub(r'\w', '', delimiter) self._buffer = "" self._extended_syntax = False + self._indent = 0 self._reset_diagram() def _reset_diagram(self): @@ -29,8 +30,8 @@ def _emit_diagram(self): if self._diagram_buffer: delim = re.sub(r'(\W{3,})(\w+)', r'\1{\2', self._delimiter) if self._extended_syntax else self._delimiter args = self._format + self._class + self._alt + self._title + self._width + self._height - self._buffer += delim+args+('}' if self._extended_syntax else '') - self._buffer += "\n"+self._diagram_buffer+"\n"+self._end_delimiter+"\n" + self._buffer += (' '*self._indent)+delim+args+('}' if self._extended_syntax else '') + self._buffer += "\n"+(' '*self._indent)+self._diagram_buffer+"\n"+(' '*self._indent)+self._end_delimiter+"\n" self._reset_diagram() @@ -108,7 +109,7 @@ def text(self, txt): self._buffer += txt return self - def diagram(self, diag): + def diagram(self, diag, indent=0): """ Define a new diagram. :param diag: Diagram source @@ -118,6 +119,15 @@ def diagram(self, diag): self._diagram_buffer = diag return self + def indent(self, value): + """ + Indent next block of text with the specified number of spaces. + :param value: how many spaces to indent + :return: The object itself + """ + self._indent = value + return self + def build(self): """ Return the markdown source build with the previous commands. diff --git a/test/plantuml b/test/plantuml index 91f0de4..e21dc20 100755 --- a/test/plantuml +++ b/test/plantuml @@ -1,4 +1,4 @@ #!/bin/sh PLANTUML_VER="1.2018.2" [ -f "/tmp/plantuml.${PLANTUML_VER}.jar" ] || wget -q "http://sourceforge.net/projects/plantuml/files/plantuml.${PLANTUML_VER}.jar/download" -O /tmp/plantuml.${PLANTUML_VER}.jar -java -jar /tmp/plantuml.${PLANTUML_VER}.jar ${@} +java -Djava.awt.headless=true -jar /tmp/plantuml.${PLANTUML_VER}.jar ${@} diff --git a/test/test_plantuml.py b/test/test_plantuml.py index a9c5687..38af430 100644 --- a/test/test_plantuml.py +++ b/test/test_plantuml.py @@ -245,8 +245,24 @@ def test_other_fenced_code(self): self.assertEqual(self._stripImageData(self._load_file('code_and_diag.html')), self._stripImageData(self.md.convert(text))) - def test_unicode_chars(self): + def test_indented_fenced_code(self): + """ + Test handling of indented fenced code """ + text = self.text_builder.text('* list item\n\n') \ + .indent(4) \ + .diagram('A --> B') \ + .build() + self.assertEqual('''<ul> +<li> +<p>list item</p> +<p><img alt="uml diagram" class="uml" src="data:image/png;base64,%s" title="" /></p> +</li> +</ul>''' % self.FAKE_IMAGE, + self._stripImageData(self.md.convert(text))) + + def test_unicode_chars(self): + """indented_code Test that svg_inline handles correctly utf8 characters """ # Example diagram from issue 21