summaryrefslogtreecommitdiffstats
path: root/markdown_it/rules_inline/html_inline.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:24:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:24:24 +0000
commit12e8343068b906f8b2afddc5569968a8a91fa5b0 (patch)
tree75cc5e05a4392ea0292251898f992a15a16b172b /markdown_it/rules_inline/html_inline.py
parentInitial commit. (diff)
downloadmarkdown-it-py-12e8343068b906f8b2afddc5569968a8a91fa5b0.tar.xz
markdown-it-py-12e8343068b906f8b2afddc5569968a8a91fa5b0.zip
Adding upstream version 2.1.0.upstream/2.1.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--markdown_it/rules_inline/html_inline.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/markdown_it/rules_inline/html_inline.py b/markdown_it/rules_inline/html_inline.py
new file mode 100644
index 0000000..295cc5c
--- /dev/null
+++ b/markdown_it/rules_inline/html_inline.py
@@ -0,0 +1,43 @@
+# Process html tags
+from ..common.html_re import HTML_TAG_RE
+from .state_inline import StateInline
+
+
+def isLetter(ch: int):
+ lc = ch | 0x20 # to lower case
+ # /* a */ and /* z */
+ return (lc >= 0x61) and (lc <= 0x7A)
+
+
+def html_inline(state: StateInline, silent: bool):
+
+ pos = state.pos
+
+ if not state.md.options.get("html", None):
+ return False
+
+ # Check start
+ maximum = state.posMax
+ if state.srcCharCode[pos] != 0x3C or pos + 2 >= maximum: # /* < */
+ return False
+
+ # Quick fail on second char
+ ch = state.srcCharCode[pos + 1]
+ if (
+ ch != 0x21
+ and ch != 0x3F # /* ! */
+ and ch != 0x2F # /* ? */
+ and not isLetter(ch) # /* / */
+ ):
+ return False
+
+ match = HTML_TAG_RE.search(state.src[pos:])
+ if not match:
+ return False
+
+ if not silent:
+ token = state.push("html_inline", "", 0)
+ token.content = state.src[pos : pos + len(match.group(0))]
+
+ state.pos += len(match.group(0))
+ return True