From c3edfd5d888ff55c517738f0752ae292da841682 Mon Sep 17 00:00:00 2001 From: Hayden Jackson Date: Fri, 5 May 2017 12:33:47 +1200 Subject: [PATCH 01/11] Bug fix to add all terms to the glossary. --- verto/processors/GlossaryLinkPattern.py | 3 ++- verto/tests/ConfigurationTest.py | 17 +++++++++------- verto/tests/GlossaryLinkTest.py | 27 +++++++++++++++++++------ 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/verto/processors/GlossaryLinkPattern.py b/verto/processors/GlossaryLinkPattern.py index b9b25b56..502a6327 100644 --- a/verto/processors/GlossaryLinkPattern.py +++ b/verto/processors/GlossaryLinkPattern.py @@ -51,9 +51,10 @@ def handleMatch(self, match): 'text': text } + glossary_reference = self.ext_glossary_terms[term] if reference is not None: identifier = self.unique_slugify('glossary-' + term) - self.ext_glossary_terms[term].append((reference, identifier)) + glossary_reference.append((reference, identifier)) context['id'] = identifier html_string = self.template.render(context) diff --git a/verto/tests/ConfigurationTest.py b/verto/tests/ConfigurationTest.py index 8d26a457..f4405d2f 100644 --- a/verto/tests/ConfigurationTest.py +++ b/verto/tests/ConfigurationTest.py @@ -64,7 +64,9 @@ def test_multiple_calls(self): children=() ), ), - required_glossary_terms=defaultdict(list) + required_glossary_terms={ + 'algorithm': [] + } ) ), ('some_processors.md', @@ -116,6 +118,7 @@ def test_multiple_calls(self): children=(), ),), required_glossary_terms={ + 'hello': [], 'algorithm': [('computer program', 'glossary-algorithm'), ('algorithm cost', 'glossary-algorithm-2'), @@ -126,15 +129,15 @@ def test_multiple_calls(self): ) ] - for test in test_cases: + for filename, expected_result in test_cases: verto = Verto() - test_string = self.read_test_file(self.test_name, test[0]) + test_string = self.read_test_file(self.test_name, filename) verto_result = verto.convert(test_string) - self.assertEqual(verto_result.title, test[1].title) - self.assertEqual(verto_result.required_files, test[1].required_files) - self.assertTupleEqual(verto_result.heading_tree, test[1].heading_tree) - self.assertDictEqual(verto_result.required_glossary_terms, test[1].required_glossary_terms) + self.assertEqual(verto_result.title, expected_result.title) + self.assertEqual(verto_result.required_files, expected_result.required_files) + self.assertTupleEqual(verto_result.heading_tree, expected_result.heading_tree) + self.assertDictEqual(verto_result.required_glossary_terms, expected_result.required_glossary_terms) def test_custom_processors_and_custom_templates_on_creation(self): '''Checks if custom processors and custom templates work diff --git a/verto/tests/GlossaryLinkTest.py b/verto/tests/GlossaryLinkTest.py index f019f5d6..c1a92672 100644 --- a/verto/tests/GlossaryLinkTest.py +++ b/verto/tests/GlossaryLinkTest.py @@ -35,7 +35,9 @@ def test_single_word_term(self): self.assertEqual(expected_string, converted_test_string) glossary_terms = self.verto_extension.glossary_terms - expected_glossary_terms = dict() + expected_glossary_terms = { + 'quicksort': [] + } self.assertDictEqual(expected_glossary_terms, glossary_terms) def test_multiple_word_term(self): @@ -51,7 +53,9 @@ def test_multiple_word_term(self): self.assertEqual(expected_string, converted_test_string) glossary_terms = self.verto_extension.glossary_terms - expected_glossary_terms = dict() + expected_glossary_terms = { + 'digital-signature': [] + } self.assertDictEqual(expected_glossary_terms, glossary_terms) def test_reference_text_given(self): @@ -88,7 +92,9 @@ def test_leading_inline_text(self): self.assertEqual(expected_string, converted_test_string) glossary_terms = self.verto_extension.glossary_terms - expected_glossary_terms = dict() + expected_glossary_terms = { + 'grammar': [] + } self.assertDictEqual(expected_glossary_terms, glossary_terms) def test_trailing_inline_text(self): @@ -105,7 +111,9 @@ def test_trailing_inline_text(self): self.assertEqual(expected_string, converted_test_string) glossary_terms = self.verto_extension.glossary_terms - expected_glossary_terms = dict() + expected_glossary_terms = { + 'finite state automaton': [] + } self.assertDictEqual(expected_glossary_terms, glossary_terms) def test_leading_and_trailing_inline_text(self): @@ -122,7 +130,9 @@ def test_leading_and_trailing_inline_text(self): self.assertEqual(expected_string, converted_test_string) glossary_terms = self.verto_extension.glossary_terms - expected_glossary_terms = dict() + expected_glossary_terms = { + 'Regular expression': [] + } self.assertDictEqual(expected_glossary_terms, glossary_terms) def test_multiple_terms(self): @@ -141,6 +151,8 @@ def test_multiple_terms(self): glossary_terms = self.verto_extension.glossary_terms expected_glossary_terms = { + 'grammar': [], + 'regular-expression': [], 'finite-state-automaton': [('Formal languages', 'glossary-finite-state-automaton')] } @@ -162,6 +174,7 @@ def test_multiple_reference_text(self): glossary_terms = self.verto_extension.glossary_terms expected_glossary_terms = { + 'hello': [], 'algorithm': [('computer program', 'glossary-algorithm'), ('algorithm cost', 'glossary-algorithm-2'), @@ -187,7 +200,9 @@ def test_doc_example_basic(self): self.assertEqual(expected_string, converted_test_string) glossary_terms = self.verto_extension.glossary_terms - expected_glossary_terms = dict() + expected_glossary_terms = { + 'algorithm': [] + } self.assertDictEqual(expected_glossary_terms, glossary_terms) def test_doc_example_override_html(self): From 497b0edfbd9e0440ea919419d121e1d6694798fb Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Fri, 5 May 2017 12:34:11 +1200 Subject: [PATCH 02/11] Update python-slugify from 1.2.3 to 1.2.4 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 227fc913..41beef12 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ markdown==2.6.8 beautifulsoup4==4.5.3 Jinja2==2.9.6 -python-slugify==1.2.3 +python-slugify==1.2.4 setuptools==35.0.2 # Required dependencies for building documentation From d723038012746dccf4bf3a3f59f32ed270b474a7 Mon Sep 17 00:00:00 2001 From: Hayden Jackson Date: Fri, 5 May 2017 13:23:11 +1200 Subject: [PATCH 03/11] Update setup.py requirements. --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index b7a1485a..875892ac 100644 --- a/setup.py +++ b/setup.py @@ -31,8 +31,8 @@ include_package_data=True, install_requires=[ 'markdown>=2.6.8', - 'beautifulsoup4==4.5.3', + 'beautifulsoup4>=4.5.3', 'Jinja2>=2.9.6', - 'python-slugify>=1.2.2' + 'python-slugify>=1.2.4' ] ) From 1b9b3ea996bf17f21ee2c0a7bc936d3806800c0e Mon Sep 17 00:00:00 2001 From: Hayden Jackson Date: Fri, 5 May 2017 13:42:21 +1200 Subject: [PATCH 04/11] Clear uniques only when requested, while per document data cleared on each run. --- verto/Verto.py | 8 +++++++- verto/VertoExtension.py | 8 ++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/verto/Verto.py b/verto/Verto.py index 35be2f0d..341c0e03 100644 --- a/verto/Verto.py +++ b/verto/Verto.py @@ -66,7 +66,7 @@ def convert(self, text): Returns: A VertoResult object. ''' - self.verto_extension.clear_saved_data() + self.verto_extension.clear_document_data() html_string = self.converter.convert(text) result = VertoResult( html_string=html_string, @@ -77,6 +77,12 @@ def convert(self, text): ) return result + def clear_saved_data(self): + '''Wrapped for clearing the saved data of the verto + extension. + ''' + self.verto_extension.clear_saved_data() + def update_templates(self, html_templates): '''Update the template dictionary with the given dictionary of templates, while leaving all other HTML templates (including diff --git a/verto/VertoExtension.py b/verto/VertoExtension.py index cff7098d..4106835e 100644 --- a/verto/VertoExtension.py +++ b/verto/VertoExtension.py @@ -116,13 +116,17 @@ def update_processors(processors, markdown_processors): processor = ScratchCompatibilityPreprocessor(self, md) md.preprocessors.add('scratch-compatibility', processor, ' Date: Fri, 5 May 2017 13:54:43 +1200 Subject: [PATCH 05/11] Update documentation for clearing saved data and the verto result definition. --- docs/source/usage.rst | 19 ++++++++++++++++++- verto/Verto.py | 4 ++-- verto/VertoExtension.py | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/docs/source/usage.rst b/docs/source/usage.rst index a6fdcbda..b6ae536b 100644 --- a/docs/source/usage.rst +++ b/docs/source/usage.rst @@ -116,6 +116,15 @@ The following attributes are available: [] } +(Optional) Step 5: Clearing Saved Data +======================================= + +Lastly there is some data that is saved between conversions such as ``required_files`` and unique ids used in the ``glossary`` and for ``headings``. This can be cleared by using the following method: + + .. code-block:: python + + converter.clear_saved_data() + Configuring Verto converter after creation =============================================== @@ -155,7 +164,7 @@ Full list of package methods ======================================= .. autoclass:: verto.Verto() - :members: __init__, convert, update_processors, processor_defaults, update_templates, clear_templates + :members: __init__, convert, update_processors, processor_defaults, update_templates, clear_templates, clear_saved_data .. autoclass:: verto.Verto.VertoResult() @@ -170,3 +179,11 @@ Full list of package methods .. attribute:: required_files A dictionary of files encountered in a Verto conversion. The dictionary has a string for the file type as the key (for example: ``image``) and a set of all file paths encountered as the value (for example: ``{'image/face.png', 'image/logo.png`}``). + + .. attribute:: heading_tree + + A tuple of namedtuples which describes the tree of headings, as generated by our heading processor. Each namedtuple contains a title (string), title_slug (string), level (integer) and children (tuple of nodes). + + .. attribute:: required_glossary_terms + + A dictionary of terms to a list of tuples containing reference text and link IDs. diff --git a/verto/Verto.py b/verto/Verto.py index 341c0e03..1da65fb3 100644 --- a/verto/Verto.py +++ b/verto/Verto.py @@ -78,8 +78,8 @@ def convert(self, text): return result def clear_saved_data(self): - '''Wrapped for clearing the saved data of the verto - extension. + '''Clears data that is saved between documents. This should be + called between conversions on unrelated documents. ''' self.verto_extension.clear_saved_data() diff --git a/verto/VertoExtension.py b/verto/VertoExtension.py index 4106835e..95e6a1b1 100644 --- a/verto/VertoExtension.py +++ b/verto/VertoExtension.py @@ -124,7 +124,7 @@ def clear_document_data(self): def clear_saved_data(self): '''Clears stored information from processors, should be called - between runs. + between runs on unrelated documents. ''' self.custom_slugify.clear() for key in self.required_files.keys(): From f55342d29757cd84eabce03427499f5af5a19fc2 Mon Sep 17 00:00:00 2001 From: Hayden Jackson Date: Fri, 5 May 2017 13:57:38 +1200 Subject: [PATCH 06/11] flake8 fix --- verto/Verto.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/verto/Verto.py b/verto/Verto.py index 1da65fb3..3cc5aa62 100644 --- a/verto/Verto.py +++ b/verto/Verto.py @@ -79,7 +79,7 @@ def convert(self, text): def clear_saved_data(self): '''Clears data that is saved between documents. This should be - called between conversions on unrelated documents. + called between conversions on unrelated documents. ''' self.verto_extension.clear_saved_data() From a235f8ab6ccde9f4d983ebc662ca60f306dfda39 Mon Sep 17 00:00:00 2001 From: Hayden Jackson Date: Fri, 5 May 2017 18:54:38 +1200 Subject: [PATCH 07/11] Remove beautify processor and update tests. --- docs/source/processors/beautify.rst | 31 ----- verto/VertoExtension.py | 2 - verto/html-templates/boxed-text.html | 2 +- verto/html-templates/glossary-link.html | 4 +- verto/html-templates/heading.html | 44 +++---- verto/html-templates/iframe.html | 4 +- verto/html-templates/image.html | 24 ++-- verto/html-templates/interactive.html | 36 +++--- verto/html-templates/panel.html | 16 +-- verto/html-templates/relative-link.html | 4 +- verto/html-templates/scratch.html | 8 +- verto/html-templates/table-of-contents.html | 2 +- verto/html-templates/video.html | 2 +- verto/processors/BeautifyPostprocessor.py | 86 -------------- .../GenericContainerBlockProcessor.py | 1 + verto/tests/BeautifyTest.py | 62 ---------- verto/tests/ConfigurationTest.py | 34 +++--- verto/tests/VideoTest.py | 11 ++ .../doc_example_basic_usage_expected.html | 10 +- .../doc_example_override_html_expected.html | 8 +- .../doc_example_override_html_template.html | 6 +- .../indented_boxed_text_expected.html | 4 +- .../multiple_boxed_text_expected.html | 16 +-- .../boxed-text/no_boxed_text_expected.html | 16 +-- .../recursive_boxed_text_expected.html | 16 +-- .../single_boxed_text_expected.html | 8 +- .../button-link/contains_button_expected.html | 19 +--- .../contains_file_link_button_expected.html | 23 +--- .../contains_multiple_buttons_expected.html | 45 ++------ .../doc_example_basic_usage_expected.html | 4 +- .../doc_example_file_usage_expected.html | 4 +- .../doc_example_override_html_expected.html | 4 +- .../missing_end_brace_expected.html | 12 +- .../button-link/no_button_expected.html | 36 ++---- .../comment_contains_comment_expected.html | 4 +- ...mment_within_block_container_expected.html | 16 +-- ...ins_multiple_inline_comments_expected.html | 4 +- .../doc_example_multiple_usage_expected.html | 12 +- .../comment/no_inline_comment_expected.html | 10 +- ...xt_contains_the_word_comment_expected.html | 20 +--- .../doc_example_basic_usage_expected.html | 4 +- .../doc_example_complex_usage_expected.html | 16 +-- .../doc_example_override_html_expected.html | 12 +- .../example_basic_else_usage_expected.html | 8 +- .../example_elif_no_else_expected.html | 2 +- .../example_single_elif_expected.html | 8 +- .../all_processors_custom_html_expected.html | 93 +++++---------- ...ll_processors_except_comment_expected.html | 106 +++++------------ .../all_processors_expected.html | 102 +++++------------ ..._processors_custom_templates_expected.html | 85 ++++---------- .../custom_processors_expected.html | 107 +++++------------- .../multiline_templates_expected.html | 96 +++++----------- .../some_processors_2_expected.html | 76 ++++--------- .../some_processors_expected.html | 29 ++--- .../doc_example_basic_usage_expected.html | 8 +- .../doc_example_override_html_expected.html | 8 +- .../doc_example_override_html_template.html | 4 +- ...ing_and_trailing_inline_text_expected.html | 14 +-- .../leading_inline_text_expected.html | 12 +- .../glossary-link/multiple_reference_text.md | 4 +- .../multiple_reference_text_expected.html | 49 ++------ .../assets/glossary-link/multiple_terms.md | 9 +- .../multiple_terms_expected.html | 20 +--- .../multiple_word_term_expected.html | 11 +- .../reference_text_given_expected.html | 6 +- .../single_word_term_expected.html | 8 +- .../trailing_inline_text_expected.html | 9 +- .../doc_example_basic_usage_expected.html | 24 ++-- .../doc_example_override_html_expected.html | 56 ++++----- .../doc_example_override_html_template.html | 8 +- .../example_single_heading_expected.html | 8 +- .../multiple_roots_zero_level_expected.html | 56 ++++----- .../doc_example_basic_usage_expected.html | 4 +- .../doc_example_override_html_template.html | 3 +- .../assets/image/align_center_expected.html | 2 +- .../assets/image/align_left_expected.html | 2 +- .../assets/image/align_right_expected.html | 2 +- .../assets/image/contains_alt_expected.html | 2 +- .../image/contains_caption_expected.html | 6 +- .../image/contains_caption_link_expected.html | 8 +- .../image/contains_hover_text_expected.html | 2 +- ...and_text_contains_word_image_expected.html | 10 +- .../assets/image/contains_image_expected.html | 14 +-- .../contains_multiple_images_expected.html | 24 ++-- .../image/contains_source_expected.html | 8 +- .../assets/image/default_image_expected.html | 26 +---- .../doc_example_2_override_html_expected.html | 2 +- .../doc_example_2_override_html_template.html | 2 +- .../doc_example_basic_usage_expected.html | 12 +- .../doc_example_override_html_expected.html | 2 +- .../doc_example_override_html_template.html | 2 +- .../assets/image/external_image_expected.html | 6 +- .../image_in_numbered_list_expected.html | 56 ++++----- .../assets/image/internal_image_expected.html | 10 +- ...text_contains_the_word_image_expected.html | 8 +- .../doc_example_iframe_usage_expected.html | 4 +- .../doc_example_override_html_expected.html | 6 +- .../doc_example_override_html_template.html | 34 +++--- ...doc_example_whole_page_usage_expected.html | 8 +- .../assets/jinja/doc_example_basic_usage.md | 10 +- .../doc_example_basic_usage_expected.html | 10 +- .../ordered_list_loose_expected.html | 28 ++--- ...red_list_multiple_paragraphs_expected.html | 42 +++---- .../ordered_list_tight_expected.html | 16 +-- .../ordered_list_tight_nested_expected.html | 28 ++--- .../markdown-override/sane_list_expected.html | 16 +-- .../sane_list_python_markdown_expected.html | 12 +- ...nordered_list_asterisk_loose_expected.html | 28 ++--- ...nordered_list_asterisk_tight_expected.html | 16 +-- .../unordered_list_loose_nested_expected.html | 52 ++++----- .../unordered_list_mixed_nested_expected.html | 40 +++---- .../unordered_list_tight_nested_expected.html | 28 ++--- .../panel/contains_inner_image_expected.html | 37 ++---- .../panel/contains_inner_panel_expected.html | 42 +++---- .../contains_multiple_panels_expected.html | 66 ++++------- .../doc_example_basic_usage_expected.html | 17 +-- .../doc_example_override_html_expected.html | 24 ++-- .../doc_example_override_html_template.html | 20 ++-- .../panel_in_numbered_list_expected.html | 61 ++++------ .../panel_only_in_numbered_list_expected.html | 57 ++++------ ...parses_always_expanded_panel_expected.html | 17 +-- ...nk_lines_multiple_paragraphs_expected.html | 41 ++----- .../panel/parses_expanded_panel_expected.html | 17 +-- ...blank_lines_single_paragraph_expected.html | 17 +-- .../doc_example_basic_usage_expected.html | 8 +- .../relative-link/ftp_schema_expected.html | 8 +- .../relative-link/ftp_text_expected.html | 8 +- .../relative-link/ftps_schema_expected.html | 8 +- .../relative-link/ftps_text_expected.html | 8 +- .../relative-link/http_schema_expected.html | 8 +- .../relative-link/http_text_expected.html | 8 +- .../relative-link/https_schema_expected.html | 8 +- .../relative-link/https_text_expected.html | 8 +- .../relative-link/long_path_expected.html | 8 +- .../relative-link/mailto_schema_expected.html | 8 +- .../relative-link/mailto_text_expected.html | 8 +- .../multiple_links_expected.html | 20 +--- .../relative-link/news_schema_expected.html | 8 +- .../relative-link/news_text_expected.html | 8 +- .../relative-link/www_text_expected.html | 8 +- .../doc_example_basic_usage_expected.html | 4 +- .../level_two_heading_expected.html | 4 +- .../multiple_headings_expected.html | 28 ++--- .../multiple_level_one_headings_expected.html | 28 ++--- .../no_heading_permalink_expected.html | 8 +- .../remove-title/no_headings_expected.html | 12 +- .../remove-title/no_space_title_expected.html | 4 +- .../remove-title/processor_off_expected.html | 8 +- .../assets/remove/doc_example_basic_usage.md | 14 +-- .../doc_example_basic_usage_expected.html | 10 +- .../doc_example_basic_usage_expected.html | 4 +- .../doc_example_override_html_expected.html | 3 +- .../doc_example_override_html_template.html | 6 +- .../example_multiple_codeblocks_expected.html | 24 ++-- ...xample_multiple_codeblocks_expected_2.html | 16 ++- .../scratch/example_other_code_expected.html | 4 +- .../example_separate_blocks_expected.html | 4 +- .../example_split_codeblocks_expected.html | 16 ++- ...mple_standard_markdown_block_expected.html | 8 +- .../doc_example_override_html_expected.html | 20 ++-- .../doc_example_override_html_template.html | 18 +-- .../contains_multiple_videos_expected.html | 8 +- .../video/contains_no_video_expected.html | 40 +------ .../assets/video/contains_vimeo_video.md | 5 - .../video/contains_vimeo_video_expected.html | 5 - .../doc_example_basic_usage_expected.html | 5 +- .../doc_example_override_html_expected.html | 5 +- .../doc_example_override_html_template.html | 5 +- .../video/multiple_vimeo_links_expected.html | 11 +- .../multiple_youtube_links_expected.html | 41 ++----- verto/tests/assets/video/vimeo_link.md | 4 +- .../assets/video/vimeo_link_expected.html | 31 +---- verto/tests/assets/video/vimeo_player_link.md | 4 +- .../video/vimeo_player_link_expected.html | 31 +---- .../youtube_and_vimeo_links_expected.html | 50 +++----- .../video/youtube_be_link_expected.html | 11 +- .../video/youtube_embed_link_expected.html | 36 ++---- .../video/youtube_watch_link_expected.html | 39 ++----- verto/tests/start_tests.py | 3 +- 179 files changed, 1021 insertions(+), 2431 deletions(-) delete mode 100644 docs/source/processors/beautify.rst delete mode 100644 verto/processors/BeautifyPostprocessor.py delete mode 100644 verto/tests/BeautifyTest.py delete mode 100644 verto/tests/assets/video/contains_vimeo_video.md delete mode 100644 verto/tests/assets/video/contains_vimeo_video_expected.html diff --git a/docs/source/processors/beautify.rst b/docs/source/processors/beautify.rst deleted file mode 100644 index a848277c..00000000 --- a/docs/source/processors/beautify.rst +++ /dev/null @@ -1,31 +0,0 @@ -.. _beautify: - -Beautify -####################################### - -**Processor name:** ``beautify`` - -The ``beautify`` processor is a post-processor that tidies and prettifies the HTML to give consistent and predictable output. The processor works by applying the prettify function from the ``beautifulsoup4`` library just before the final output, this means HTML elements will be separated onto individual lines where children are indented by one space. For example given the following document: - -.. literalinclude:: ../../../verto/tests/assets/beautify/doc_example_basic_usage.md - :language: none - -Verto will prettify it into: - -.. literalinclude:: ../../../verto/tests/assets/beautify/doc_example_basic_usage_expected.html - :language: html - -Special Case(s) -*************************************** - -For example given the following Markdown: - -.. literalinclude:: ../../../verto/tests/assets/beautify/example_inline_code.md - :language: none - -Verto with ``beautify`` enabled will produce the following html: - -.. literalinclude:: ../../../verto/tests/assets/beautify/example_inline_code_expected.html - :language: html - -Where the ``code`` tag and its contents are unchanged to preserve formatting, this is especially important for whitespace dependent languages. diff --git a/verto/VertoExtension.py b/verto/VertoExtension.py index cff7098d..f2d8df3e 100644 --- a/verto/VertoExtension.py +++ b/verto/VertoExtension.py @@ -9,7 +9,6 @@ from verto.processors.RemoveTitlePreprocessor import RemoveTitlePreprocessor from verto.processors.SaveTitlePreprocessor import SaveTitlePreprocessor from verto.processors.GlossaryLinkPattern import GlossaryLinkPattern -from verto.processors.BeautifyPostprocessor import BeautifyPostprocessor from verto.processors.ConditionalProcessor import ConditionalProcessor from verto.processors.StylePreprocessor import StylePreprocessor from verto.processors.RemovePostprocessor import RemovePostprocessor @@ -98,7 +97,6 @@ def update_processors(processors, markdown_processors): md.preprocessors.add('style', StylePreprocessor(self, md), '_begin') md.postprocessors.add('remove', RemovePostprocessor(md), '_end') - md.postprocessors.add('beautify', BeautifyPostprocessor(md), '_end') md.postprocessors.add('jinja', JinjaPostprocessor(md), '_end') # Compatibility modules diff --git a/verto/html-templates/boxed-text.html b/verto/html-templates/boxed-text.html index 18c22971..12e4bb64 100644 --- a/verto/html-templates/boxed-text.html +++ b/verto/html-templates/boxed-text.html @@ -1,5 +1,5 @@
{% autoescape false -%} {{ text }} -{%- endautoescape %} +{% endautoescape -%}
diff --git a/verto/html-templates/glossary-link.html b/verto/html-templates/glossary-link.html index dc4d18f0..7fb89faa 100644 --- a/verto/html-templates/glossary-link.html +++ b/verto/html-templates/glossary-link.html @@ -1,5 +1,3 @@ - {{ text }} - + {% if id %} id="{{ id }}" {% endif %}>{{ text }} diff --git a/verto/html-templates/heading.html b/verto/html-templates/heading.html index ad4a56af..0df83a38 100644 --- a/verto/html-templates/heading.html +++ b/verto/html-templates/heading.html @@ -1,24 +1,24 @@ <{{ heading_type }} id="{{ title_slug }}"> - - {% if heading_level >= 1 -%} - {{ "{{ chapter.number }}" }} - {%- endif -%} - {%- if heading_level >= 2 -%} - .{{ level_2 }} - {%- endif -%} - {%- if heading_level >= 3 -%} - .{{ level_3 }} - {%- endif -%} - {%- if heading_level >= 4 -%} - .{{ level_4 }} - {%- endif -%} - {%- if heading_level >= 5 -%} - .{{ level_5 }} - {%- endif -%} - {%- if heading_level >= 6 -%} - .{{ level_6 }} - {%- endif -%} - . - - {{ title }} + +{% if heading_level >= 1 -%} +{{ "{{ chapter.number }}" }} +{%- endif -%} +{%- if heading_level >= 2 -%} +.{{ level_2 }} +{%- endif -%} +{%- if heading_level >= 3 -%} +.{{ level_3 }} +{%- endif -%} +{%- if heading_level >= 4 -%} +.{{ level_4 }} +{%- endif -%} +{%- if heading_level >= 5 -%} +.{{ level_5 }} +{%- endif -%} +{%- if heading_level >= 6 -%} +.{{ level_6 }} +{%- endif -%} +. + +{{ title }} diff --git a/verto/html-templates/iframe.html b/verto/html-templates/iframe.html index b4436685..5181a1c6 100644 --- a/verto/html-templates/iframe.html +++ b/verto/html-templates/iframe.html @@ -1,5 +1,3 @@ diff --git a/verto/html-templates/image.html b/verto/html-templates/image.html index adfbb35d..b9f4013d 100644 --- a/verto/html-templates/image.html +++ b/verto/html-templates/image.html @@ -1,14 +1,14 @@
- - {%- if caption and caption_link -%} -

