Implemented detection of codeblocks and made it ignore everything inside it.
This commit is contained in:
parent
2e16be6484
commit
15718aff6f
1 changed files with 9 additions and 0 deletions
9
omg.py
9
omg.py
|
@ -91,10 +91,19 @@ class OMG:
|
||||||
"links": []
|
"links": []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
codeblock = False
|
||||||
|
|
||||||
for line in content.split("\n"):
|
for line in content.split("\n"):
|
||||||
if line == "":
|
if line == "":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if line.startswith("```"): # detect codeblocks and ignore everything inside it
|
||||||
|
codeblock = not codeblock
|
||||||
|
continue
|
||||||
|
|
||||||
|
if codeblock:
|
||||||
|
continue
|
||||||
|
|
||||||
# ==== headings ====
|
# ==== headings ====
|
||||||
if line.startswith("#"): # heading or tag
|
if line.startswith("#"): # heading or tag
|
||||||
tokens = line.split()
|
tokens = line.split()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue