Use "heading" consistently on the UI
This commit is contained in:
@@ -307,7 +307,7 @@ class NWIndex:
|
||||
nTitle = 0 # Line Number of the previous title
|
||||
cTitle = TT_NONE # Tag of the current title
|
||||
pTitle = TT_NONE # Tag of the previous title
|
||||
canSetHeader = True # First header has not yet been set
|
||||
canSetHead = True # First heading has not yet been set
|
||||
|
||||
lines = text.splitlines()
|
||||
for n, line in enumerate(lines, start=1):
|
||||
@@ -320,9 +320,9 @@ class NWIndex:
|
||||
if hDepth == "H0":
|
||||
continue
|
||||
|
||||
if canSetHeader:
|
||||
if canSetHead:
|
||||
nwItem.setMainHeading(hDepth)
|
||||
canSetHeader = False
|
||||
canSetHead = False
|
||||
|
||||
cTitle = self._itemIndex.addItemHeading(tHandle, n, hDepth, hText)
|
||||
if cTitle != TT_NONE:
|
||||
@@ -383,7 +383,7 @@ class NWIndex:
|
||||
return
|
||||
|
||||
def _splitHeading(self, line: str) -> tuple[str, str]:
|
||||
"""Split a heading into its header level and text value."""
|
||||
"""Split a heading into its heading level and text value."""
|
||||
if line.startswith("# "):
|
||||
return "H1", line[2:].strip()
|
||||
elif line.startswith("## "):
|
||||
@@ -515,8 +515,8 @@ class NWIndex:
|
||||
"""Get the index data for a given item."""
|
||||
return self._itemIndex[tHandle]
|
||||
|
||||
def getItemHeader(self, tHandle: str, sTitle: str) -> IndexHeading | None:
|
||||
"""Get the header entry for a specific item and heading."""
|
||||
def getItemHeading(self, tHandle: str, sTitle: str) -> IndexHeading | None:
|
||||
"""Get the heading entry for a specific item and heading."""
|
||||
tItem = self._itemIndex[tHandle]
|
||||
if isinstance(tItem, IndexItem):
|
||||
return tItem[sTitle]
|
||||
@@ -825,7 +825,7 @@ class ItemIndex:
|
||||
class around a single storage dictionary with a set of utility
|
||||
functions for setting and accessing the index data. Each indexed
|
||||
item is stored in an IndexItem object, which again holds an
|
||||
IndexHeading object for each header of the text.
|
||||
IndexHeading object for each heading of the text.
|
||||
"""
|
||||
|
||||
__slots__ = ("_project", "_items")
|
||||
@@ -1200,7 +1200,7 @@ class IndexHeading:
|
||||
##
|
||||
|
||||
def setLevel(self, level: str) -> None:
|
||||
"""Set the level of the header if it's a valid value."""
|
||||
"""Set the level of the heading if it's a valid value."""
|
||||
if level in nwHeaders.H_VALID:
|
||||
self._level = level
|
||||
return
|
||||
|
||||
@@ -89,10 +89,10 @@ class Tokenizer(ABC):
|
||||
T_KEYWORD = 5 # Command line
|
||||
T_TITLE = 6 # Title
|
||||
T_UNNUM = 7 # Unnumbered
|
||||
T_HEAD1 = 8 # Header 1
|
||||
T_HEAD2 = 9 # Header 2
|
||||
T_HEAD3 = 10 # Header 3
|
||||
T_HEAD4 = 11 # Header 4
|
||||
T_HEAD1 = 8 # Heading 1
|
||||
T_HEAD2 = 9 # Heading 2
|
||||
T_HEAD3 = 10 # Heading 3
|
||||
T_HEAD4 = 11 # Heading 4
|
||||
T_TEXT = 12 # Text line
|
||||
T_SEP = 13 # Scene separator
|
||||
T_SKIP = 14 # Paragraph break
|
||||
@@ -158,10 +158,10 @@ class Tokenizer(ABC):
|
||||
self._fmtScene = nwHeadFmt.TITLE # Formatting for scenes
|
||||
self._fmtSection = nwHeadFmt.TITLE # Formatting for sections
|
||||
|
||||
self._hideScene = False # Do not include scene headers
|
||||
self._hideSection = False # Do not include section headers
|
||||
self._hideScene = False # Do not include scene headings
|
||||
self._hideSection = False # Do not include section headings
|
||||
|
||||
self._linkHeaders = False # Add an anchor before headers
|
||||
self._linkHeaders = False # Add an anchor before headings
|
||||
|
||||
self._titleStyle = self.A_CENTRE | self.A_PBB
|
||||
self._chapterStyle = self.A_PBB
|
||||
@@ -309,22 +309,22 @@ class Tokenizer(ABC):
|
||||
return
|
||||
|
||||
def setHead1Margins(self, upper: float, lower: float) -> None:
|
||||
"""Set the upper and lower header 1 margin."""
|
||||
"""Set the upper and lower heading 1 margin."""
|
||||
self._marginHead1 = (float(upper), float(lower))
|
||||
return
|
||||
|
||||
def setHead2Margins(self, upper: float, lower: float) -> None:
|
||||
"""Set the upper and lower header 2 margin."""
|
||||
"""Set the upper and lower heading 2 margin."""
|
||||
self._marginHead2 = (float(upper), float(lower))
|
||||
return
|
||||
|
||||
def setHead3Margins(self, upper: float, lower: float) -> None:
|
||||
"""Set the upper and lower header 3 margin."""
|
||||
"""Set the upper and lower heading 3 margin."""
|
||||
self._marginHead3 = (float(upper), float(lower))
|
||||
return
|
||||
|
||||
def setHead4Margins(self, upper: float, lower: float) -> None:
|
||||
"""Set the upper and lower header 4 margin."""
|
||||
"""Set the upper and lower heading 4 margin."""
|
||||
self._marginHead4 = (float(upper), float(lower))
|
||||
return
|
||||
|
||||
@@ -338,8 +338,8 @@ class Tokenizer(ABC):
|
||||
self._marginMeta = (float(upper), float(lower))
|
||||
return
|
||||
|
||||
def setLinkHeaders(self, state: bool) -> None:
|
||||
"""Enable or disable adding an anchor before headers."""
|
||||
def setLinkHeadings(self, state: bool) -> None:
|
||||
"""Enable or disable adding an anchor before headings."""
|
||||
self._linkHeaders = state
|
||||
return
|
||||
|
||||
@@ -442,7 +442,7 @@ class Tokenizer(ABC):
|
||||
|
||||
def tokenizeText(self) -> None:
|
||||
"""Scan the text for either lines starting with specific
|
||||
characters that indicate headers, comments, commands etc, or
|
||||
characters that indicate headings, comments, commands etc, or
|
||||
just contain plain text. In the case of plain text, apply the
|
||||
same RegExes that the syntax highlighter uses and save the
|
||||
locations of these formatting tags into the token array.
|
||||
@@ -450,7 +450,7 @@ class Tokenizer(ABC):
|
||||
The format of the token list is an entry with a five-tuple for
|
||||
each line in the file. The tuple is as follows:
|
||||
1: The type of the block, self.T_*
|
||||
2: The header number under which the text is placed
|
||||
2: The heading number under which the text is placed
|
||||
3: The text content of the block, without leading tags
|
||||
4: The internal formatting map of the text, self.FMT_*
|
||||
5: The style of the block, self.A_*
|
||||
@@ -557,9 +557,9 @@ class Tokenizer(ABC):
|
||||
tmpMarkdown.append(f"{aLine}\n")
|
||||
|
||||
elif aLine[:2] == "# ":
|
||||
# Partition Headers
|
||||
# =================
|
||||
# Partition headers are only formatted in novel documents, and
|
||||
# Partition Headings
|
||||
# ==================
|
||||
# Partition headings are only formatted in novel documents, and
|
||||
# otherwise unchanged. Scene separators are disabled
|
||||
# immediately after partitions, and scene numbers are reset.
|
||||
|
||||
@@ -579,12 +579,12 @@ class Tokenizer(ABC):
|
||||
tmpMarkdown.append(f"{aLine}\n")
|
||||
|
||||
elif aLine[:3] == "## ":
|
||||
# Chapter Headers
|
||||
# ===============
|
||||
# Chapter headers are only formatted in novel documents, and
|
||||
# Chapter Headings
|
||||
# ================
|
||||
# Chapter headings are only formatted in novel documents, and
|
||||
# otherwise unchanged. Chapter numbers are bumped before the
|
||||
# heading is formatted. Scene separators are disabled
|
||||
# immediately after chapter headers, and scene numbers are
|
||||
# immediately after chapter headings, and scene numbers are
|
||||
# reset.
|
||||
|
||||
nHead += 1
|
||||
@@ -604,15 +604,15 @@ class Tokenizer(ABC):
|
||||
tmpMarkdown.append(f"{aLine}\n")
|
||||
|
||||
elif aLine[:4] == "### ":
|
||||
# Scene Headers
|
||||
# =============
|
||||
# Scene headers in novel documents are treated as centred
|
||||
# Scene Headings
|
||||
# ==============
|
||||
# Scene headings in novel documents are treated as centred
|
||||
# separators if the formatting does not change the text. If the
|
||||
# format is empty, the scene can be hidden or a blank paragraph
|
||||
# (skip). When the scene title has static text or no text, it
|
||||
# is always ignored if the noSep flag is set. This prevents
|
||||
# separators immediately after other titles. Scene numbers are
|
||||
# always incremented before formatting. For notes, the header
|
||||
# always incremented before formatting. For notes, the heading
|
||||
# is unchanged.
|
||||
|
||||
nHead += 1
|
||||
@@ -639,12 +639,12 @@ class Tokenizer(ABC):
|
||||
tmpMarkdown.append(f"{aLine}\n")
|
||||
|
||||
elif aLine[:5] == "#### ":
|
||||
# Section Headers
|
||||
# ===============
|
||||
# Section headers in novel docs are treated as centred
|
||||
# Section Headings
|
||||
# =================
|
||||
# Section headings in novel docs are treated as centred
|
||||
# separators if the formatting does not change the text. If the
|
||||
# format is empty, the section can be hidden or a blank
|
||||
# paragraph (skip). For notes, the header is unchanged.
|
||||
# paragraph (skip). For notes, the heading is unchanged.
|
||||
|
||||
nHead += 1
|
||||
tText = aLine[5:].strip()
|
||||
@@ -682,10 +682,10 @@ class Tokenizer(ABC):
|
||||
tmpMarkdown.append(f"{aLine}\n")
|
||||
|
||||
elif aLine[:4] == "##! ":
|
||||
# Unnumbered Chapter Header
|
||||
# =========================
|
||||
# Unnumbered Chapter Headings
|
||||
# ===========================
|
||||
# Unnumbered chapters are only meaningful in Novel docs, so if
|
||||
# we're in a note, we convert them to a plain level 2 header.
|
||||
# we're in a note, we convert them to a plain level 2 heading.
|
||||
|
||||
nHead += 1
|
||||
tText = aLine[4:].strip()
|
||||
|
||||
@@ -57,7 +57,7 @@ class GuiDocSplit(QDialog):
|
||||
|
||||
self.setWindowTitle(self.tr("Split Document"))
|
||||
|
||||
self.headLabel = QLabel("<b>{0}</b>".format(self.tr("Document Headers")))
|
||||
self.headLabel = QLabel("<b>{0}</b>".format(self.tr("Document Headings")))
|
||||
self.helpLabel = NColourLabel(
|
||||
self.tr("Select the maximum level to split into files."),
|
||||
SHARED.theme.helpText, parent=self, wrap=True
|
||||
@@ -74,17 +74,17 @@ class GuiDocSplit(QDialog):
|
||||
intoFolder = pOptions.getBool("GuiDocSplit", "intoFolder", True)
|
||||
docHierarchy = pOptions.getBool("GuiDocSplit", "docHierarchy", True)
|
||||
|
||||
# Header Selection
|
||||
# Heading Selection
|
||||
self.listBox = QListWidget()
|
||||
self.listBox.setDragDropMode(QAbstractItemView.NoDragDrop)
|
||||
self.listBox.setMinimumWidth(CONFIG.pxInt(400))
|
||||
self.listBox.setMinimumHeight(CONFIG.pxInt(180))
|
||||
|
||||
self.splitLevel = QComboBox(self)
|
||||
self.splitLevel.addItem(self.tr("Split on Header Level 1 (Title)"), 1)
|
||||
self.splitLevel.addItem(self.tr("Split up to Header Level 2 (Chapter)"), 2)
|
||||
self.splitLevel.addItem(self.tr("Split up to Header Level 3 (Scene)"), 3)
|
||||
self.splitLevel.addItem(self.tr("Split up to Header Level 4 (Section)"), 4)
|
||||
self.splitLevel.addItem(self.tr("Split on Heading Level 1 (Partition)"), 1)
|
||||
self.splitLevel.addItem(self.tr("Split up to Heading Level 2 (Chapter)"), 2)
|
||||
self.splitLevel.addItem(self.tr("Split up to Heading Level 3 (Scene)"), 3)
|
||||
self.splitLevel.addItem(self.tr("Split up to Heading Level 4 (Section)"), 4)
|
||||
spIndex = self.splitLevel.findData(spLevel)
|
||||
if spIndex != -1:
|
||||
self.splitLevel.setCurrentIndex(spIndex)
|
||||
|
||||
@@ -90,10 +90,10 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
"header2": self._makeFormat(SHARED.theme.colHead, "bold", 1.6),
|
||||
"header3": self._makeFormat(SHARED.theme.colHead, "bold", 1.4),
|
||||
"header4": self._makeFormat(SHARED.theme.colHead, "bold", 1.2),
|
||||
"header1h": self._makeFormat(SHARED.theme.colHeadH, "bold", 1.8),
|
||||
"header2h": self._makeFormat(SHARED.theme.colHeadH, "bold", 1.6),
|
||||
"header3h": self._makeFormat(SHARED.theme.colHeadH, "bold", 1.4),
|
||||
"header4h": self._makeFormat(SHARED.theme.colHeadH, "bold", 1.2),
|
||||
"head1h": self._makeFormat(SHARED.theme.colHeadH, "bold", 1.8),
|
||||
"head2h": self._makeFormat(SHARED.theme.colHeadH, "bold", 1.6),
|
||||
"head3h": self._makeFormat(SHARED.theme.colHeadH, "bold", 1.4),
|
||||
"head4h": self._makeFormat(SHARED.theme.colHeadH, "bold", 1.2),
|
||||
"bold": self._makeFormat(colEmph, "bold"),
|
||||
"italic": self._makeFormat(colEmph, "italic"),
|
||||
"strike": self._makeFormat(SHARED.theme.colHidden, "strike"),
|
||||
@@ -303,28 +303,28 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
elif text.startswith(("# ", "#! ", "## ", "##! ", "### ", "#### ")):
|
||||
self.setCurrentBlockState(self.BLOCK_TITLE)
|
||||
|
||||
if text.startswith("# "): # Header 1
|
||||
self.setFormat(0, 1, self._hStyles["header1h"])
|
||||
if text.startswith("# "): # Heading 1
|
||||
self.setFormat(0, 1, self._hStyles["head1h"])
|
||||
self.setFormat(1, len(text), self._hStyles["header1"])
|
||||
|
||||
elif text.startswith("## "): # Header 2
|
||||
self.setFormat(0, 2, self._hStyles["header2h"])
|
||||
elif text.startswith("## "): # Heading 2
|
||||
self.setFormat(0, 2, self._hStyles["head2h"])
|
||||
self.setFormat(2, len(text), self._hStyles["header2"])
|
||||
|
||||
elif text.startswith("### "): # Header 3
|
||||
self.setFormat(0, 3, self._hStyles["header3h"])
|
||||
elif text.startswith("### "): # Heading 3
|
||||
self.setFormat(0, 3, self._hStyles["head3h"])
|
||||
self.setFormat(3, len(text), self._hStyles["header3"])
|
||||
|
||||
elif text.startswith("#### "): # Header 4
|
||||
self.setFormat(0, 4, self._hStyles["header4h"])
|
||||
elif text.startswith("#### "): # Heading 4
|
||||
self.setFormat(0, 4, self._hStyles["head4h"])
|
||||
self.setFormat(4, len(text), self._hStyles["header4"])
|
||||
|
||||
elif text.startswith("#! "): # Title
|
||||
self.setFormat(0, 2, self._hStyles["header1h"])
|
||||
self.setFormat(0, 2, self._hStyles["head1h"])
|
||||
self.setFormat(2, len(text), self._hStyles["header1"])
|
||||
|
||||
elif text.startswith("##! "): # Unnumbered
|
||||
self.setFormat(0, 3, self._hStyles["header2h"])
|
||||
self.setFormat(0, 3, self._hStyles["head2h"])
|
||||
self.setFormat(3, len(text), self._hStyles["header2"])
|
||||
|
||||
elif text.startswith("%"): # Comments
|
||||
|
||||
@@ -202,7 +202,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
sPos = self.verticalScrollBar().value()
|
||||
aDoc = ToHtml(SHARED.project)
|
||||
aDoc.setPreview(CONFIG.viewComments, CONFIG.viewSynopsis)
|
||||
aDoc.setLinkHeaders(True)
|
||||
aDoc.setLinkHeadings(True)
|
||||
|
||||
# Be extra careful here to prevent crashes when first opening a
|
||||
# project as a crash here leaves no way of recovering.
|
||||
|
||||
@@ -693,29 +693,29 @@ class GuiMainMenu(QMenuBar):
|
||||
# Format > Separator
|
||||
self.fmtMenu.addSeparator()
|
||||
|
||||
# Format > Header 1 (Partition)
|
||||
self.aFmtHead1 = self.fmtMenu.addAction(self.tr("Header 1 (Partition)"))
|
||||
# Format > Heading 1 (Partition)
|
||||
self.aFmtHead1 = self.fmtMenu.addAction(self.tr("Heading 1 (Partition)"))
|
||||
self.aFmtHead1.setShortcut("Ctrl+1")
|
||||
self.aFmtHead1.triggered.connect(
|
||||
lambda: self.requestDocAction.emit(nwDocAction.BLOCK_H1)
|
||||
)
|
||||
|
||||
# Format > Header 2 (Chapter)
|
||||
self.aFmtHead2 = self.fmtMenu.addAction(self.tr("Header 2 (Chapter)"))
|
||||
# Format > Heading 2 (Chapter)
|
||||
self.aFmtHead2 = self.fmtMenu.addAction(self.tr("Heading 2 (Chapter)"))
|
||||
self.aFmtHead2.setShortcut("Ctrl+2")
|
||||
self.aFmtHead2.triggered.connect(
|
||||
lambda: self.requestDocAction.emit(nwDocAction.BLOCK_H2)
|
||||
)
|
||||
|
||||
# Format > Header 3 (Scene)
|
||||
self.aFmtHead3 = self.fmtMenu.addAction(self.tr("Header 3 (Scene)"))
|
||||
# Format > Heading 3 (Scene)
|
||||
self.aFmtHead3 = self.fmtMenu.addAction(self.tr("Heading 3 (Scene)"))
|
||||
self.aFmtHead3.setShortcut("Ctrl+3")
|
||||
self.aFmtHead3.triggered.connect(
|
||||
lambda: self.requestDocAction.emit(nwDocAction.BLOCK_H3)
|
||||
)
|
||||
|
||||
# Format > Header 4 (Section)
|
||||
self.aFmtHead4 = self.fmtMenu.addAction(self.tr("Header 4 (Section)"))
|
||||
# Format > Heading 4 (Section)
|
||||
self.aFmtHead4 = self.fmtMenu.addAction(self.tr("Heading 4 (Section)"))
|
||||
self.aFmtHead4.setShortcut("Ctrl+4")
|
||||
self.aFmtHead4.triggered.connect(
|
||||
lambda: self.requestDocAction.emit(nwDocAction.BLOCK_H4)
|
||||
|
||||
@@ -750,7 +750,7 @@ class GuiNovelTree(QTreeWidget):
|
||||
logger.debug("Generating meta data tooltip for '%s:%s'", tHandle, sTitle)
|
||||
|
||||
pIndex = SHARED.project.index
|
||||
novIdx = pIndex.getItemHeader(tHandle, sTitle)
|
||||
novIdx = pIndex.getItemHeading(tHandle, sTitle)
|
||||
refTags = pIndex.getReferences(tHandle, sTitle)
|
||||
if not novIdx:
|
||||
return
|
||||
|
||||
@@ -1020,7 +1020,7 @@ class GuiOutlineDetails(QScrollArea):
|
||||
"""
|
||||
pIndex = SHARED.project.index
|
||||
nwItem = SHARED.project.tree[tHandle]
|
||||
novIdx = pIndex.getItemHeader(tHandle, sTitle)
|
||||
novIdx = pIndex.getItemHeading(tHandle, sTitle)
|
||||
novRefs = pIndex.getReferences(tHandle, sTitle)
|
||||
if nwItem and novIdx:
|
||||
self.titleLabel.setText("<b>%s</b>" % self.tr(self.LVL_MAP.get(novIdx.level, "H1")))
|
||||
|
||||
@@ -1836,7 +1836,7 @@ class _TreeContextMenu(QMenu):
|
||||
|
||||
def _itemHeader(self) -> None:
|
||||
"""Check if there is a header that can be used for rename."""
|
||||
if hItem := SHARED.project.index.getItemHeader(self._handle, "T0001"):
|
||||
if hItem := SHARED.project.index.getItemHeading(self._handle, "T0001"):
|
||||
action = self.addAction(self.tr("Rename to Heading"))
|
||||
action.triggered.connect(
|
||||
lambda: self.projTree.renameTreeItem(self._handle, hItem.title)
|
||||
@@ -1935,7 +1935,7 @@ class _TreeContextMenu(QMenu):
|
||||
action.triggered.connect(lambda: tree._mergeDocuments(tHandle, True))
|
||||
|
||||
if isFile:
|
||||
action = menu.addAction(self.tr("Split Document by Headers"))
|
||||
action = menu.addAction(self.tr("Split Document by Headings"))
|
||||
action.triggered.connect(lambda: tree._splitDocument(tHandle))
|
||||
|
||||
return
|
||||
|
||||
@@ -642,7 +642,7 @@ class GuiIcons:
|
||||
def getItemIcon(self, tType: nwItemType, tClass: nwItemClass,
|
||||
tLayout: nwItemLayout, hLevel: str = "H0") -> QIcon:
|
||||
"""Get the correct icon for a project item based on type, class
|
||||
and header level
|
||||
and heading level
|
||||
"""
|
||||
iconName = None
|
||||
if tType == nwItemType.ROOT:
|
||||
@@ -668,7 +668,7 @@ class GuiIcons:
|
||||
return self.getIcon(iconName)
|
||||
|
||||
def getHeaderDecoration(self, hLevel: int) -> QPixmap:
|
||||
"""Get the decoration for a specific header level."""
|
||||
"""Get the decoration for a specific heading level."""
|
||||
if not self._headerDec:
|
||||
iPx = self.mainTheme.baseIconSize
|
||||
self._headerDec = [
|
||||
@@ -681,7 +681,7 @@ class GuiIcons:
|
||||
return self._headerDec[minmax(hLevel, 0, 4)]
|
||||
|
||||
def getHeaderDecorationNarrow(self, hLevel: int) -> QPixmap:
|
||||
"""Get the narrow decoration for a specific header level."""
|
||||
"""Get the narrow decoration for a specific heading level."""
|
||||
if not self._headerDecNarrow:
|
||||
iPx = self.mainTheme.baseIconSize
|
||||
self._headerDecNarrow = [
|
||||
|
||||
@@ -736,7 +736,7 @@ class GuiMain(QMainWindow):
|
||||
return False
|
||||
|
||||
if tHandle is not None and sTitle is not None:
|
||||
hItem = SHARED.project.index.getItemHeader(tHandle, sTitle)
|
||||
hItem = SHARED.project.index.getItemHeading(tHandle, sTitle)
|
||||
if hItem is not None:
|
||||
tLine = hItem.line
|
||||
|
||||
@@ -1144,7 +1144,7 @@ class GuiMain(QMainWindow):
|
||||
if tHandle is not None:
|
||||
if mode == nwDocMode.EDIT:
|
||||
tLine = None
|
||||
hItem = SHARED.project.index.getItemHeader(tHandle, sTitle)
|
||||
hItem = SHARED.project.index.getItemHeading(tHandle, sTitle)
|
||||
if hItem is not None:
|
||||
tLine = hItem.line
|
||||
self.openDocument(tHandle, tLine=tLine, changeFocus=setFocus)
|
||||
|
||||
@@ -72,7 +72,7 @@ def preProcessText(text: str, keepHeaders: bool = True) -> list[str]:
|
||||
|
||||
def standardCounter(text: str) -> tuple[int, int, int]:
|
||||
"""A counter that counts paragraphs, words and characters.
|
||||
This is the standard counter that includes headers in the word and
|
||||
This is the standard counter that includes headings in the word and
|
||||
character counts.
|
||||
"""
|
||||
cCount = 0
|
||||
|
||||
@@ -1011,10 +1011,10 @@ class _StatsWidget(QWidget):
|
||||
|
||||
self.leftForm = QFormLayout()
|
||||
self.leftForm.addRow(self.tr("Words"), self.maxTotalWords)
|
||||
self.leftForm.addRow(self.tr("Header Words"), self.maxHeaderWords)
|
||||
self.leftForm.addRow(self.tr("Heading Words"), self.maxHeaderWords)
|
||||
self.leftForm.addRow(self.tr("Body Text Words"), self.maxTextWords)
|
||||
self.leftForm.addRow("", QLabel(self))
|
||||
self.leftForm.addRow(self.tr("Headers"), self.maxTitleCount)
|
||||
self.leftForm.addRow(self.tr("Headings"), self.maxTitleCount)
|
||||
self.leftForm.addRow(self.tr("Paragraphs"), self.maxParCount)
|
||||
self.leftForm.setHorizontalSpacing(hPx)
|
||||
self.leftForm.setVerticalSpacing(vPx)
|
||||
@@ -1038,10 +1038,10 @@ class _StatsWidget(QWidget):
|
||||
|
||||
self.rightForm = QFormLayout()
|
||||
self.rightForm.addRow(self.tr("Characters"), self.maxTotalChars)
|
||||
self.rightForm.addRow(self.tr("Header Characters"), self.maxHeaderChars)
|
||||
self.rightForm.addRow(self.tr("Heading Characters"), self.maxHeaderChars)
|
||||
self.rightForm.addRow(self.tr("Body Text Characters"), self.maxTextChars)
|
||||
self.rightForm.addRow(self.tr("Characters, No Spaces"), self.maxTotalWordChars)
|
||||
self.rightForm.addRow(self.tr("Header Characters, No Spaces"), self.maxHeaderWordChars)
|
||||
self.rightForm.addRow(self.tr("Heading Characters, No Spaces"), self.maxHeaderWordChars)
|
||||
self.rightForm.addRow(self.tr("Body Text Characters, No Spaces"), self.maxTextWordChars)
|
||||
self.rightForm.setHorizontalSpacing(hPx)
|
||||
self.rightForm.setVerticalSpacing(vPx)
|
||||
|
||||
@@ -252,7 +252,7 @@ def testCoreIndex_CheckThese(mockGUI, fncPath, mockRnd):
|
||||
assert index._tagsIndex.tagHandle("Jane") == cHandle
|
||||
assert index._tagsIndex.tagHeading("Jane") == "T0001"
|
||||
assert index._tagsIndex.tagClass("Jane") == "CHARACTER"
|
||||
assert index.getItemHeader(nHandle, "T0001").title == "Hello World!" # type: ignore
|
||||
assert index.getItemHeading(nHandle, "T0001").title == "Hello World!" # type: ignore
|
||||
assert index.getReferences(nHandle, "T0001") == {
|
||||
"@char": [],
|
||||
"@custom": [],
|
||||
@@ -382,7 +382,7 @@ def testCoreIndex_ScanText(mockGUI, fncPath, mockRnd):
|
||||
assert index._tagsIndex.tagHandle("Jane") == cHandle
|
||||
assert index._tagsIndex.tagHeading("Jane") == "T0001"
|
||||
assert index._tagsIndex.tagClass("Jane") == "CHARACTER"
|
||||
assert index.getItemHeader(nHandle, "T0001").title == "Hello World!" # type: ignore
|
||||
assert index.getItemHeading(nHandle, "T0001").title == "Hello World!" # type: ignore
|
||||
|
||||
# Title Indexing
|
||||
# ==============
|
||||
@@ -560,8 +560,8 @@ def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
|
||||
assert isinstance(cHandle, str)
|
||||
assert isinstance(dHandle, str)
|
||||
|
||||
assert index.getItemHeader("", "") is None
|
||||
assert index.getItemHeader(C.hNovelRoot, "") is None
|
||||
assert index.getItemHeading("", "") is None
|
||||
assert index.getItemHeading(C.hNovelRoot, "") is None
|
||||
|
||||
assert index.scanText(cHandle, (
|
||||
"# Jane Smith\n"
|
||||
@@ -685,11 +685,11 @@ def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
|
||||
assert list(index.getTagsData()) == [(
|
||||
"jane", "Jane", "CHARACTER",
|
||||
index.getItemData(cHandle),
|
||||
index.getItemHeader(cHandle, "T0001")
|
||||
index.getItemHeading(cHandle, "T0001")
|
||||
), (
|
||||
"john", "John", "CHARACTER",
|
||||
index.getItemData(dHandle),
|
||||
index.getItemHeader(dHandle, "T0001")
|
||||
index.getItemHeading(dHandle, "T0001")
|
||||
)]
|
||||
|
||||
# getSingleTag
|
||||
@@ -697,7 +697,7 @@ def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
|
||||
assert index.getSingleTag("jane") == (
|
||||
"Jane", "CHARACTER",
|
||||
index.getItemData(cHandle),
|
||||
index.getItemHeader(cHandle, "T0001")
|
||||
index.getItemHeading(cHandle, "T0001")
|
||||
)
|
||||
assert index.getSingleTag("foobar") == ("", "", None, None)
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ def testCoreToHtml_ConvertHeaders(mockGUI):
|
||||
html._isNovel = False
|
||||
html._isNote = True
|
||||
html._isFirst = True
|
||||
html.setLinkHeaders(True)
|
||||
html.setLinkHeadings(True)
|
||||
|
||||
# Header 1
|
||||
html._text = "# Heading One\n"
|
||||
@@ -270,7 +270,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
|
||||
html._isNovel = True
|
||||
html._isNote = False
|
||||
html.setLinkHeaders(True)
|
||||
html.setLinkHeadings(True)
|
||||
|
||||
# Special Titles
|
||||
# ==============
|
||||
@@ -319,7 +319,7 @@ def testCoreToHtml_ConvertDirect(mockGUI):
|
||||
# Alignment
|
||||
# =========
|
||||
|
||||
html.setLinkHeaders(False)
|
||||
html.setLinkHeadings(False)
|
||||
|
||||
# Align Left
|
||||
html.setStyles(False)
|
||||
|
||||
@@ -86,7 +86,7 @@ def testCoreToken_Setters(mockGUI):
|
||||
tokens.setHead4Margins(2.0, 2.0)
|
||||
tokens.setTextMargins(2.0, 2.0)
|
||||
tokens.setMetaMargins(2.0, 2.0)
|
||||
tokens.setLinkHeaders(True)
|
||||
tokens.setLinkHeadings(True)
|
||||
tokens.setBodyText(False)
|
||||
tokens.setSynopsis(True)
|
||||
tokens.setComments(True)
|
||||
|
||||
@@ -1229,7 +1229,7 @@ def testGuiProjTree_ContextMenu(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
]
|
||||
assert getTransformSubMenu(ctxMenu) == [
|
||||
"Convert to Project Note", "Merge Child Items into Self",
|
||||
"Merge Child Items into New", "Split Document by Headers"
|
||||
"Merge Child Items into New", "Split Document by Headings"
|
||||
]
|
||||
|
||||
# Context Menu on Note File Item in Character Folder
|
||||
@@ -1244,7 +1244,7 @@ def testGuiProjTree_ContextMenu(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
"Move to Trash",
|
||||
]
|
||||
assert getTransformSubMenu(ctxMenu) == [
|
||||
"Split Document by Headers",
|
||||
"Split Document by Headings",
|
||||
]
|
||||
|
||||
# Context Menu on Note File Item in Novel Tree
|
||||
@@ -1259,7 +1259,7 @@ def testGuiProjTree_ContextMenu(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
"Move to Trash",
|
||||
]
|
||||
assert getTransformSubMenu(ctxMenu) == [
|
||||
"Convert to Novel Document", "Split Document by Headers",
|
||||
"Convert to Novel Document", "Split Document by Headings",
|
||||
]
|
||||
|
||||
# Context Menu on Multiple Items, Clicked on Document
|
||||
|
||||
Reference in New Issue
Block a user