{{ caption }}

- {%- elif caption -%} -

{{ caption }}

- {%- endif -%} - {%- if source_link -%} -

Source

- {%- endif -%} + +{% if caption and caption_link -%} +

{{ caption }}

+{%- elif caption -%} +

{{ caption }}

+{%- endif -%} +{%- if source_link -%} +

Source

+{%- endif -%}
diff --git a/verto/html-templates/interactive.html b/verto/html-templates/interactive.html index a5154713..2a5d5c08 100644 --- a/verto/html-templates/interactive.html +++ b/verto/html-templates/interactive.html @@ -1,22 +1,22 @@ {%- if type == 'in-page' -%} - - {{ "{% include 'interactive/" }}{{ name }}{{ "/index.html' %}" }} - + +{{ "{% include 'interactive/" }}{{ name }}{{ "/index.html' %}" }} + {% elif type == 'iframe' -%} - + {% elif type == 'whole-page' -%} - - -
- {% if text -%} - {{ text }} - {% else -%} - Click to load {{ name }} - {% endif -%} -
-
+ + +
+{% if text -%} +{{ text }} +{% else -%} +Click to load {{ name }} +{% endif -%} +
+
{%- endif -%} diff --git a/verto/html-templates/panel.html b/verto/html-templates/panel.html index 48134631..e794e485 100644 --- a/verto/html-templates/panel.html +++ b/verto/html-templates/panel.html @@ -1,10 +1,10 @@
-
- {{ title }}{% if subtitle %}: {{ subtitle }}{% else %}{% endif %} -
-
- {% autoescape false -%} - {{ content }} - {%- endautoescape %} -
+
+{{ title }}{% if subtitle %}: {{ subtitle }}{% else %}{% endif %} +
+
+{% autoescape false -%} +{{ content }} +{% endautoescape -%} +
diff --git a/verto/html-templates/relative-link.html b/verto/html-templates/relative-link.html index 888f21ba..5a99930a 100644 --- a/verto/html-templates/relative-link.html +++ b/verto/html-templates/relative-link.html @@ -1,3 +1 @@ - - {{ text }} - +{{ text }} diff --git a/verto/html-templates/scratch.html b/verto/html-templates/scratch.html index c00cc825..5e504c44 100644 --- a/verto/html-templates/scratch.html +++ b/verto/html-templates/scratch.html @@ -1,6 +1,6 @@
- {% for hash in images -%} - - - {% endfor -%} +{% for hash in images -%} + + +{% endfor -%}
diff --git a/verto/html-templates/table-of-contents.html b/verto/html-templates/table-of-contents.html index f5e57596..b0aa0298 100644 --- a/verto/html-templates/table-of-contents.html +++ b/verto/html-templates/table-of-contents.html @@ -1,3 +1,3 @@ - {{ "{{ table_of_contents }}" }} +{{ "{{ table_of_contents }}" }} diff --git a/verto/html-templates/video.html b/verto/html-templates/video.html index afa588ad..88f11eff 100644 --- a/verto/html-templates/video.html +++ b/verto/html-templates/video.html @@ -1,3 +1,3 @@
- +
diff --git a/verto/processors/BeautifyPostprocessor.py b/verto/processors/BeautifyPostprocessor.py deleted file mode 100644 index d0aa9b48..00000000 --- a/verto/processors/BeautifyPostprocessor.py +++ /dev/null @@ -1,86 +0,0 @@ -from markdown.postprocessors import Postprocessor -from markdown.util import HtmlStash -from markdown.odict import OrderedDict -from bs4 import BeautifulSoup -import re - - -class BeautifyPostprocessor(Postprocessor): - ''' Converts the output document into a more asthetically - pleasing version with more consistent whitespace. - ''' - - def __init__(self, *args, **kwargs): - ''' Creates a new BeautifyPostprocessor. - ''' - super().__init__(*args, **kwargs) - self.pre_pattern = re.compile(r'
.*?
', re.DOTALL) - self.code_pattern = re.compile(r'(?P.*?)', re.DOTALL) - self.html_stash = HtmlStash() - - def run(self, text): - '''Converts the document into a more asthetically - pleasing version. - Args: - text: A string of the document to convert. - Returns: - A string of the converted document. - ''' - text = self.store_non_pre_code_tags(text) - text = BeautifulSoup(text, 'html.parser').prettify(formatter='html') - text = self.restore_non_pre_code_tags(text) - return text - - def store_non_pre_code_tags(self, text): - '''Stores code tags that are not in pre tags to preserve - whitespacing, replacing with placeholders. - - Args: - text: A string of the document to process. - Returns: - The document with code blocks replaced with placeholders. - ''' - prepass_text = text - pre_spans = [] - - match = self.pre_pattern.search(prepass_text) - while match is not None: - pre_spans.append(match.span()) - prepass_text = prepass_text[match.end():] - match = self.pre_pattern.search(prepass_text) - - out_text = '' - match = self.code_pattern.search(text) - while match is not None: - if not any(match.start() in range(*span) or match.end() in range(*span) for span in pre_spans): - html_string = match.group() - placeholder = self.html_stash.store(html_string, True) - out_text = text[:match.start()] + placeholder - else: - out_text = text[:match.end()] - text = text[match.end():] - match = self.pre_pattern.search(text) - out_text += text - - return out_text - - def restore_non_pre_code_tags(self, text): - '''Restores code tags that are not in pre tags by replacing - placeholders. This is to preserve whitespacing. - - Args: - text: A string of the document to process. - Returns: - The document with placeholders replaced with stored - code blocks. - ''' - replacements = OrderedDict() - for i in range(self.html_stash.html_counter): - html, safe = self.html_stash.rawHtmlBlocks[i] - replacements[self.html_stash.get_placeholder(i)] = html - - if len(replacements) > 0: - pattern = re.compile('|'.join(re.escape(k) for k in replacements)) - text = pattern.sub(lambda m: replacements[m.group(0)], text) - - return text diff --git a/verto/processors/GenericContainerBlockProcessor.py b/verto/processors/GenericContainerBlockProcessor.py index ed79c5e8..1843ae25 100644 --- a/verto/processors/GenericContainerBlockProcessor.py +++ b/verto/processors/GenericContainerBlockProcessor.py @@ -100,6 +100,7 @@ def run(self, parent, blocks): content = '' for child in content_tree: content += HtmlSerializer.tostring(child) + '\n' + content = content.strip('\n') if content.strip() == '': message = 'content cannot be blank.' diff --git a/verto/tests/BeautifyTest.py b/verto/tests/BeautifyTest.py deleted file mode 100644 index 74a25a4d..00000000 --- a/verto/tests/BeautifyTest.py +++ /dev/null @@ -1,62 +0,0 @@ -import markdown -from verto.VertoExtension import VertoExtension -from verto.tests.ProcessorTest import ProcessorTest - -class BeautifyTest(ProcessorTest): - '''The major concern with beautifying is that preformatted tags and - code blocks are unchanged. The tests here cover these cases. - ''' - - def __init__(self, *args, **kwargs): - '''Set processor name in class for file names. - ''' - ProcessorTest.__init__(self, *args, **kwargs) - self.processor_name = 'beautify' - - def test_doc_example_basic(self): - '''Checks that basic usecase works as expected. - ''' - test_string = self.read_test_file(self.processor_name, 'doc_example_basic_usage.md') - - converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) - expected_string = self.read_test_file(self.processor_name, 'doc_example_basic_usage_expected.html', strip=True) - self.assertEqual(expected_string, converted_test_string) - - def test_example_inline_code(self): - '''Tests to see that inline code formatting is unchanged. - ''' - test_string = self.read_test_file(self.processor_name, 'example_inline_code.md') - - converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) - expected_string = self.read_test_file(self.processor_name, 'example_inline_code_expected.html', strip=True) - self.assertEqual(expected_string, converted_test_string) - - def test_example_preformatted_code(self): - '''Tests to ensure that preformatted tag content is unchanged. - ''' - test_string = self.read_test_file(self.processor_name, 'example_preformatted_code.md') - - converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) - expected_string = self.read_test_file(self.processor_name, 'example_preformatted_code_expected.html', strip=True) - self.assertEqual(expected_string, converted_test_string) - - def test_example_preformatted_code_with_extension(self): - '''Tests to ensure that the fenced_code extension does not - change output to retain compatibility. - ''' - verto_extension = VertoExtension([self.processor_name], {}, ['markdown.extensions.fenced_code']) - test_string = self.read_test_file(self.processor_name, 'example_preformatted_code_with_extension.md') - - converted_test_string = markdown.markdown(test_string, extensions=[verto_extension, 'markdown.extensions.fenced_code']) - expected_string = self.read_test_file(self.processor_name, 'example_preformatted_code_with_extension_expected.html', strip=True) - self.assertEqual(expected_string, converted_test_string) - - def text_example_mixed_code_types(self): - '''Tests that all types of code blocks remain unchanged when - used together. - ''' - test_string = self.read_test_file(self.processor_name, 'example_mixed_code_types.md') - - converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) - expected_string = self.read_test_file(self.processor_name, 'example_mixed_code_types_expected.html', strip=True) - self.assertEqual(expected_string, converted_test_string) diff --git a/verto/tests/ConfigurationTest.py b/verto/tests/ConfigurationTest.py index f4405d2f..3ed3ed74 100644 --- a/verto/tests/ConfigurationTest.py +++ b/verto/tests/ConfigurationTest.py @@ -247,20 +247,26 @@ def test_multiline_custom_templates(self): and used correctly. ''' custom_templates = { - 'image': '''
- -
''', - 'boxed-text': '''
-
- {{ text }} -
-
''', - 'heading': '''<{{ heading_type }} id="{{ title_slug }}"> - - {{ level_1 }}.{{ level_2 }}.{{ level_3 }}.{{ level_4 }}.{{ level_5 }}.{{ level_6 }}. - - {{ title }} - ''' + 'image': \ +'''
+ +
''', + + 'boxed-text': \ +'''
+
+{{ text }} +
+
''', + + 'heading': \ +'''<{{ heading_type }} id="{{ title_slug }}"> + +{{ level_1 }}.{{ level_2 }}.{{ level_3 }}.{{ level_4 }}.{{ level_5 }}.{{ level_6 }}. + +{{ title }} +''' + } verto = Verto(html_templates=custom_templates) diff --git a/verto/tests/VideoTest.py b/verto/tests/VideoTest.py index 87171b68..61d88c66 100644 --- a/verto/tests/VideoTest.py +++ b/verto/tests/VideoTest.py @@ -162,6 +162,17 @@ def test_missing_identifier(self): self.assertRaises(NoVideoIdentifierError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) + def test_contains_multiple_videos(self): + '''Tests output of multiple video links. + ''' + test_string = self.read_test_file(self.processor_name, 'contains_multiple_videos.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([False, False, True, False, True, False, True, False], [VideoBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) + expected_file_string = self.read_test_file(self.processor_name, 'contains_multiple_videos_expected.html', strip=True) + self.assertEqual(converted_test_string, expected_file_string) #~ # Doc Tests #~ diff --git a/verto/tests/assets/boxed-text/doc_example_basic_usage_expected.html b/verto/tests/assets/boxed-text/doc_example_basic_usage_expected.html index daa8b571..53e3b827 100644 --- a/verto/tests/assets/boxed-text/doc_example_basic_usage_expected.html +++ b/verto/tests/assets/boxed-text/doc_example_basic_usage_expected.html @@ -1,10 +1,4 @@
-

- - Computer Science Report for 2.44 - -

-

- Put your introduction to what bits are here. -

+

Computer Science Report for 2.44

+

Put your introduction to what bits are here.

diff --git a/verto/tests/assets/boxed-text/doc_example_override_html_expected.html b/verto/tests/assets/boxed-text/doc_example_override_html_expected.html index 109dba12..cf26a564 100644 --- a/verto/tests/assets/boxed-text/doc_example_override_html_expected.html +++ b/verto/tests/assets/boxed-text/doc_example_override_html_expected.html @@ -1,7 +1,5 @@
-
-

- This text is displayed using a Bootstrap 4 card. -

-
+
+

This text is displayed using a Bootstrap 4 card.

+
diff --git a/verto/tests/assets/boxed-text/doc_example_override_html_template.html b/verto/tests/assets/boxed-text/doc_example_override_html_template.html index fe317ee1..77e162c4 100644 --- a/verto/tests/assets/boxed-text/doc_example_override_html_template.html +++ b/verto/tests/assets/boxed-text/doc_example_override_html_template.html @@ -1,5 +1,5 @@
-
- {{ text }} -
+
+{{ text }} +
diff --git a/verto/tests/assets/boxed-text/indented_boxed_text_expected.html b/verto/tests/assets/boxed-text/indented_boxed_text_expected.html index 78289b50..cd5443b5 100644 --- a/verto/tests/assets/boxed-text/indented_boxed_text_expected.html +++ b/verto/tests/assets/boxed-text/indented_boxed_text_expected.html @@ -1,5 +1,3 @@
-

- This text is displayed using a Bootstrap 4 card. -

+

This text is displayed using a Bootstrap 4 card.

diff --git a/verto/tests/assets/boxed-text/multiple_boxed_text_expected.html b/verto/tests/assets/boxed-text/multiple_boxed_text_expected.html index 568c19cb..2dbeb661 100644 --- a/verto/tests/assets/boxed-text/multiple_boxed_text_expected.html +++ b/verto/tests/assets/boxed-text/multiple_boxed_text_expected.html @@ -1,16 +1,8 @@
-

- This text is displayed using a Bootstrap 4 card. -

+

This text is displayed using a Bootstrap 4 card.

-

- Aenean turpis diam, dictum nec odio ut, porta luctus nunc. Donec vulputate eu magna non finibus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam finibus lectus non lorem consectetur, id sollicitudin est tristique. Nulla in ultricies lectus, nec dapibus ante. Ut ullamcorper orci tincidunt ex mollis rutrum. Nam dapibus diam eu orci laoreet, et egestas quam consectetur. Vestibulum ligula leo, iaculis ac commodo lobortis, posuere ac dui. Aliquam egestas odio congue tempus cursus. Donec dictum dui facilisis enim molestie venenatis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. -

+

Aenean turpis diam, dictum nec odio ut, porta luctus nunc. Donec vulputate eu magna non finibus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam finibus lectus non lorem consectetur, id sollicitudin est tristique. Nulla in ultricies lectus, nec dapibus ante. Ut ullamcorper orci tincidunt ex mollis rutrum. Nam dapibus diam eu orci laoreet, et egestas quam consectetur. Vestibulum ligula leo, iaculis ac commodo lobortis, posuere ac dui. Aliquam egestas odio congue tempus cursus. Donec dictum dui facilisis enim molestie venenatis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.

-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. In fermentum sit amet metus at congue. Fusce nec mauris accumsan, consequat mi ut, scelerisque erat. In hac habitasse platea dictumst. Phasellus maximus semper blandit. Nam consequat justo eget orci ultricies convallis. Praesent tempus sodales ipsum. Suspendisse faucibus quam vitae mollis rutrum. Fusce sit amet lacus sit amet arcu lobortis suscipit a vel nulla. -

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. In fermentum sit amet metus at congue. Fusce nec mauris accumsan, consequat mi ut, scelerisque erat. In hac habitasse platea dictumst. Phasellus maximus semper blandit. Nam consequat justo eget orci ultricies convallis. Praesent tempus sodales ipsum. Suspendisse faucibus quam vitae mollis rutrum. Fusce sit amet lacus sit amet arcu lobortis suscipit a vel nulla.

-

- Mauris vestibulum vestibulum neque a mollis. Curabitur ut urna eleifend urna eleifend mollis. Aliquam malesuada luctus purus, eu maximus elit finibus sed. Ut consectetur tempus tempus. Etiam lacinia at mauris eu sagittis. Donec ante urna, semper id aliquam id. -

+

Mauris vestibulum vestibulum neque a mollis. Curabitur ut urna eleifend urna eleifend mollis. Aliquam malesuada luctus purus, eu maximus elit finibus sed. Ut consectetur tempus tempus. Etiam lacinia at mauris eu sagittis. Donec ante urna, semper id aliquam id.

diff --git a/verto/tests/assets/boxed-text/no_boxed_text_expected.html b/verto/tests/assets/boxed-text/no_boxed_text_expected.html index e73eabef..f4453490 100644 --- a/verto/tests/assets/boxed-text/no_boxed_text_expected.html +++ b/verto/tests/assets/boxed-text/no_boxed_text_expected.html @@ -1,12 +1,4 @@ -

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. In fermentum sit amet metus at congue. Fusce nec mauris accumsan, consequat mi ut, scelerisque erat. In hac habitasse platea dictumst. Phasellus maximus semper blandit. Nam consequat justo eget orci ultricies convallis. Praesent tempus sodales ipsum. Suspendisse faucibus quam vitae mollis rutrum. Fusce sit amet lacus sit amet arcu lobortis suscipit a vel nulla. -

-

- Aenean turpis diam, dictum nec odio ut, porta luctus nunc. Donec vulputate eu magna non finibus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam finibus lectus non lorem consectetur, id sollicitudin est tristique. Nulla in ultricies lectus, nec dapibus ante. Ut ullamcorper orci tincidunt ex mollis rutrum. Nam dapibus diam eu orci laoreet, et egestas quam consectetur. Vestibulum ligula leo, iaculis ac commodo lobortis, posuere ac dui. Aliquam egestas odio congue tempus cursus. Donec dictum dui facilisis enim molestie venenatis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. -

-

- Mauris vestibulum vestibulum neque a mollis. Curabitur ut urna eleifend urna eleifend mollis. Aliquam malesuada luctus purus, eu maximus elit finibus sed. Ut consectetur tempus tempus. Etiam lacinia at mauris eu sagittis. Donec ante urna, semper id aliquam id. -

-

- boxed-text -

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. In fermentum sit amet metus at congue. Fusce nec mauris accumsan, consequat mi ut, scelerisque erat. In hac habitasse platea dictumst. Phasellus maximus semper blandit. Nam consequat justo eget orci ultricies convallis. Praesent tempus sodales ipsum. Suspendisse faucibus quam vitae mollis rutrum. Fusce sit amet lacus sit amet arcu lobortis suscipit a vel nulla.

+

Aenean turpis diam, dictum nec odio ut, porta luctus nunc. Donec vulputate eu magna non finibus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam finibus lectus non lorem consectetur, id sollicitudin est tristique. Nulla in ultricies lectus, nec dapibus ante. Ut ullamcorper orci tincidunt ex mollis rutrum. Nam dapibus diam eu orci laoreet, et egestas quam consectetur. Vestibulum ligula leo, iaculis ac commodo lobortis, posuere ac dui. Aliquam egestas odio congue tempus cursus. Donec dictum dui facilisis enim molestie venenatis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.

+

Mauris vestibulum vestibulum neque a mollis. Curabitur ut urna eleifend urna eleifend mollis. Aliquam malesuada luctus purus, eu maximus elit finibus sed. Ut consectetur tempus tempus. Etiam lacinia at mauris eu sagittis. Donec ante urna, semper id aliquam id.

+

boxed-text

diff --git a/verto/tests/assets/boxed-text/recursive_boxed_text_expected.html b/verto/tests/assets/boxed-text/recursive_boxed_text_expected.html index bba0ec73..cb14041a 100644 --- a/verto/tests/assets/boxed-text/recursive_boxed_text_expected.html +++ b/verto/tests/assets/boxed-text/recursive_boxed_text_expected.html @@ -1,13 +1,7 @@
-

- This text is displayed using a Bootstrap 4 card. -

-
-

- I'm inside you. -

-
-

- Where some more text might exist. -

+

This text is displayed using a Bootstrap 4 card.

+
+

I'm inside you.

+
+

Where some more text might exist.

diff --git a/verto/tests/assets/boxed-text/single_boxed_text_expected.html b/verto/tests/assets/boxed-text/single_boxed_text_expected.html index 1b53c3b4..a5ffb467 100644 --- a/verto/tests/assets/boxed-text/single_boxed_text_expected.html +++ b/verto/tests/assets/boxed-text/single_boxed_text_expected.html @@ -1,8 +1,4 @@
-

- This text is displayed using a Bootstrap 4 card. -

-

- Where some more text might exist. -

+

This text is displayed using a Bootstrap 4 card.

+

Where some more text might exist.

diff --git a/verto/tests/assets/button-link/contains_button_expected.html b/verto/tests/assets/button-link/contains_button_expected.html index 66481241..dbe1d4f7 100644 --- a/verto/tests/assets/button-link/contains_button_expected.html +++ b/verto/tests/assets/button-link/contains_button_expected.html @@ -1,15 +1,4 @@ -

- The following interactive has a program that solves the problem for however many cities you want to select by trying out all possible routes, and recording the best so far. You can get a feel for what an intractable problem looks like by seeing how long the interactive takes to solve the problem for different size maps. -Try generating a map with about 5 cities, and press "Start" to solve the problem. -

- - View city trip interactive - -

- Now try it for 10 cities (twice as many). Does it take twice as long? How about twice as many again (20 cities)? What about 50 cities? Can you guess how long it would take? -You're starting to get a feel for what it means for a problem to be - - intractable - - . -

+

The following interactive has a program that solves the problem for however many cities you want to select by trying out all possible routes, and recording the best so far. You can get a feel for what an intractable problem looks like by seeing how long the interactive takes to solve the problem for different size maps. +Try generating a map with about 5 cities, and press "Start" to solve the problem.

+View city trip interactive

Now try it for 10 cities (twice as many). Does it take twice as long? How about twice as many again (20 cities)? What about 50 cities? Can you guess how long it would take? +You're starting to get a feel for what it means for a problem to be intractable.

diff --git a/verto/tests/assets/button-link/contains_file_link_button_expected.html b/verto/tests/assets/button-link/contains_file_link_button_expected.html index f813e61c..8d93d5d9 100644 --- a/verto/tests/assets/button-link/contains_file_link_button_expected.html +++ b/verto/tests/assets/button-link/contains_file_link_button_expected.html @@ -1,18 +1,5 @@ -

- The following interactive has a program that solves the problem for however many cities you want to select by trying out all possible routes, and recording the best so far. You can get a feel for what an intractable problem looks like by seeing how long the interactive takes to solve the problem for different size maps. -Try generating a map with about 5 cities, and press "Start" to solve the problem. -

- - Example Code - -

- Now try it for 10 cities (twice as many). Does it take twice as long? How about twice as many again (20 cities)? What about 50 cities? Can you guess how long it would take? -You're starting to get a feel for what it means for a problem to be - - intractable - - . -

- - View city trip interactive - +

The following interactive has a program that solves the problem for however many cities you want to select by trying out all possible routes, and recording the best so far. You can get a feel for what an intractable problem looks like by seeing how long the interactive takes to solve the problem for different size maps. +Try generating a map with about 5 cities, and press "Start" to solve the problem.

+Example Code

Now try it for 10 cities (twice as many). Does it take twice as long? How about twice as many again (20 cities)? What about 50 cities? Can you guess how long it would take? +You're starting to get a feel for what it means for a problem to be intractable.

+View city trip interactive diff --git a/verto/tests/assets/button-link/contains_multiple_buttons_expected.html b/verto/tests/assets/button-link/contains_multiple_buttons_expected.html index 56e7adee..6ba4de7c 100644 --- a/verto/tests/assets/button-link/contains_multiple_buttons_expected.html +++ b/verto/tests/assets/button-link/contains_multiple_buttons_expected.html @@ -1,35 +1,10 @@ -

- You can try out this 3D matrix in the following interactive. -

- - Click for interactive: 3D transform matrix - -

- The above image mesh has 3644 points in it, and your matrix was applied to each one of them to work out the new image. -

-

- The next interactive allows you to do translation (using a vector). -Use it to get used to translating in the three dimensions (don't worry about using matrices this time.) -

- - Click for interactive: 3D translation - -

- Rotation is trickier because you can now rotate in different directions. -In 2D rotations were around the centre (origin) of the grid, but in 3D rotations are around a line (either the horizontal x-axis, the vertical y-axis, or the z-axis, which goes into the screen!) -

-

- The 2D rotation we used earlier can be applied to 3 dimensions using this matrix: -

- - Click for interactive: 3D with multiple matrices and vectors - -

- In the above examples, when you have several matrices being applied to every point in the image, a lot of time can be saved by converting the series of matrices and transforms to just one formula that does all of the transforms in one go. The following interactive can do those calculations for you. -

-

- For example, in the following interactive, type in the matrix for doubling the size of an object (put the number 2 instead of 1 on the main diagonal values), then add another matrix that triples the size of the image (3 on the main diagonal). The interactive shows a matrix on the right that combines the two --- does it look right? -

- - Click for interactive: matrix simplifier - +

You can try out this 3D matrix in the following interactive.

+Click for interactive: 3D transform matrix

The above image mesh has 3644 points in it, and your matrix was applied to each one of them to work out the new image.

+

The next interactive allows you to do translation (using a vector). +Use it to get used to translating in the three dimensions (don't worry about using matrices this time.)

+Click for interactive: 3D translation

Rotation is trickier because you can now rotate in different directions. +In 2D rotations were around the centre (origin) of the grid, but in 3D rotations are around a line (either the horizontal x-axis, the vertical y-axis, or the z-axis, which goes into the screen!)

+

The 2D rotation we used earlier can be applied to 3 dimensions using this matrix:

+Click for interactive: 3D with multiple matrices and vectors

In the above examples, when you have several matrices being applied to every point in the image, a lot of time can be saved by converting the series of matrices and transforms to just one formula that does all of the transforms in one go. The following interactive can do those calculations for you.

+

For example, in the following interactive, type in the matrix for doubling the size of an object (put the number 2 instead of 1 on the main diagonal values), then add another matrix that triples the size of the image (3 on the main diagonal). The interactive shows a matrix on the right that combines the two --- does it look right?

+Click for interactive: matrix simplifier diff --git a/verto/tests/assets/button-link/doc_example_basic_usage_expected.html b/verto/tests/assets/button-link/doc_example_basic_usage_expected.html index 87283030..16d4b42f 100644 --- a/verto/tests/assets/button-link/doc_example_basic_usage_expected.html +++ b/verto/tests/assets/button-link/doc_example_basic_usage_expected.html @@ -1,3 +1 @@ - - Visit Google - +Visit Google diff --git a/verto/tests/assets/button-link/doc_example_file_usage_expected.html b/verto/tests/assets/button-link/doc_example_file_usage_expected.html index 78640424..a4373737 100644 --- a/verto/tests/assets/button-link/doc_example_file_usage_expected.html +++ b/verto/tests/assets/button-link/doc_example_file_usage_expected.html @@ -1,3 +1 @@ - - Download Python Sorting Example - +Download Python Sorting Example diff --git a/verto/tests/assets/button-link/doc_example_override_html_expected.html b/verto/tests/assets/button-link/doc_example_override_html_expected.html index 677abcd3..2337fa6d 100644 --- a/verto/tests/assets/button-link/doc_example_override_html_expected.html +++ b/verto/tests/assets/button-link/doc_example_override_html_expected.html @@ -1,3 +1 @@ - - Verto on GitHub - +Verto on GitHub diff --git a/verto/tests/assets/button-link/missing_end_brace_expected.html b/verto/tests/assets/button-link/missing_end_brace_expected.html index 107c4d51..23474043 100644 --- a/verto/tests/assets/button-link/missing_end_brace_expected.html +++ b/verto/tests/assets/button-link/missing_end_brace_expected.html @@ -1,9 +1,3 @@ -

- Try generating a map with about 5 cities, and press "Start" to solve the problem. -

-

- {button-link link="http://www.csfieldguide.org.nz/releases/1.9.9/_static/widgets/tract-tsp-basic-v2.html" text="View city trip interactive" -

-

- Now try it for 10 cities (twice as many). Does it take twice as long? How about twice as many again (20 cities)? What about 50 cities? Can you guess how long it would take? -

+

Try generating a map with about 5 cities, and press "Start" to solve the problem.

+

{button-link link="http://www.csfieldguide.org.nz/releases/1.9.9/_static/widgets/tract-tsp-basic-v2.html" text="View city trip interactive"

+

Now try it for 10 cities (twice as many). Does it take twice as long? How about twice as many again (20 cities)? What about 50 cities? Can you guess how long it would take?

diff --git a/verto/tests/assets/button-link/no_button_expected.html b/verto/tests/assets/button-link/no_button_expected.html index 7c7b7b6f..555d56a7 100644 --- a/verto/tests/assets/button-link/no_button_expected.html +++ b/verto/tests/assets/button-link/no_button_expected.html @@ -1,29 +1,7 @@ -

- Finally, you’re the top layer of the system. You use the program but you will (hopefully) never have to interact with the more complicated parts of the operating system such as driver software, let alone the hardware. In this way, you can use the computer without ever having to worry about these things. -

-

- {image filename="computer-layers.png" alt="The computer can be broken down into multiple layers, starting with the user, then the programs, then the operating system, then finally the hardware." caption="The computer can be broken down into multiple layers, starting with the user, then the programs, then the operating system, then finally the hardware."} -

-

- We call a system like this a - - layered system - - . You can have any number of layers you want but each layer can only communicate with the one directly below it. The operating system can directly access the hardware but a program running on the computer can't. You can use programs but hopefully will never have to access the hardware or the more complex parts of the operating system such as drivers. This again reduces the complexity of the system because each layer only needs to know about the layer directly below it, not any others. -

-

- Each layer in the system needs to provide an interface so that the layer above it can communicate with it. For example, a processor provides a set of instructions to the operating system; the operating system provides commands to programs to create or delete files on the hard drive; a program provides buttons and commands so that you can interact with it. -

-

- One layer knows nothing about the internal workings of the layer below; it only needs to know how to use the layer’s interface. In this way, the complexity of lower layers is completely hidden, or - - abstracted - - . Each layer represents a higher level of abstraction. -

-

- So each layer hides some complexity, so that as we go up the layers things remain manageable. Another advantage of having layers is that we can change one layer without affecting the others, as long as we keep the layer’s interface the same of course. For example, your browser’s code might change but you might never notice as long as the browser still looks and works the same as before. Of course, if the browser stops working or new buttons appear suddenly you know that something has changed. -

-

- Something about a button or more explicitly a button-link that you should not match. -

+

Finally, you’re the top layer of the system. You use the program but you will (hopefully) never have to interact with the more complicated parts of the operating system such as driver software, let alone the hardware. In this way, you can use the computer without ever having to worry about these things.

+

{image filename="computer-layers.png" alt="The computer can be broken down into multiple layers, starting with the user, then the programs, then the operating system, then finally the hardware." caption="The computer can be broken down into multiple layers, starting with the user, then the programs, then the operating system, then finally the hardware."}

+

We call a system like this a layered system. You can have any number of layers you want but each layer can only communicate with the one directly below it. The operating system can directly access the hardware but a program running on the computer can't. You can use programs but hopefully will never have to access the hardware or the more complex parts of the operating system such as drivers. This again reduces the complexity of the system because each layer only needs to know about the layer directly below it, not any others.

+

Each layer in the system needs to provide an interface so that the layer above it can communicate with it. For example, a processor provides a set of instructions to the operating system; the operating system provides commands to programs to create or delete files on the hard drive; a program provides buttons and commands so that you can interact with it.

+

One layer knows nothing about the internal workings of the layer below; it only needs to know how to use the layer’s interface. In this way, the complexity of lower layers is completely hidden, or abstracted. Each layer represents a higher level of abstraction.

+

So each layer hides some complexity, so that as we go up the layers things remain manageable. Another advantage of having layers is that we can change one layer without affecting the others, as long as we keep the layer’s interface the same of course. For example, your browser’s code might change but you might never notice as long as the browser still looks and works the same as before. Of course, if the browser stops working or new buttons appear suddenly you know that something has changed.

+

Something about a button or more explicitly a button-link that you should not match.

diff --git a/verto/tests/assets/comment/comment_contains_comment_expected.html b/verto/tests/assets/comment/comment_contains_comment_expected.html index 40995fc7..d41ea925 100644 --- a/verto/tests/assets/comment/comment_contains_comment_expected.html +++ b/verto/tests/assets/comment/comment_contains_comment_expected.html @@ -1,3 +1 @@ -

- {comment explain different views of algorithm (programming context) and Algorithm (that have interesting complexity) {comment explain different views of algorithm (programming context) and Algorithm (that have interesting complexity)}} -

+

{comment explain different views of algorithm (programming context) and Algorithm (that have interesting complexity) {comment explain different views of algorithm (programming context) and Algorithm (that have interesting complexity)}}

diff --git a/verto/tests/assets/comment/comment_within_block_container_expected.html b/verto/tests/assets/comment/comment_within_block_container_expected.html index 4fc569d0..aab01af9 100644 --- a/verto/tests/assets/comment/comment_within_block_container_expected.html +++ b/verto/tests/assets/comment/comment_within_block_container_expected.html @@ -1,12 +1,8 @@
-
- - Lipsum Lorem - -
-
-

- Should be the only text left. -

-
+
+Lipsum Lorem +
+
+

Should be the only text left.

+
diff --git a/verto/tests/assets/comment/contains_multiple_inline_comments_expected.html b/verto/tests/assets/comment/contains_multiple_inline_comments_expected.html index d439a9c9..5121572f 100644 --- a/verto/tests/assets/comment/contains_multiple_inline_comments_expected.html +++ b/verto/tests/assets/comment/contains_multiple_inline_comments_expected.html @@ -1,3 +1 @@ -

- Some intermediary text. -

+

Some intermediary text.

diff --git a/verto/tests/assets/comment/doc_example_multiple_usage_expected.html b/verto/tests/assets/comment/doc_example_multiple_usage_expected.html index 76d9ed49..7c6dc546 100644 --- a/verto/tests/assets/comment/doc_example_multiple_usage_expected.html +++ b/verto/tests/assets/comment/doc_example_multiple_usage_expected.html @@ -1,9 +1,3 @@ -

- Finally add a teaspoon of salt and tumeric. -

-

- Combine and mix ingredients in a large bowl. -

-

- Bake at 180C for 40 minutes. -

+

Finally add a teaspoon of salt and tumeric.

+

Combine and mix ingredients in a large bowl.

+

Bake at 180C for 40 minutes.

diff --git a/verto/tests/assets/comment/no_inline_comment_expected.html b/verto/tests/assets/comment/no_inline_comment_expected.html index 0112f398..fa9fcac2 100644 --- a/verto/tests/assets/comment/no_inline_comment_expected.html +++ b/verto/tests/assets/comment/no_inline_comment_expected.html @@ -1,8 +1,4 @@ -

- In this chapter we'll look at what typically makes good and bad interfaces. The idea is to make you sensitive to the main issues so that you can critique existing interfaces, and begin to think about how you might design good interfaces. -

-

- Often software developers create a computer program or system for a device that requires the user to spend some time to learn how to use. +

In this chapter we'll look at what typically makes good and bad interfaces. The idea is to make you sensitive to the main issues so that you can critique existing interfaces, and begin to think about how you might design good interfaces.

+

Often software developers create a computer program or system for a device that requires the user to spend some time to learn how to use. The interface might be easy to use for the developer since they know the system really well, but a user just wants to get the job done without spending too much time learning the software (and they might switch to another program if it's too hard to use). -A developer might think of the program and the user separately, but the user is part of the system, and a developer needs to create the software with the user in mind, designing a program that they will find easy to use and intuitive. -

+A developer might think of the program and the user separately, but the user is part of the system, and a developer needs to create the software with the user in mind, designing a program that they will find easy to use and intuitive.

diff --git a/verto/tests/assets/comment/text_contains_the_word_comment_expected.html b/verto/tests/assets/comment/text_contains_the_word_comment_expected.html index 10936821..cde827f1 100644 --- a/verto/tests/assets/comment/text_contains_the_word_comment_expected.html +++ b/verto/tests/assets/comment/text_contains_the_word_comment_expected.html @@ -1,17 +1,7 @@ -

- Now go back and have another conversation with Eliza. There are many other examples of Eliza saying stuff that makes no sense such as the above dialogue. How many can you find? In addition, how does Eliza respond when you do the following things? -

+

Now go back and have another conversation with Eliza. There are many other examples of Eliza saying stuff that makes no sense such as the above dialogue. How many can you find? In addition, how does Eliza respond when you do the following things?

    -
  • - Try being a "parrot" that just copies everything Eliza says. -
  • -
  • - What happens when you don’t give meaningful answers to her questions? -
  • -
  • - If you say the same thing you said earlier in the conversation, does Eliza always respond in the same way? (When you say it immediately after, she probably won’t, as she’ll comment on the fact that you repeated yourself the second time!) -
  • -
  • - What happens when you talk about things that are unrelated to what would be said in a therapy session, i.e. you try to have a general conversation with Eliza (remember that Eliza works in a restricted domain, i.e. she assumes she is a therapist). -
  • +
  • Try being a "parrot" that just copies everything Eliza says.
  • +
  • What happens when you don’t give meaningful answers to her questions?
  • +
  • If you say the same thing you said earlier in the conversation, does Eliza always respond in the same way? (When you say it immediately after, she probably won’t, as she’ll comment on the fact that you repeated yourself the second time!)
  • +
  • What happens when you talk about things that are unrelated to what would be said in a therapy session, i.e. you try to have a general conversation with Eliza (remember that Eliza works in a restricted domain, i.e. she assumes she is a therapist).
diff --git a/verto/tests/assets/conditional/doc_example_basic_usage_expected.html b/verto/tests/assets/conditional/doc_example_basic_usage_expected.html index 9796b655..fda33feb 100644 --- a/verto/tests/assets/conditional/doc_example_basic_usage_expected.html +++ b/verto/tests/assets/conditional/doc_example_basic_usage_expected.html @@ -1,5 +1,3 @@ {% if version == 'teacher' %} -

- This is text that only teachers should see. -

+

This is text that only teachers should see.

{% endif %} diff --git a/verto/tests/assets/conditional/doc_example_complex_usage_expected.html b/verto/tests/assets/conditional/doc_example_complex_usage_expected.html index 97cda7a1..fe747c39 100644 --- a/verto/tests/assets/conditional/doc_example_complex_usage_expected.html +++ b/verto/tests/assets/conditional/doc_example_complex_usage_expected.html @@ -1,17 +1,9 @@ {% if version == 'teacher' %} -

- This is text that only teachers should see. -

+

This is text that only teachers should see.

{% elif version == 'instructor' %} -

- This is text that only instuctors should see. -

+

This is text that only instuctors should see.

{% elif version == 'coordinator' %} -

- This is text that only coordinators should see. -

+

This is text that only coordinators should see.

{% else %} -

- This is text that everyone else should see. -

+

This is text that everyone else should see.

{% endif %} diff --git a/verto/tests/assets/conditional/doc_example_override_html_expected.html b/verto/tests/assets/conditional/doc_example_override_html_expected.html index b2058613..581406d2 100644 --- a/verto/tests/assets/conditional/doc_example_override_html_expected.html +++ b/verto/tests/assets/conditional/doc_example_override_html_expected.html @@ -1,13 +1,7 @@ % if version == 'teacher': -

- This is text that only teachers should see. -

+

This is text that only teachers should see.

% elif version == 'instructor': -

- This is text that only instuctors should see. -

+

This is text that only instuctors should see.

% elif version == 'coordinator': -

- This is text that only coordinators should see. -

+

This is text that only coordinators should see.

% endif diff --git a/verto/tests/assets/conditional/example_basic_else_usage_expected.html b/verto/tests/assets/conditional/example_basic_else_usage_expected.html index 9c5330df..ee818a9e 100644 --- a/verto/tests/assets/conditional/example_basic_else_usage_expected.html +++ b/verto/tests/assets/conditional/example_basic_else_usage_expected.html @@ -1,9 +1,5 @@ {% if version == 'teacher' %} -

- This is text that only teachers should see. -

+

This is text that only teachers should see.

{% else %} -

- This is text that everyone else should see. -

+

This is text that everyone else should see.

{% endif %} diff --git a/verto/tests/assets/conditional/example_elif_no_else_expected.html b/verto/tests/assets/conditional/example_elif_no_else_expected.html index 3d6a8c65..ef1ecaac 100644 --- a/verto/tests/assets/conditional/example_elif_no_else_expected.html +++ b/verto/tests/assets/conditional/example_elif_no_else_expected.html @@ -1,5 +1,5 @@