Testing out going with markdown instead of html.

This commit is contained in:
Veronica K. B. Olsen
2019-04-06 10:25:49 +02:00
parent ec49adadcd
commit 7126e59bc7
7 changed files with 33 additions and 41 deletions
+3 -3
View File
@@ -58,7 +58,7 @@ class GuiDocEditor(QWidget):
# self.guiEditor.setCurrentFont(self.docFont)
# self.guiEditor.setContentsMargins(20,20,20,20)
self.guiEditor.setStyleSheet(
"QTextEdit {background-color: #f0f0f0;};"
"QTextEdit {background-color: #ffffff;};"
)
theDoc = self.guiEditor.document()
theDoc.setDefaultFont(QFont("Source Sans Pro",13))
@@ -84,11 +84,11 @@ class GuiDocEditor(QWidget):
return
def setText(self, docHtml):
self.guiEditor.setHtml(docHtml)
self.guiEditor.setPlainText(docHtml)
return True
def getText(self):
theText = self.guiEditor.toHtml()
theText = self.guiEditor.toPlainText()
return theText
def _buildTabToolBar(self):
+5 -2
View File
@@ -92,7 +92,8 @@ class GuiMain(QMainWindow):
dlgOpt = QFileDialog.Options()
dlgOpt |= QFileDialog.DontUseNativeDialog
projPath, _ = QFileDialog.getOpenFileName(
self,"Open novelWriter Project","","novelWriter Project File (nwProject.nwx);;All Files (*)", options=dlgOpt)
self,"Open novelWriter Project","","novelWriter Project File (nwProject.nwx);;All Files (*)", options=dlgOpt
)
if projPath:
self.theProject.openProject(projPath)
self.treeView.buildTree()
@@ -106,7 +107,8 @@ class GuiMain(QMainWindow):
dlgOpt = QFileDialog.Options()
dlgOpt |= QFileDialog.DontUseNativeDialog
projPath, _ = QFileDialog.getSaveFileName(
self,"Save novelWriter Project","","novelWriter Project File (nwProject.nwx);;All Files (*)", options=dlgOpt)
self,"Save novelWriter Project","","novelWriter Project File (nwProject.nwx);;All Files (*)", options=dlgOpt
)
if projPath:
self.theProject.setProjectPath(projPath)
else:
@@ -160,6 +162,7 @@ class GuiMain(QMainWindow):
logger.info("Exiting %s" % nw.__package__)
self.mainConf.setWinSize(self.width(), self.height())
self.mainConf.setTreeColWidths(self.treeView.getColumnSizes())
print(self.treePane.width())
self.mainConf.saveConfig()
return
+13 -10
View File
@@ -20,6 +20,8 @@ logger = logging.getLogger(__name__)
class NWDoc():
FILE_MN = "main.md"
def __init__(self, theProject):
self.mainConf = nw.CONFIG
@@ -30,7 +32,7 @@ class NWDoc():
def openDocument(self, tHandle):
self.docHandle = tHandle
docDir, docFile = self._assemblePath("main.htm")
docDir, docFile = self._assemblePath(self.FILE_MN)
logger.debug("Opening document %s" % path.join(docDir,docFile))
dataDir = path.join(self.theProject.projPath, docDir)
docPath = path.join(dataDir, docFile)
@@ -44,21 +46,22 @@ class NWDoc():
def saveDocument(self, docHtml):
if self.docHandle is None: return False
docDir, docFile = self._assemblePath("main.htm")
docDir, docFile = self._assemblePath(self.FILE_MN)
logger.debug("Saving document %s" % path.join(docDir,docFile))
dataDir = path.join(self.theProject.projPath, docDir)
docPath = path.join(dataDir, docFile)
if not path.isdir(dataDir):
mkdir(dataDir)
logger.debug("Created folder %s" % dataDir)
with open(docPath,mode="wb") as outFile:
docData = html.fromstring(docHtml)
outFile.write(html.tostring(
docData,
pretty_print = True,
encoding = "utf-8",
method = "html",
))
with open(docPath,mode="w") as outFile:
outFile.write(docHtml)
# docData = html.fromstring(docHtml)
# outFile.write(html.tostring(
# docData,
# pretty_print = True,
# encoding = "utf-8",
# method = "html",
# ))
return True
def _assemblePath(self, docExt):