Split up block types of comments in build formats
This commit is contained in:
@@ -37,7 +37,7 @@ from PyQt6.QtPrintSupport import QPrinter
|
||||
from novelwriter import __version__
|
||||
from novelwriter.constants import nwStyles, nwUnicode
|
||||
from novelwriter.formats.shared import BlockFmt, BlockTyp, T_Formats, TextFmt, stripEscape
|
||||
from novelwriter.formats.tokenizer import HEADINGS, Tokenizer
|
||||
from novelwriter.formats.tokenizer import HEADING_BLOCKS, META_BLOCKS, Tokenizer
|
||||
from novelwriter.types import (
|
||||
QtAlignAbsolute, QtAlignCenter, QtAlignJustify, QtAlignLeft, QtAlignRight,
|
||||
QtKeepAnchor, QtMoveAnchor, QtPageBreakAfter, QtPageBreakAuto,
|
||||
@@ -214,7 +214,7 @@ class ToQTextDocument(Tokenizer):
|
||||
for tType, tMeta, tText, tFormat, tStyle in self._blocks:
|
||||
|
||||
bFmt = QTextBlockFormat(self._blockFmt)
|
||||
if tType in (BlockTyp.COMMENT, BlockTyp.KEYWORD):
|
||||
if tType in META_BLOCKS:
|
||||
bFmt.setTopMargin(self._mMeta[0])
|
||||
bFmt.setBottomMargin(self._mMeta[1])
|
||||
elif tType == BlockTyp.SEP:
|
||||
@@ -248,17 +248,21 @@ class ToQTextDocument(Tokenizer):
|
||||
if tStyle & BlockFmt.IND_T:
|
||||
bFmt.setTextIndent(self._tIndent)
|
||||
|
||||
if tType in (BlockTyp.TEXT, BlockTyp.COMMENT, BlockTyp.KEYWORD):
|
||||
if tType == BlockTyp.TEXT:
|
||||
newBlock(cursor, bFmt)
|
||||
self._insertFragments(tText, tFormat, cursor, self._charFmt)
|
||||
|
||||
elif tType in HEADINGS:
|
||||
elif tType in HEADING_BLOCKS:
|
||||
bFmt, cFmt = self._genHeadStyle(tType, tMeta, bFmt)
|
||||
for tPart in tText.split("\n"):
|
||||
newBlock(cursor, bFmt)
|
||||
cursor.insertText(tPart, cFmt)
|
||||
bFmt.setPageBreakPolicy(QtPageBreakAuto)
|
||||
|
||||
elif tType in META_BLOCKS:
|
||||
newBlock(cursor, bFmt)
|
||||
self._insertFragments(tText, tFormat, cursor, self._charFmt)
|
||||
|
||||
elif tType == BlockTyp.SEP:
|
||||
newBlock(cursor, bFmt)
|
||||
cursor.insertText(tText, self._charFmt)
|
||||
|
||||
Reference in New Issue
Block a user