Fix bug in splitting on alt scene headings (#2234)
This commit is contained in:
+2
-1
@@ -20,8 +20,9 @@ i18n/*.qph
|
|||||||
|
|
||||||
# Documentation
|
# Documentation
|
||||||
/docs/build/
|
/docs/build/
|
||||||
|
/docs/source/locales/**/*.mo
|
||||||
/novelwriter/assets/help/
|
/novelwriter/assets/help/
|
||||||
/novelwriter/assets/manual.pdf
|
/novelwriter/assets/manual*.pdf
|
||||||
*.qch
|
*.qch
|
||||||
*.qhc
|
*.qhc
|
||||||
.~lock.*
|
.~lock.*
|
||||||
|
|||||||
@@ -71,10 +71,10 @@ class GuiDocSplit(NDialog):
|
|||||||
vSp = CONFIG.pxInt(8)
|
vSp = CONFIG.pxInt(8)
|
||||||
bSp = CONFIG.pxInt(12)
|
bSp = CONFIG.pxInt(12)
|
||||||
|
|
||||||
pOptions = SHARED.project.options
|
options = SHARED.project.options
|
||||||
spLevel = pOptions.getInt("GuiDocSplit", "spLevel", 3)
|
spLevel = options.getInt("GuiDocSplit", "spLevel", 3)
|
||||||
intoFolder = pOptions.getBool("GuiDocSplit", "intoFolder", True)
|
intoFolder = options.getBool("GuiDocSplit", "intoFolder", True)
|
||||||
docHierarchy = pOptions.getBool("GuiDocSplit", "docHierarchy", True)
|
docHierarchy = options.getBool("GuiDocSplit", "docHierarchy", True)
|
||||||
|
|
||||||
# Heading Selection
|
# Heading Selection
|
||||||
self.listBox = QListWidget(self)
|
self.listBox = QListWidget(self)
|
||||||
@@ -171,10 +171,10 @@ class GuiDocSplit(NDialog):
|
|||||||
self._data["moveToTrash"] = moveToTrash
|
self._data["moveToTrash"] = moveToTrash
|
||||||
|
|
||||||
logger.debug("Saving State: GuiDocSplit")
|
logger.debug("Saving State: GuiDocSplit")
|
||||||
pOptions = SHARED.project.options
|
options = SHARED.project.options
|
||||||
pOptions.setValue("GuiDocSplit", "spLevel", spLevel)
|
options.setValue("GuiDocSplit", "spLevel", spLevel)
|
||||||
pOptions.setValue("GuiDocSplit", "intoFolder", intoFolder)
|
options.setValue("GuiDocSplit", "intoFolder", intoFolder)
|
||||||
pOptions.setValue("GuiDocSplit", "docHierarchy", docHierarchy)
|
options.setValue("GuiDocSplit", "docHierarchy", docHierarchy)
|
||||||
|
|
||||||
return self._data, self._text
|
return self._data, self._text
|
||||||
|
|
||||||
@@ -218,42 +218,46 @@ class GuiDocSplit(NDialog):
|
|||||||
if not self._text:
|
if not self._text:
|
||||||
self._text = SHARED.project.storage.getDocumentText(sHandle).splitlines()
|
self._text = SHARED.project.storage.getDocumentText(sHandle).splitlines()
|
||||||
|
|
||||||
for lineNo, aLine in enumerate(self._text):
|
for i, line in enumerate(self._text):
|
||||||
|
|
||||||
onLine = -1
|
pos = -1
|
||||||
hLevel = 0
|
level = 0
|
||||||
hLabel = aLine.strip()
|
label = line.strip()
|
||||||
if aLine.startswith("# ") and spLevel >= 1:
|
if line.startswith("# ") and spLevel >= 1:
|
||||||
onLine = lineNo
|
pos = i
|
||||||
hLevel = 1
|
level = 1
|
||||||
hLabel = aLine[2:].strip()
|
label = line[2:].strip()
|
||||||
elif aLine.startswith("## ") and spLevel >= 2:
|
elif line.startswith("## ") and spLevel >= 2:
|
||||||
onLine = lineNo
|
pos = i
|
||||||
hLevel = 2
|
level = 2
|
||||||
hLabel = aLine[3:].strip()
|
label = line[3:].strip()
|
||||||
elif aLine.startswith("### ") and spLevel >= 3:
|
elif line.startswith("### ") and spLevel >= 3:
|
||||||
onLine = lineNo
|
pos = i
|
||||||
hLevel = 3
|
level = 3
|
||||||
hLabel = aLine[4:].strip()
|
label = line[4:].strip()
|
||||||
elif aLine.startswith("#### ") and spLevel >= 4:
|
elif line.startswith("#### ") and spLevel >= 4:
|
||||||
onLine = lineNo
|
pos = i
|
||||||
hLevel = 4
|
level = 4
|
||||||
hLabel = aLine[5:].strip()
|
label = line[5:].strip()
|
||||||
elif aLine.startswith("#! ") and spLevel >= 1:
|
elif line.startswith("#! ") and spLevel >= 1:
|
||||||
onLine = lineNo
|
pos = i
|
||||||
hLevel = 1
|
level = 1
|
||||||
hLabel = aLine[3:].strip()
|
label = line[3:].strip()
|
||||||
elif aLine.startswith("##! ") and spLevel >= 2:
|
elif line.startswith("##! ") and spLevel >= 2:
|
||||||
onLine = lineNo
|
pos = i
|
||||||
hLevel = 2
|
level = 2
|
||||||
hLabel = aLine[4:].strip()
|
label = line[4:].strip()
|
||||||
|
elif line.startswith("###! ") and spLevel >= 3:
|
||||||
|
pos = i
|
||||||
|
level = 3
|
||||||
|
label = line[5:].strip()
|
||||||
|
|
||||||
if onLine >= 0 and hLevel > 0:
|
if pos >= 0 and level > 0:
|
||||||
newItem = QListWidgetItem()
|
trItem = QListWidgetItem()
|
||||||
newItem.setText(aLine.strip())
|
trItem.setText(line.strip())
|
||||||
newItem.setData(self.LINE_ROLE, onLine)
|
trItem.setData(self.LINE_ROLE, pos)
|
||||||
newItem.setData(self.LEVEL_ROLE, hLevel)
|
trItem.setData(self.LEVEL_ROLE, level)
|
||||||
newItem.setData(self.LABEL_ROLE, hLabel)
|
trItem.setData(self.LABEL_ROLE, label)
|
||||||
self.listBox.addItem(newItem)
|
self.listBox.addItem(trItem)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -43,10 +43,10 @@ def testDlgSplit_Main(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
|||||||
"##! Prologue\n\nText\n\n"
|
"##! Prologue\n\nText\n\n"
|
||||||
"## Chapter One\n\nText\n\n"
|
"## Chapter One\n\nText\n\n"
|
||||||
"### Scene One\n\nText\n\n"
|
"### Scene One\n\nText\n\n"
|
||||||
"### Scene Two\n\nText\n\n"
|
"###! Scene Two\n\nText\n\n"
|
||||||
"## Chapter Two\n\nText\n\n"
|
"## Chapter Two\n\nText\n\n"
|
||||||
"### Scene Three\n\nText\n\n"
|
"### Scene Three\n\nText\n\n"
|
||||||
"### Scene Four\n\nText\n\n"
|
"###! Scene Four\n\nText\n\n"
|
||||||
"#! New Title\n\nText\n\n"
|
"#! New Title\n\nText\n\n"
|
||||||
"## New Chapter\n\nText\n\n"
|
"## New Chapter\n\nText\n\n"
|
||||||
"### New Scene\n\nText\n\n"
|
"### New Scene\n\nText\n\n"
|
||||||
|
|||||||
@@ -858,10 +858,10 @@ def testGuiProjTree_SplitDocument(qtbot, monkeypatch, nwGUI, projPath, mockRnd,
|
|||||||
"##! Prologue\n\nText\n\n"
|
"##! Prologue\n\nText\n\n"
|
||||||
"## Chapter One\n\nText\n\n"
|
"## Chapter One\n\nText\n\n"
|
||||||
"### Scene One\n\nText\n\n"
|
"### Scene One\n\nText\n\n"
|
||||||
"### Scene Two\n\nText\n\n"
|
"###! Scene Two\n\nText\n\n"
|
||||||
"## Chapter Two\n\nText\n\n"
|
"## Chapter Two\n\nText\n\n"
|
||||||
"### Scene Three\n\nText\n\n"
|
"### Scene Three\n\nText\n\n"
|
||||||
"### Scene Four\n\nText\n\n"
|
"###! Scene Four\n\nText\n\n"
|
||||||
"#! New Title\n\nText\n\n"
|
"#! New Title\n\nText\n\n"
|
||||||
"## New Chapter\n\nText\n\n"
|
"## New Chapter\n\nText\n\n"
|
||||||
"### New Scene\n\nText\n\n"
|
"### New Scene\n\nText\n\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user