[gi-docgen/gtkdoc-sigils: 1/2] Do not handle gtk-doc sigils inside code blocks
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gi-docgen/gtkdoc-sigils: 1/2] Do not handle gtk-doc sigils inside code blocks
- Date: Wed, 11 Aug 2021 19:16:03 +0000 (UTC)
commit 5a48acfb72642755de899b529fa4c46984e16c13
Author: Emmanuele Bassi <ebassi gnome org>
Date: Wed Aug 11 19:45:41 2021 +0100
Do not handle gtk-doc sigils inside code blocks
The gtk-doc sigils only apply to text blocks.
gidocgen/mdext.py | 34 ++++++++++++++++++++++------------
1 file changed, 22 insertions(+), 12 deletions(-)
---
diff --git a/gidocgen/mdext.py b/gidocgen/mdext.py
index 7ee1761..a081e74 100644
--- a/gidocgen/mdext.py
+++ b/gidocgen/mdext.py
@@ -22,25 +22,35 @@ class GtkDocPreprocessor(Preprocessor):
"""Remove all gtk-doc sigils from the Markdown text"""
def run(self, lines):
new_lines = []
+ inside_code_block = False
for line in lines:
+ if line.startswith("```"):
+ if not inside_code_block:
+ inside_code_block = True
+ else:
+ inside_code_block = False
+
new_line = line
- # XXX: The order is important; signals and properties have
- # higher precedence than types
- # Signal sigil
- new_line = re.sub(SIGNAL_SIGIL_RE, r"\g<1>`\g<2>::\g<3>`", new_line)
+ # Never transform code blocks
+ if not inside_code_block:
+ # XXX: The order is important; signals and properties have
+ # higher precedence than types
+
+ # Signal sigil
+ new_line = re.sub(SIGNAL_SIGIL_RE, r"\g<1>`\g<2>::\g<3>`", new_line)
- # Property sigil
- new_line = re.sub(PROP_SIGIL_RE, r"\g<1>`\g<2>:\g<3>`", new_line)
+ # Property sigil
+ new_line = re.sub(PROP_SIGIL_RE, r"\g<1>`\g<2>:\g<3>`", new_line)
- # Type sigil
- new_line = re.sub(TYPE_SIGIL_RE, r"\g<1>`\g<2>`", new_line)
+ # Type sigil
+ new_line = re.sub(TYPE_SIGIL_RE, r"\g<1>`\g<2>`", new_line)
- # Constant sygil
- new_line = re.sub(CONST_SIGIL_RE, r"\g<1>`\g<2>`", new_line)
+ # Constant sygil
+ new_line = re.sub(CONST_SIGIL_RE, r"\g<1>`\g<2>`", new_line)
- # Argument sygil
- new_line = re.sub(ARG_SIGIL_RE, r"\g<1>`\g<2>`", new_line)
+ # Argument sygil
+ new_line = re.sub(ARG_SIGIL_RE, r"\g<1>`\g<2>`", new_line)
new_lines.append(new_line)
return new_lines
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]