From f6b7a35c811b417842924708e329ee11832a808f Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Wed, 13 Jan 2021 23:52:09 +0100 Subject: [PATCH] Add some more unicode constants and rename thin non-breaking space variable --- nw/common.py | 6 +++--- nw/constants/constants.py | 10 +++++++--- nw/core/tohtml.py | 2 +- nw/gui/doceditor.py | 2 +- tests/test_gui_mainmenu.py | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/nw/common.py b/nw/common.py index f0e5900e..922c7b6f 100644 --- a/nw/common.py +++ b/nw/common.py @@ -152,11 +152,11 @@ def formatInt(theInt): theVal /= 1000.0 if theVal < 1000.0: if theVal < 10.0: - return f"{theVal:4.2f}{nwUnicode.U_THNSP}{pF}" + return f"{theVal:4.2f}{nwUnicode.U_THSP}{pF}" elif theVal < 100.0: - return f"{theVal:4.1f}{nwUnicode.U_THNSP}{pF}" + return f"{theVal:4.1f}{nwUnicode.U_THSP}{pF}" else: - return f"{theVal:3.0f}{nwUnicode.U_THNSP}{pF}" + return f"{theVal:3.0f}{nwUnicode.U_THSP}{pF}" return str(theInt) diff --git a/nw/constants/constants.py b/nw/constants/constants.py index a39bb8e1..8efbec6f 100644 --- a/nw/constants/constants.py +++ b/nw/constants/constants.py @@ -241,7 +241,7 @@ class nwQuotes(): # END Class nwQuotes class nwUnicode: - """Supported unicode character constants and translation maps for HTML. + """Supported unicode character constants and their HTML equivalents. """ # Unicode Constants @@ -276,8 +276,10 @@ class nwUnicode: ## Spaces and Lines U_NBSP = "\u00a0" # Non-breaking space - U_THNSP = "\u2009" # Thin space + U_THSP = "\u2009" # Thin space U_THNBSP = "\u202f" # Thin non-breaking space + U_ENSP = "\u2002" # Short (en) space + U_EMSP = "\u2003" # Long (em) space U_LSEP = "\u2028" # Line separator U_PSEP = "\u2029" # Paragraph separator @@ -328,8 +330,10 @@ class nwUnicode: ## Spaces H_NBSP = " " - H_THNSP = " " + H_THSP = " " H_THNBSP = " " + H_ENSP = " " + H_EMSP = " " ## Symbols H_CHECK = "✔" diff --git a/nw/core/tohtml.py b/nw/core/tohtml.py index 55da29d1..41807586 100644 --- a/nw/core/tohtml.py +++ b/nw/core/tohtml.py @@ -53,7 +53,7 @@ class ToHtml(Tokenizer): nwUnicode.U_EMDASH : nwUnicode.H_EMDASH, nwUnicode.U_HELLIP : nwUnicode.H_HELLIP, nwUnicode.U_NBSP : nwUnicode.H_NBSP, - nwUnicode.U_THNSP : nwUnicode.H_THNSP, + nwUnicode.U_THSP : nwUnicode.H_THSP, nwUnicode.U_THNBSP : nwUnicode.H_THNBSP, nwUnicode.U_MAPOSS : nwUnicode.H_RSQUO, } diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 3421276c..e155c9fd 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -734,7 +734,7 @@ class GuiDocEditor(QTextEdit): elif theInsert == nwDocInsert.NB_SPACE: theText = nwUnicode.U_NBSP elif theInsert == nwDocInsert.THIN_SPACE: - theText = nwUnicode.U_THNSP + theText = nwUnicode.U_THSP elif theInsert == nwDocInsert.THIN_NB_SPACE: theText = nwUnicode.U_THNBSP elif theInsert == nwDocInsert.SHORT_DASH: diff --git a/tests/test_gui_mainmenu.py b/tests/test_gui_mainmenu.py index 33408505..86e3b749 100644 --- a/tests/test_gui_mainmenu.py +++ b/tests/test_gui_mainmenu.py @@ -410,7 +410,7 @@ def testGuiMenu_Insert(qtbot, monkeypatch, nwGUI, fncDir, fncProj): nwGUI.docEditor.clear() nwGUI.mainMenu.aInsThinSpace.activate(QAction.Trigger) - assert nwGUI.docEditor.getText() == nwUnicode.U_THNSP + assert nwGUI.docEditor.getText() == nwUnicode.U_THSP nwGUI.docEditor.clear() nwGUI.mainMenu.aInsThinNBSpace.activate(QAction.Trigger)