From 1e9b239803ad9fc4ec6f5c0b17056a33937dd872 Mon Sep 17 00:00:00 2001 From: Olivier Keshavjee Date: Thu, 2 Jul 2015 10:19:52 +0200 Subject: [PATCH] Better formatting in notes and cheat sheet --- src/models/references.py | 9 ++++++++- src/ui/editors/textFormat.py | 2 +- src/ui/views/textEditView.py | 4 +--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/models/references.py b/src/models/references.py index 3b9543c9..f55f4662 100644 --- a/src/models/references.py +++ b/src/models/references.py @@ -94,7 +94,7 @@ def infoForRef(ref): ls=ls.replace("\n", "
")) if ls else "", notes="

{notesTitle}
{notes}

".format( notesTitle=notesTitle, - notes=linkifyAllRefs(notes).replace("\n", "
")) if notes else "", + notes=linkifyAllRefs(basicT2TFormat(notes))) if notes else "", ) return text @@ -208,6 +208,13 @@ def refToLink(ref): def linkifyAllRefs(text): return re.sub(r"::(\w):(\d+?)::", lambda m: refToLink(m.group(0)), text) +def basicT2TFormat(text): + text = re.sub("\*\*(.*?)\*\*", "\\1", text) + text = re.sub("//(.*?)//", "\\1", text) + text = re.sub("__(.*?)__", "\\1", text) + text = text.replace("\n", "
") + return text + def tooltipForRef(ref): match = re.fullmatch("::(\w):(\d+?)::", ref) if match: diff --git a/src/ui/editors/textFormat.py b/src/ui/editors/textFormat.py index 6591c3d3..889bc96d 100644 --- a/src/ui/editors/textFormat.py +++ b/src/ui/editors/textFormat.py @@ -45,7 +45,7 @@ class textFormat(QWidget, Ui_textFormat): self.setVisible(False) return - if index.column() != Outline.text.value: + if index.column() not in [Outline.text.value, Outline.notes.value]: self.setVisible(False) return diff --git a/src/ui/views/textEditView.py b/src/ui/views/textEditView.py index 9b7fa685..9e3994f0 100644 --- a/src/ui/views/textEditView.py +++ b/src/ui/views/textEditView.py @@ -132,7 +132,7 @@ class textEditView(QTextEdit): self._textFormat = "text" return - if self._column != Outline.text.value: + if self._column not in [Outline.text.value, Outline.notes.value]: self._textFormat = "text" else: @@ -477,8 +477,6 @@ class textEditView(QTextEdit): def applyFormat(self, _format): - print(_format) - if self._textFormat == "html": if _format == "Clear":