diff --git a/eorg/const.py b/eorg/const.py
index aa583a3..b9a507b 100755
--- a/eorg/const.py
+++ b/eorg/const.py
@@ -29,8 +29,8 @@ t_CAPTIONS = r"^\#\+CAPTION:"
t_IMG = r"^\[\[\s]]$"
t_RESULTS_END = r"^\:..*"
-t_BULLET_START = r"^\s*[\+|\-]"
-t_BULLET_END = r"^(?!\s*\[\+|\-]).*$"
+t_BULLET_START = r"^\s*[\+|\-|0-9\.]"
+t_BULLET_END = r"^\s*(?![\+|\-|0-9]).*$"
t_HEADER = r"^\*+"
t_META_OTHER = r"^[#]\+[A-Z\_]+\:"
diff --git a/eorg/generate.py b/eorg/generate.py
index 4a47540..4282e00 100644
--- a/eorg/generate.py
+++ b/eorg/generate.py
@@ -1,3 +1,4 @@
+import re
from html import escape
from io import StringIO
from eorg.const import Token, ESCAPE
@@ -43,10 +44,23 @@ def parse_list_html(doc, token, cls="", root=True):
def parse_bullets_html(doc, token, cls="", root=True):
response = StringIO()
- response.write(f"
")
- for row in item.value.split("\n"):
- response.write(f"- {row}
")
- response.write(f"
")
+ bullet = 'ul'
+ if token.value[0].isdigit():
+ bullet = 'ol'
+
+ response.write(f"<{bullet}{cls} style=\"list-style-type: decimal-leading-zero;\">")
+ for row in token.value.split("\n"):
+ if row:
+ text = ''
+ if row[0] in ['-', '+']:
+ text = re.sub(r'^\s*[-|+]+\s*', '', row, 1)
+
+ if row[0].isdigit():
+ text = re.sub(r'^\s*[0-9]+\.*\s*', '', row, 1)
+
+ response.write(f"{text}")
+
+ response.write(f"{bullet}>")
response.seek(0)
return response.read()
@@ -102,7 +116,7 @@ builddoc = {
tokens.VERBATIM: ("code", None),
tokens.LIST: (parse_list_html, "flow-text"),
tokens.TEXT: (parse_text_html, "flow-text"),
- tokens.BULLET: (parse_bullets_html, ""),
+ tokens.BULLET: (parse_bullets_html, "browser-default"),
tokens.SOURCE: (src, None),
tokens.EXAMPLE: (blockquote, None),
tokens.RESULTS: (blockquote, None),
diff --git a/eorg/parser.py b/eorg/parser.py
index b7245ba..c67fdc8 100644
--- a/eorg/parser.py
+++ b/eorg/parser.py
@@ -76,9 +76,7 @@ class Document:
def parse_attrs(text):
attrs = {}
value_list = text.split(':')
- print(value_list)
attrs['language'] = value_list.pop(0).strip()
- #attrs['language'] = value_list.pop(0).strip()
for row in value_list:
values = row.strip().split(' ')
attrs[values[0]] = values[1:]
@@ -109,6 +107,8 @@ def parseline(text):
return block, Token(token=key, attrs=parse_attrs(value))
if key == tokens.TABLE:
return block, Token(token=key, value=text+"\n")
+ if key == tokens.BULLET:
+ return block, Token(token=key, value=text+"\n")
return block, Token(token=key, value=value, attrs=attrs)
text = text.strip()
diff --git a/tests/test_html.py b/tests/test_html.py
index 1fae865..b30d3e5 100644
--- a/tests/test_html.py
+++ b/tests/test_html.py
@@ -105,22 +105,19 @@ head -n 5 examples/html-plain/example.py
assert result[1].value == expected[1].value
-@pytest.mark.skip
-def test_src_block():
+def test_bullet_block():
text = StringIO(
"""
- + Bullet 1
- + Bullet 2
-"""
++ Bullet 1
++ Bullet 2"""
)
expected = [
Token(tokens.BLANK, ""),
- Token(tokens.BULLET, """ Bullet 1\nBullet 2"""),
+ Token(tokens.BULLET, """+ Bullet 1\n+ Bullet 2\n"""),
]
result = parse(text).doc
assert result[0].token == tokens.BLANK
assert result[0].value == expected[0].value
assert result[1].token == tokens.BULLET
-
assert result[1].value == expected[1].value
diff --git a/tests/test_regex.py b/tests/test_regex.py
index 6e6fe46..33ce540 100644
--- a/tests/test_regex.py
+++ b/tests/test_regex.py
@@ -51,3 +51,16 @@ def test_source():
rx = const.t_SRC_BEGIN
match = re.search(rx, text)
assert match is not None
+
+
+def test_bullets():
+ # invalid if no language specified
+ text=" + bullet 1"
+ rx = const.t_BULLET_START
+ match = re.search(rx, text)
+ assert match is not None
+
+ text="+ bullet 1"
+ rx = const.t_BULLET_START
+ match = re.search(rx, text)
+ assert match is not None