Make preview mode in HTML build also usable by Manuscript tool
This commit is contained in:
@@ -170,6 +170,7 @@ class NWBuildDocument:
|
|||||||
makeObj = ToHtml(self._project)
|
makeObj = ToHtml(self._project)
|
||||||
filtered = self._setupBuild(makeObj)
|
filtered = self._setupBuild(makeObj)
|
||||||
|
|
||||||
|
makeObj.setPreview(self._preview)
|
||||||
for i, tHandle in enumerate(self._queue):
|
for i, tHandle in enumerate(self._queue):
|
||||||
self._error = None
|
self._error = None
|
||||||
if filtered.get(tHandle, (False, 0))[0]:
|
if filtered.get(tHandle, (False, 0))[0]:
|
||||||
|
|||||||
@@ -74,15 +74,9 @@ class ToHtml(Tokenizer):
|
|||||||
# Setters
|
# Setters
|
||||||
##
|
##
|
||||||
|
|
||||||
def setPreview(self, doComments: bool, doSynopsis: bool) -> None:
|
def setPreview(self, state: bool) -> None:
|
||||||
"""If we're using this class to generate markdown preview, we
|
"""Set to preview generator mode."""
|
||||||
need to make a few changes to formatting, which is managed by
|
self._genMode = self.M_PREVIEW if state else self.M_EXPORT
|
||||||
these flags.
|
|
||||||
"""
|
|
||||||
self._genMode = self.M_PREVIEW
|
|
||||||
self._doKeywords = True
|
|
||||||
self._doComments = doComments
|
|
||||||
self._doSynopsis = doSynopsis
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def setStyles(self, cssStyles: bool) -> None:
|
def setStyles(self, cssStyles: bool) -> None:
|
||||||
@@ -302,8 +296,7 @@ class ToHtml(Tokenizer):
|
|||||||
lines.append(tTemp)
|
lines.append(tTemp)
|
||||||
|
|
||||||
self._result = "".join(lines)
|
self._result = "".join(lines)
|
||||||
if self._genMode != self.M_PREVIEW:
|
self._fullHTML.append(self._result)
|
||||||
self._fullHTML.append(self._result)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -197,7 +197,10 @@ class GuiDocViewer(QTextBrowser):
|
|||||||
|
|
||||||
sPos = self.verticalScrollBar().value()
|
sPos = self.verticalScrollBar().value()
|
||||||
aDoc = ToHtml(SHARED.project)
|
aDoc = ToHtml(SHARED.project)
|
||||||
aDoc.setPreview(CONFIG.viewComments, CONFIG.viewSynopsis)
|
aDoc.setPreview(True)
|
||||||
|
aDoc.setKeywords(True)
|
||||||
|
aDoc.setComments(CONFIG.viewComments)
|
||||||
|
aDoc.setSynopsis(CONFIG.viewSynopsis)
|
||||||
aDoc.setLinkHeadings(True)
|
aDoc.setLinkHeadings(True)
|
||||||
|
|
||||||
# Be extra careful here to prevent crashes when first opening a
|
# Be extra careful here to prevent crashes when first opening a
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ def testCoreToHtml_ConvertParagraphs(mockGUI):
|
|||||||
# Preview Mode
|
# Preview Mode
|
||||||
# ============
|
# ============
|
||||||
|
|
||||||
html.setPreview(True, True)
|
html.setPreview(True)
|
||||||
|
|
||||||
# Text (HTML4)
|
# Text (HTML4)
|
||||||
html._text = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
html._text = "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n"
|
||||||
@@ -606,16 +606,6 @@ def testCoreToHtml_Methods(mockGUI):
|
|||||||
"<p>Text with <brackets> & short–dash, long—dash …</p>\n"
|
"<p>Text with <brackets> & short–dash, long—dash …</p>\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
# With Preview
|
|
||||||
html.setPreview(True, True)
|
|
||||||
html._text = docText
|
|
||||||
html.doPreProcessing()
|
|
||||||
html.tokenizeText()
|
|
||||||
html.doConvert()
|
|
||||||
assert html.allMarkdown[-1] == (
|
|
||||||
"Text with <brackets> & short–dash, long—dash …\n\n"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Result Size
|
# Result Size
|
||||||
assert html.getFullResultSize() == 147
|
assert html.getFullResultSize() == 147
|
||||||
|
|
||||||
@@ -669,7 +659,7 @@ def testCoreToHtml_Format(mockGUI):
|
|||||||
# Preview Mode
|
# Preview Mode
|
||||||
# ============
|
# ============
|
||||||
|
|
||||||
html.setPreview(True, True)
|
html.setPreview(True)
|
||||||
|
|
||||||
assert html._formatSynopsis("synopsis text", True) == (
|
assert html._formatSynopsis("synopsis text", True) == (
|
||||||
"<p class='comment'><span class='synopsis'>Synopsis:</span> synopsis text</p>\n"
|
"<p class='comment'><span class='synopsis'>Synopsis:</span> synopsis text</p>\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user