By lipsum.com
“Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit…”
“There is no one who loves pain itself, who seeks after it and wants to have it, simply because it is pain…”
-Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of “de Finibus Bonorum et Malorum” (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, “Lorem ipsum dolor sit amet..”, comes from a line in section 1.10.32.
-The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from “de Finibus Bonorum et Malorum” by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
+Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of “de Finibus Bonorum et Malorum” (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, “Lorem ipsum dolor sit amet..”, comes from a line in section 1.10.32.
+The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from “de Finibus Bonorum et Malorum” by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
“Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit…”
“There is no one who loves pain itself, who seeks after it and wants to have it, simply because it is pain…”
Comment: Exctracted from the lipsum.com website.
-Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of “de Finibus Bonorum et Malorum” (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, “Lorem ipsum dolor sit amet..”, comes from a line in section 1.10.32.
-The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from “de Finibus Bonorum et Malorum” by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
+Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of “de Finibus Bonorum et Malorum” (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, “Lorem ipsum dolor sit amet..”, comes from a line in section 1.10.32.
+The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from “de Finibus Bonorum et Malorum” by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
Synopsis: Explanation from the lipsum.com website.
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
diff --git a/tests/reference/guiBuild_Tool_Step3_Lorem_Ipsum.fodt b/tests/reference/guiBuild_Tool_Step3_Lorem_Ipsum.fodt index 3411a1e1..5b2251d7 100644 --- a/tests/reference/guiBuild_Tool_Step3_Lorem_Ipsum.fodt +++ b/tests/reference/guiBuild_Tool_Step3_Lorem_Ipsum.fodt @@ -66,24 +66,21 @@“Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit…”
“There is no one who loves pain itself, who seeks after it and wants to have it, simply because it is pain…”
Comment: Exctracted from the lipsum.com website.
-Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of “de Finibus Bonorum et Malorum” (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, “Lorem ipsum dolor sit amet..”, comes from a line in section 1.10.32.
-The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from “de Finibus Bonorum et Malorum” by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
+Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of “de Finibus Bonorum et Malorum” (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, “Lorem ipsum dolor sit amet..”, comes from a line in section 1.10.32.
+The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from “de Finibus Bonorum et Malorum” by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
Synopsis: Explanation from the lipsum.com website.
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
diff --git a/tests/test_core/test_core_index.py b/tests/test_core/test_core_index.py index 87ce2b02..0fdde671 100644 --- a/tests/test_core/test_core_index.py +++ b/tests/test_core/test_core_index.py @@ -1177,29 +1177,59 @@ def testCoreIndex_CheckTextCounts(dummyGUI): def testCoreIndex_CountWords(): """Test the word counter and the exclusion filers. """ - testText = ( + # Non-Text + assert countWords(None) == (0, 0, 0) + assert countWords(1234) == (0, 0, 0) + + # General Text + cC, wC, pC = countWords(( "# Heading One\n" "## Heading Two\n" "### Heading Three\n" - "#### Heading Four\n" - "\n" - "@tag: value\n" - "\n" - "% A comment that should n ot be counted.\n" - "\n" - "The first paragraph.\n" - "\n" - "The second paragraph.\n" - "\n" - "\n" - "The third paragraph.\n" - "\n" + "#### Heading Four\n\n" + "@tag: value\n\n" + "% A comment that should not be counted.\n\n" + "The first paragraph.\n\n" + "The second paragraph.\n\n\n" + "The third paragraph.\n\n" "Dashes\u2013and even longer\u2014dashes." - ) - cC, wC, pC = countWords(testText) - + )) assert cC == 138 assert wC == 22 assert pC == 4 + # Text Alignment + cC, wC, pC = countWords(( + "# Title\n\n" + "Left aligned<<\n\n" + "Left aligned <<\n\n" + "Right indent<\n\n" + "Right indent <\n\n" + )) + assert cC == 53 + assert wC == 9 + assert pC == 4 + + cC, wC, pC = countWords(( + "# Title\n\n" + ">>Right aligned\n\n" + ">> Right aligned\n\n" + ">Left indent\n\n" + "> Left indent\n\n" + )) + assert cC == 53 + assert wC == 9 + assert pC == 4 + + cC, wC, pC = countWords(( + "# Title\n\n" + ">>Centre aligned<<\n\n" + ">> Centre aligned <<\n\n" + ">Double indent<\n\n" + "> Double indent <\n\n" + )) + assert cC == 59 + assert wC == 9 + assert pC == 4 + # END Test testCoreIndex_CountWords diff --git a/tests/test_core/test_core_tokenizer.py b/tests/test_core/test_core_tokenizer.py index 0f4d9f85..79a18b79 100644 --- a/tests/test_core/test_core_tokenizer.py +++ b/tests/test_core/test_core_tokenizer.py @@ -406,6 +406,92 @@ def testCoreToken_Tokenize(dummyGUI): "Some **nested bold and _italic_ and ~~strikethrough~~ text** here\n\n" ) + # Alignment and Indentation + dblIndent = Tokenizer.A_IND_L | Tokenizer.A_IND_R + rIndAlign = Tokenizer.A_RIGHT | Tokenizer.A_IND_R + theToken.theText = ( + "Some regular text\n\n" + "Some left-aligned text <<\n\n" + ">> Some right-aligned text\n\n" + ">> Some centered text <<\n\n" + "> Left-indented block\n\n" + "Right-indented block <\n\n" + "> Double-indented block <\n\n" + ">> Right-indent, right-aligned <\n\n" + ) + theToken.tokenizeText() + assert theToken.theTokens == [ + (Tokenizer.T_TEXT, 1, "Some regular text", [], Tokenizer.A_NONE), + (Tokenizer.T_EMPTY, 2, "", None, Tokenizer.A_NONE), + (Tokenizer.T_TEXT, 3, "Some left-aligned text", [], Tokenizer.A_LEFT), + (Tokenizer.T_EMPTY, 4, "", None, Tokenizer.A_NONE), + (Tokenizer.T_TEXT, 5, "Some right-aligned text", [], Tokenizer.A_RIGHT), + (Tokenizer.T_EMPTY, 6, "", None, Tokenizer.A_NONE), + (Tokenizer.T_TEXT, 7, "Some centered text", [], Tokenizer.A_CENTRE), + (Tokenizer.T_EMPTY, 8, "", None, Tokenizer.A_NONE), + (Tokenizer.T_TEXT, 9, "Left-indented block", [], Tokenizer.A_IND_L), + (Tokenizer.T_EMPTY, 10, "", None, Tokenizer.A_NONE), + (Tokenizer.T_TEXT, 11, "Right-indented block", [], Tokenizer.A_IND_R), + (Tokenizer.T_EMPTY, 12, "", None, Tokenizer.A_NONE), + (Tokenizer.T_TEXT, 13, "Double-indented block", [], dblIndent), + (Tokenizer.T_EMPTY, 14, "", None, Tokenizer.A_NONE), + (Tokenizer.T_TEXT, 15, "Right-indent, right-aligned", [], rIndAlign), + (Tokenizer.T_EMPTY, 16, "", None, Tokenizer.A_NONE), + (Tokenizer.T_EMPTY, 16, "", None, Tokenizer.A_NONE), + ] + assert theToken.theMarkdown[-1] == ( + "Some regular text\n\n" + "Some left-aligned text\n\n" + "Some right-aligned text\n\n" + "Some centered text\n\n" + "Left-indented block\n\n" + "Right-indented block\n\n" + "Double-indented block\n\n" + "Right-indent, right-aligned\n\n\n" + ) + + # Alignment w/HTML Codes + theToken.theText = ( + "Some regular text\n\n" + "Some left-aligned text <<\n\n" + ">> Some right-aligned text\n\n" + ">> Some centered text <<\n\n" + "> Left-indented block\n\n" + "Right-indented block <\n\n" + "> Double-indented block <\n\n" + ">> Right-indent, right-aligned <\n\n" + ) + theToken.tokenizeText() + assert theToken.theTokens == [ + (Tokenizer.T_TEXT, 1, "Some regular text", [], Tokenizer.A_NONE), + (Tokenizer.T_EMPTY, 2, "", None, Tokenizer.A_NONE), + (Tokenizer.T_TEXT, 3, "Some left-aligned text", [], Tokenizer.A_LEFT), + (Tokenizer.T_EMPTY, 4, "", None, Tokenizer.A_NONE), + (Tokenizer.T_TEXT, 5, "Some right-aligned text", [], Tokenizer.A_RIGHT), + (Tokenizer.T_EMPTY, 6, "", None, Tokenizer.A_NONE), + (Tokenizer.T_TEXT, 7, "Some centered text", [], Tokenizer.A_CENTRE), + (Tokenizer.T_EMPTY, 8, "", None, Tokenizer.A_NONE), + (Tokenizer.T_TEXT, 9, "Left-indented block", [], Tokenizer.A_IND_L), + (Tokenizer.T_EMPTY, 10, "", None, Tokenizer.A_NONE), + (Tokenizer.T_TEXT, 11, "Right-indented block", [], Tokenizer.A_IND_R), + (Tokenizer.T_EMPTY, 12, "", None, Tokenizer.A_NONE), + (Tokenizer.T_TEXT, 13, "Double-indented block", [], dblIndent), + (Tokenizer.T_EMPTY, 14, "", None, Tokenizer.A_NONE), + (Tokenizer.T_TEXT, 15, "Right-indent, right-aligned", [], rIndAlign), + (Tokenizer.T_EMPTY, 16, "", None, Tokenizer.A_NONE), + (Tokenizer.T_EMPTY, 16, "", None, Tokenizer.A_NONE), + ] + assert theToken.theMarkdown[-1] == ( + "Some regular text\n\n" + "Some left-aligned text\n\n" + "Some right-aligned text\n\n" + "Some centered text\n\n" + "Left-indented block\n\n" + "Right-indented block\n\n" + "Double-indented block\n\n" + "Right-indent, right-aligned\n\n\n" + ) + # END Test testCoreToken_Tokenize @pytest.mark.core @@ -664,9 +750,10 @@ def testCoreToken_Headers(dummyGUI): # H1: Title theToken.theText = "# Novel Title\n" - theToken.tokenizeText() + theToken.setTitleFormat(r"T: %title%") theToken.isTitle = True theToken.isPart = False + theToken.tokenizeText() theToken.doHeaders() assert theToken.theTokens == [ (Tokenizer.T_TITLE, 1, "Novel Title", None, Tokenizer.A_PBB_AUT | Tokenizer.A_CENTRE), @@ -676,9 +763,9 @@ def testCoreToken_Headers(dummyGUI): # H1: Partition theToken.theText = "# Partition Title\n" theToken.setTitleFormat(r"T: %title%") - theToken.tokenizeText() theToken.isTitle = False theToken.isPart = True + theToken.tokenizeText() theToken.doHeaders() assert theToken.theTokens == [ (Tokenizer.T_HEAD1, 1, "Partition Title", None, Tokenizer.A_PBB | Tokenizer.A_CENTRE), @@ -699,10 +786,10 @@ def testCoreToken_Headers(dummyGUI): theToken.tokenizeText() theToken.doHeaders() assert theToken.theTokens == [ - (Tokenizer.T_TEXT, 1, "Page text", [], Tokenizer.A_PBB | Tokenizer.A_LEFT), - (Tokenizer.T_EMPTY, 2, "", None, Tokenizer.A_LEFT), - (Tokenizer.T_TEXT, 3, "More text", [], Tokenizer.A_LEFT), - (Tokenizer.T_EMPTY, 3, "", None, Tokenizer.A_LEFT), + (Tokenizer.T_TEXT, 1, "Page text", [], Tokenizer.A_PBB), + (Tokenizer.T_EMPTY, 2, "", None, Tokenizer.A_NONE), + (Tokenizer.T_TEXT, 3, "More text", [], Tokenizer.A_NONE), + (Tokenizer.T_EMPTY, 3, "", None, Tokenizer.A_NONE), ] # END Test testCoreToken_Headers diff --git a/tests/test_gui/test_gui_mainmenu.py b/tests/test_gui/test_gui_mainmenu.py index 3da0d48c..752e596e 100644 --- a/tests/test_gui/test_gui_mainmenu.py +++ b/tests/test_gui/test_gui_mainmenu.py @@ -40,19 +40,19 @@ def testGuiMenu_EditFormat(qtbot, monkeypatch, nwGUI, nwLipsum): """Test the main menu Edit and Format entries. """ # Block message box - monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes) - monkeypatch.setattr(GuiDocEditor, "hasFocus", lambda *args: True) + monkeypatch.setattr(QMessageBox, "question", lambda *a: QMessageBox.Yes) + monkeypatch.setattr(GuiDocEditor, "hasFocus", lambda *a: True) # Test Document Action with No Project - assert not nwGUI.docEditor.docAction(nwDocAction.COPY) + assert nwGUI.docEditor.docAction(nwDocAction.COPY) is False nwGUI.theProject.projTree.setSeed(42) - assert nwGUI.openProject(nwLipsum) + assert nwGUI.openProject(nwLipsum) is True qtbot.wait(stepDelay) # Split By Chapter - assert nwGUI.openDocument("4c4f28287af27") - assert nwGUI.docEditor.setCursorPosition(30) + assert nwGUI.openDocument("4c4f28287af27") is True + assert nwGUI.docEditor.setCursorPosition(30) is True cleanText = nwGUI.docEditor.getText()[27:74] @@ -114,30 +114,44 @@ def testGuiMenu_EditFormat(qtbot, monkeypatch, nwGUI, nwLipsum): # Block Formats assert nwGUI.docEditor.setCursorPosition(30) + + ## Header 1 nwGUI.mainMenu.aFmtHead1.activate(QAction.Trigger) fmtStr = "# Pellentesque nec erat ut nulla posuere commodo." assert nwGUI.docEditor.getText()[27:76] == fmtStr qtbot.wait(stepDelay) + + ## Header 2 nwGUI.mainMenu.aFmtHead2.activate(QAction.Trigger) fmtStr = "## Pellentesque nec erat ut nulla posuere commodo." assert nwGUI.docEditor.getText()[27:77] == fmtStr qtbot.wait(stepDelay) + + ## Header 3 nwGUI.mainMenu.aFmtHead3.activate(QAction.Trigger) fmtStr = "### Pellentesque nec erat ut nulla posuere commodo." assert nwGUI.docEditor.getText()[27:78] == fmtStr qtbot.wait(stepDelay) + + ## Header 4 nwGUI.mainMenu.aFmtHead4.activate(QAction.Trigger) fmtStr = "#### Pellentesque nec erat ut nulla posuere commodo." assert nwGUI.docEditor.getText()[27:79] == fmtStr qtbot.wait(stepDelay) + + ## Clear Format nwGUI.mainMenu.aFmtNoFormat.activate(QAction.Trigger) assert nwGUI.docEditor.getText()[27:74] == cleanText qtbot.wait(stepDelay) + + ## Comment On nwGUI.mainMenu.aFmtComment.activate(QAction.Trigger) fmtStr = "% Pellentesque nec erat ut nulla posuere commodo." assert nwGUI.docEditor.getText()[27:76] == fmtStr qtbot.wait(stepDelay) - nwGUI.mainMenu.aFmtNoFormat.activate(QAction.Trigger) + + ## Comment Off + nwGUI.mainMenu.aFmtComment.activate(QAction.Trigger) assert nwGUI.docEditor.getText()[27:74] == cleanText qtbot.wait(stepDelay) @@ -213,6 +227,48 @@ def testGuiMenu_EditFormat(qtbot, monkeypatch, nwGUI, nwLipsum): nwGUI.docEditor.clear() assert nwGUI.docEditor.isEmpty() + # Alignment & Indent + cleanText = "A single, short paragraph.\n\n" + nwGUI.docEditor.setText(cleanText) + assert nwGUI.docEditor.setCursorPosition(0) + + ## Left Align + nwGUI.mainMenu.aFmtAlignLeft.activate(QAction.Trigger) + fmtStr = "A single, short paragraph. <<" + assert nwGUI.docEditor.getText()[:29] == fmtStr + qtbot.wait(stepDelay) + + ## Right Align + nwGUI.mainMenu.aFmtAlignRight.activate(QAction.Trigger) + fmtStr = ">> A single, short paragraph." + assert nwGUI.docEditor.getText()[:29] == fmtStr + qtbot.wait(stepDelay) + + ## Centre Align + nwGUI.mainMenu.aFmtAlignCentre.activate(QAction.Trigger) + fmtStr = ">> A single, short paragraph. <<" + assert nwGUI.docEditor.getText()[:32] == fmtStr + qtbot.wait(stepDelay) + + ## Left Indent + nwGUI.mainMenu.aFmtIndentLeft.activate(QAction.Trigger) + fmtStr = "> A single, short paragraph." + assert nwGUI.docEditor.getText()[:28] == fmtStr + qtbot.wait(stepDelay) + + ## Right Indent + nwGUI.mainMenu.aFmtIndentRight.activate(QAction.Trigger) + fmtStr = "> A single, short paragraph. <" + assert nwGUI.docEditor.getText()[:30] == fmtStr + qtbot.wait(stepDelay) + + ## No Format + nwGUI.mainMenu.aFmtNoFormat.activate(QAction.Trigger) + assert nwGUI.docEditor.getText()[:30] == cleanText + qtbot.wait(stepDelay) + + # Other Checks + # Replace Quotes nwGUI.docEditor.setText(( "### New Text\n\n"