Skip to content

Commit 549817e

Browse files
authored
🔀 Merge pull request #31 from davep/improve-quotes
Improve the detection of quotes
2 parents 5626b5b + b35b900 commit 549817e

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
([#26](https://github.com/davep/rogallo/pull/26))
1313
- Improved the detection of headings.
1414
([#29](https://github.com/davep/rogallo/pull/29))
15+
- Improved the detection of quotes.
16+
([#31](https://github.com/davep/rogallo/pull/31))
1517

1618
## v0.1.0
1719

src/rogallo/gemtext/parser.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ def uri(self) -> str:
100100
"""Marker for a level 2 heading in Gemtext."""
101101
_H3: Final[str] = "###"
102102
"""Marker for a level 3 heading in Gemtext."""
103+
_QUOTE: Final[str] = ">"
104+
"""Marker for a quote in Gemtext."""
103105

104106

105107
##############################################################################
@@ -133,8 +135,8 @@ def _parse(self) -> Iterator[Line]:
133135
elif line.startswith(_LINK):
134136
parts = line.removeprefix(_LINK).strip().split(maxsplit=1)
135137
yield Link(parts[0], parts[1] if len(parts) > 1 else "")
136-
elif line.startswith("> "):
137-
yield Quote(line.removeprefix("> ").strip())
138+
elif line.startswith(_QUOTE):
139+
yield Quote(line.removeprefix(_QUOTE).strip())
138140
elif line.startswith(_H3):
139141
yield Heading(line.removeprefix(_H3).strip(), 3)
140142
elif line.startswith(_H2):

tests/unit/test_gemtext.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ def test_str_gemtext() -> None:
3939
("\nSecond line.", ""),
4040
(" \nSecond line.", " "),
4141
(" > Not a quote", " > Not a quote"),
42-
(">Not a quote", ">Not a quote"),
43-
(">> Not a quote", ">> Not a quote"),
4442
(" # Not a header", " # Not a header"),
4543
("*Not a list item", "*Not a list item"),
4644
("** Not a list item", "** Not a list item"),
@@ -93,6 +91,7 @@ def test_parse_header(gemtext: str, expected_level: int, expected_content: str)
9391
[
9492
("> This is a quote.", "This is a quote."),
9593
("> This is a quote.", "This is a quote."),
94+
(">> This is a quote.", "> This is a quote."),
9695
("> > This is a quote.", "> This is a quote."),
9796
("> This is a quote.\n> Second line.", "This is a quote."),
9897
("> \nSecond line.", ""),

0 commit comments

Comments
 (0)