Add support for triple hash alt header format

This commit is contained in:
Veronica Berglyd Olsen
2024-03-11 23:25:28 +01:00
parent 459a8e5cde
commit bdff3b4ee2
4 changed files with 13 additions and 1 deletions
+2
View File
@@ -396,6 +396,8 @@ class NWIndex:
return "H1", line[3:].strip()
elif line.startswith("##! "):
return "H2", line[4:].strip()
elif line.startswith("###! "):
return "H3", line[5:].strip()
return "H0", ""
def _indexWordCounts(self, tHandle: str, text: str, sTitle: str) -> None:
+3
View File
@@ -1651,6 +1651,9 @@ class GuiDocEditor(QPlainTextEdit):
elif text.startswith("##! "):
temp = text[4:]
offset = 4
elif text.startswith("###! "):
temp = text[5:]
offset = 5
elif text.startswith(">> "):
temp = text[3:]
offset = 3
+5 -1
View File
@@ -300,7 +300,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
# so we force a return here
return
elif text.startswith(("# ", "#! ", "## ", "##! ", "### ", "#### ")):
elif text.startswith(("# ", "#! ", "## ", "##! ", "### ", "###! ", "#### ")):
self.setCurrentBlockState(self.BLOCK_TITLE)
if text.startswith("# "): # Heading 1
@@ -327,6 +327,10 @@ class GuiDocHighlighter(QSyntaxHighlighter):
self.setFormat(0, 3, self._hStyles["head2h"])
self.setFormat(3, len(text), self._hStyles["header2"])
elif text.startswith("###! "): # Hard Scene
self.setFormat(0, 4, self._hStyles["head3h"])
self.setFormat(4, len(text), self._hStyles["header3"])
elif text.startswith("%"): # Comments
self.setCurrentBlockState(self.BLOCK_TEXT)
cStyle, _, cPos = processComment(text)
+3
View File
@@ -106,6 +106,9 @@ def standardCounter(text: str) -> tuple[int, int, int]:
elif line[:4] == "##! ":
line = line[4:]
countPara = False
elif line[:5] == "###! ":
line = line[5:]
countPara = False
wCount += len(line.split())
cCount += len(line)