mirror of
https://codeberg.org/fediverse/fep.git
synced 2026-08-09 05:56:10 +00:00
Website: Escape double quotes when producing page description (#825)
Double quotes are escaped to fix FEP-db0e and FEP-7b29 pages. Removed ':' replacement, it is no longer necessary. Reviewed-on: https://codeberg.org/fediverse/fep/pulls/825
This commit is contained in:
@@ -57,9 +57,8 @@ def clean_markdown(text: str) -> str:
|
||||
"""Transforms markdown to a plain text string. To be used in the frontmatter"""
|
||||
transformed = nh3.clean(markdown(text), tags=set())
|
||||
transformed = re.sub(r"\[(.+?)\]\[(.+?)\]", r"\1", transformed)
|
||||
transformed = transformed.replace(
|
||||
":", " "
|
||||
) # See https://codeberg.org/fediverse/fep/pulls/673/files#issuecomment-7514311
|
||||
# Escape double quotes (FEP-db0e, FEP-7b29)
|
||||
transformed = transformed.replace('"', '\\"')
|
||||
return transformed.replace("\n", " ")
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ def test_format_metatable():
|
||||
("[link](http://test.example)", "link"),
|
||||
("[link][link]", "link"),
|
||||
("[a][a] [b][b]", "a b"),
|
||||
("a:b", "a b"),
|
||||
('a "b"', r'a \"b\"'),
|
||||
],
|
||||
)
|
||||
def test_clean_markdown(text: str, expected: str):
|
||||
|
||||
Reference in New Issue
Block a user