feature: implement index on html side as stub
This commit is contained in:
@@ -6,6 +6,7 @@ from .dash import Dash
|
|||||||
from .formula import Formula
|
from .formula import Formula
|
||||||
from .halfwidth_spaces import HalfwidthSpaces
|
from .halfwidth_spaces import HalfwidthSpaces
|
||||||
from .include import Include
|
from .include import Include
|
||||||
|
from .index import Index
|
||||||
from .morse import Morse
|
from .morse import Morse
|
||||||
from .nonbreaking_spaces import NonbreakingSpaces, NonbreakingSpacesDots
|
from .nonbreaking_spaces import NonbreakingSpaces, NonbreakingSpacesDots
|
||||||
from .photo import Photo
|
from .photo import Photo
|
||||||
@@ -64,6 +65,7 @@ class FiftyOhmHtmlRenderer(HtmlRenderer):
|
|||||||
Qso,
|
Qso,
|
||||||
Include,
|
Include,
|
||||||
Formula,
|
Formula,
|
||||||
|
Index,
|
||||||
*extras,
|
*extras,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
@@ -332,3 +334,7 @@ class FiftyOhmHtmlRenderer(HtmlRenderer):
|
|||||||
|
|
||||||
def render_formula(self, token):
|
def render_formula(self, token):
|
||||||
return f"\n$${token.formula}$$\n"
|
return f"\n$${token.formula}$$\n"
|
||||||
|
|
||||||
|
def render_index(self, token):
|
||||||
|
# For HTML just ignore the index
|
||||||
|
return ""
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
from mistletoe.span_token import SpanToken
|
||||||
|
|
||||||
|
|
||||||
|
class Index(SpanToken):
|
||||||
|
"""
|
||||||
|
Resolve index commands
|
||||||
|
Identifies "[index:term:subterm]" or "[index:term]"
|
||||||
|
"""
|
||||||
|
|
||||||
|
pattern = re.compile(r"[ \t]*\[index:([^:\]\s]+)(?::([^:\]\s]+))?\]")
|
||||||
|
|
||||||
|
def __init__(self, match_object):
|
||||||
|
self.first = match_object.group(1)
|
||||||
|
self.second = match_object.group(2)
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import mistletoe
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from renderer.fifty_ohm_html_renderer import FiftyOhmHtmlRenderer
|
||||||
|
from test.util import paragraph
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.html
|
||||||
|
def test_index_html():
|
||||||
|
|
||||||
|
assertions = {
|
||||||
|
"Im Betrieb werden Yagi-Antennen [index:Antenne:Yagi-Antenne] oft gedreht": "Im Betrieb werden Yagi-Antennen oft gedreht",
|
||||||
|
"Im Betrieb werden Yagi-Antennen[index:Antenne:Yagi-Antenne] oft gedreht": "Im Betrieb werden Yagi-Antennen oft gedreht",
|
||||||
|
"Im Betrieb werden Yagi-Antennen [index:Antenne] oft gedreht": "Im Betrieb werden Yagi-Antennen oft gedreht",
|
||||||
|
"Im Betrieb werden Yagi-Antennen[index:Antenne] oft gedreht": "Im Betrieb werden Yagi-Antennen oft gedreht",
|
||||||
|
}
|
||||||
|
|
||||||
|
for key, value in assertions.items():
|
||||||
|
assert mistletoe.markdown(key, FiftyOhmHtmlRenderer) == paragraph(value)
|
||||||
Reference in New Issue
Block a user