adjust blockquote to insert line breaks
This commit is contained in:
parent
e9755697e6
commit
88b9288b1e
|
@ -45,6 +45,10 @@ def parse_text_html(doc, token, cls="", root=True):
|
||||||
# return f"<p{cls}>{token.value}</p>"
|
# return f"<p{cls}>{token.value}</p>"
|
||||||
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", "</br>"), tag)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
builddoc = {
|
builddoc = {
|
||||||
"HEADER1": ("h2", None),
|
"HEADER1": ("h2", None),
|
||||||
|
@ -59,7 +63,7 @@ builddoc = {
|
||||||
"LIST": (parse_list_html, "flow-text"),
|
"LIST": (parse_list_html, "flow-text"),
|
||||||
"TEXT": (parse_text_html, "flow-text"),
|
"TEXT": (parse_text_html, "flow-text"),
|
||||||
"SRC_BEGIN": (src, None),
|
"SRC_BEGIN": (src, None),
|
||||||
"EXAMPLE": ("blockquote", None),
|
"EXAMPLE": (blockquote, None),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
|
from io import StringIO
|
||||||
from eorg.parser import Token
|
from eorg.parser import Token
|
||||||
from eorg.parser import parse
|
from eorg.parser import parse
|
||||||
from eorg.parser import parse_text
|
from eorg.parser import parse_text
|
||||||
|
@ -36,3 +37,25 @@ def test_image():
|
||||||
assert result[0].value == expected[0].value
|
assert result[0].value == expected[0].value
|
||||||
assert result[1].value == expected[1].value
|
assert result[1].value == expected[1].value
|
||||||
assert result[2].value == expected[2].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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue