feat: also parse within formatting
Signed-off-by: Konstantin Fickel <mail@konstantinfickel.de>
This commit is contained in:
parent
fa85017ce3
commit
8f5a000c5c
3 changed files with 186 additions and 34 deletions
|
|
@ -44,11 +44,11 @@ class TestParseProcess:
|
|||
)
|
||||
|
||||
def test_parse_single_line_with_two_tags(self):
|
||||
test_file = "@Tag1 @Tag2 Hello World"
|
||||
test_file = "@Marker1 @Marker2 Hello World"
|
||||
assert parse_markdown_file(self.file_name, test_file) == StreamFile(
|
||||
filename=self.file_name,
|
||||
shard=Shard(
|
||||
markers=["Tag1", "Tag2"],
|
||||
markers=["Marker1", "Marker2"],
|
||||
start_line=1,
|
||||
end_line=1,
|
||||
),
|
||||
|
|
@ -149,7 +149,7 @@ class TestParseProcess:
|
|||
),
|
||||
)
|
||||
|
||||
def test_continue_full_parsing_before_headings_start(self):
|
||||
def test_parse_fullly_before_headings_start(self):
|
||||
file_text = "Hello\n\n@Marker1 World!\n\n# @Marker2 I'm a heading!"
|
||||
|
||||
assert parse_markdown_file(self.file_name, file_text).shard == Shard(
|
||||
|
|
@ -171,7 +171,7 @@ class TestParseProcess:
|
|||
],
|
||||
)
|
||||
|
||||
def test_complex_heading_structure(self):
|
||||
def test_parse_complex_heading_structure(self):
|
||||
file_text = "Preamble @Preamble\n## @Intro\n# @Title\n## @Chapter1\n## @Chapter2\n### Section 1\n### Section 2"
|
||||
|
||||
assert parse_markdown_file(self.file_name, file_text).shard == Shard(
|
||||
|
|
@ -228,3 +228,116 @@ class TestParseProcess:
|
|||
)
|
||||
],
|
||||
)
|
||||
|
||||
def test_parse_complex_list(self):
|
||||
file_text = """* I'm the parent!
|
||||
* @Marker1 I've got a marker\n
|
||||
* I've got no marker!
|
||||
* I've got a child with a marker!
|
||||
* @Marker2 I'm the child with the marker
|
||||
"""
|
||||
|
||||
assert parse_markdown_file(self.file_name, file_text).shard == Shard(
|
||||
markers=[],
|
||||
tags=[],
|
||||
start_line=1,
|
||||
end_line=6,
|
||||
children=[
|
||||
Shard(
|
||||
markers=[],
|
||||
tags=[],
|
||||
start_line=2,
|
||||
end_line=6,
|
||||
children=[
|
||||
Shard(
|
||||
markers=["Marker1"],
|
||||
tags=[],
|
||||
start_line=2,
|
||||
end_line=3,
|
||||
children=[],
|
||||
),
|
||||
Shard(
|
||||
markers=[],
|
||||
tags=[],
|
||||
start_line=5,
|
||||
end_line=6,
|
||||
children=[
|
||||
Shard(
|
||||
markers=["Marker2"],
|
||||
tags=[],
|
||||
start_line=6,
|
||||
end_line=6,
|
||||
children=[],
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
def test_parse_ignores_tags_in_code(self):
|
||||
file_text = "```\n@Marker\n```"
|
||||
|
||||
assert parse_markdown_file(self.file_name, file_text).shard == Shard(
|
||||
markers=[],
|
||||
tags=[],
|
||||
start_line=1,
|
||||
end_line=3,
|
||||
children=[],
|
||||
)
|
||||
|
||||
def test_parse_finds_tags_in_italic_text(self):
|
||||
file_text = "*@ItalicMarker*"
|
||||
|
||||
assert parse_markdown_file(self.file_name, file_text).shard == Shard(
|
||||
markers=["ItalicMarker"],
|
||||
tags=[],
|
||||
start_line=1,
|
||||
end_line=1,
|
||||
children=[],
|
||||
)
|
||||
|
||||
def test_parse_finds_tags_in_bold_text(self):
|
||||
file_text = "**@BoldMarker**"
|
||||
|
||||
assert parse_markdown_file(self.file_name, file_text).shard == Shard(
|
||||
markers=["BoldMarker"],
|
||||
tags=[],
|
||||
start_line=1,
|
||||
end_line=1,
|
||||
children=[],
|
||||
)
|
||||
|
||||
def test_parse_finds_tags_in_strikethrough_text(self):
|
||||
file_text = "~~@StrikeMarker~~"
|
||||
|
||||
assert parse_markdown_file(self.file_name, file_text).shard == Shard(
|
||||
markers=["StrikeMarker"],
|
||||
tags=[],
|
||||
start_line=1,
|
||||
end_line=1,
|
||||
children=[],
|
||||
)
|
||||
|
||||
def test_parse_finds_tags_in_link(self):
|
||||
file_text = "[@LinkMarker](https://konstantinfickel.de)"
|
||||
|
||||
assert parse_markdown_file(self.file_name, file_text).shard == Shard(
|
||||
markers=["LinkMarker"],
|
||||
tags=[],
|
||||
start_line=1,
|
||||
end_line=1,
|
||||
children=[],
|
||||
)
|
||||
|
||||
def test_parse_continues_looking_for_markers_after_first_link_marker(self):
|
||||
file_text = "[@LinkMarker1](https://konstantinfickel.de1) [@LinkMarker2](https://konstantinfickel.de)"
|
||||
|
||||
assert parse_markdown_file(self.file_name, file_text).shard == Shard(
|
||||
markers=["LinkMarker1", "LinkMarker2"],
|
||||
tags=[],
|
||||
start_line=1,
|
||||
end_line=1,
|
||||
children=[],
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue