diff --git a/eorg/generate.py b/eorg/generate.py index abb2599..25b5e86 100644 --- a/eorg/generate.py +++ b/eorg/generate.py @@ -45,6 +45,10 @@ def parse_text_html(doc, token, cls="", root=True): # return f"
{token.value}
" return f"{token.value}" +def blockquote(doc, token, cls="", root=True): + return "<%s%s>%s%s>\n" % (tag, cls, item.value.replace("\n", ""), tag) + + builddoc = { "HEADER1": ("h2", None), @@ -59,7 +63,7 @@ builddoc = { "LIST": (parse_list_html, "flow-text"), "TEXT": (parse_text_html, "flow-text"), "SRC_BEGIN": (src, None), - "EXAMPLE": ("blockquote", None), + "EXAMPLE": (blockquote, None), } diff --git a/tests/test_html.py b/tests/test_html.py index 43404aa..23e6bb1 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -1,5 +1,6 @@ import os import pytest +from io import StringIO from eorg.parser import Token from eorg.parser import parse from eorg.parser import parse_text @@ -36,3 +37,25 @@ def test_image(): assert result[0].value == expected[0].value assert result[1].value == expected[1].value assert result[2].value == expected[2].value + + + +def test_example(): + text = StringIO( + """ +#+BEGIN_EXAMPLE +*I'm bold text* +/I'm italic text/ +_I'm underlined text_ +#+END_EXAMPLE""") + + expected = [ + Token("BREAK", ""), + Token("EXAMPLE", """*I'm bold text* +/I'm italic text/ +_I'm underlined text_ +"""), + ] + result = parse(text).doc + assert result[0].value == expected[0].value + assert result[1].value == expected[1].value diff --git a/tests/test_regex.py b/tests/test_regex.py new file mode 100644 index 0000000..c80a160 --- /dev/null +++ b/tests/test_regex.py @@ -0,0 +1,19 @@ +import os +import re +import pytest +from eorg import const +from eorg.parser import parse +from eorg.generate import html + + +def test_example(): + text="#+BEGIN_EXAMPLE" + rx = const.t_EXAMPLE_BEGIN + match = re.search(rx, text) + assert match is not None + + text="#+BEGIN_EXAMPLE " + rx = const.t_EXAMPLE_BEGIN + match = re.search(rx, text) + assert match is not None +