adjust blockquote to insert line breaks

This commit is contained in:
Oliver Marks 2018-11-02 07:41:38 +00:00
parent e9755697e6
commit 88b9288b1e
3 changed files with 47 additions and 1 deletions

View File

@ -45,6 +45,10 @@ def parse_text_html(doc, token, cls="", root=True):
# return f"<p{cls}>{token.value}</p>"
return f"{token.value}"
def blockquote(doc, token, cls="", root=True):
return "<%s%s>%s</%s>\n" % (tag, cls, item.value.replace("\n", "</br>"), 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),
}

View File

@ -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

19
tests/test_regex.py Normal file
View File

@ -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