diff --git a/README.rst b/README.rst index fbeb35b1..0fcacbae 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,6 @@ |Verto Image| -|Build Status| |Code Climate Status| +|Build Status| Verto is an extension of the Python Markdown package, which allows authors to include complex HTML elements with simple text tags in their @@ -82,10 +82,6 @@ The changelog is available within the `documentation`_. .. |Build Status| image:: https://travis-ci.org/uccser/verto.svg?branch=master :target: https://travis-ci.org/uccser/verto -.. |Code Climate Status| image:: https://codeclimate.com/github/uccser/verto/badges/gpa.svg - :target: https://codeclimate.com/github/uccser/verto - :alt: Code Climate - .. |Verto Image| image:: https://raw.githubusercontent.com/uccser/verto/master/verto/images/verto-logo.png :target: https://github.com/uccser/verto :alt: Verto GitHub diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 285f5598..e6a65c22 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -1,26 +1,43 @@ Changelog ####################################### +0.7.0 +======================================= + +Fixes: + +- :doc:`processors/relative-link` processor will now handle query parameters. +- Modify :doc:`processors/panel` processor for translating subtitles, by requiring subtitle text as second level heading. +- Modify :doc:`processors/image` processor for translating captions, by requiring caption text between start and end tags. +- Modify :doc:`processors/image` processor to allow finer control of output, in particular when dealing with image with width values. +- Add new tag configuration value ``tag_argument`` to override tag name. +- Dependency updates: + + - Update ``markdown`` to 2.6.10. + - Update ``Jinja2`` to 2.10. + - Update ``setuptools`` to 38.2.5. + - Update ``sphinx`` to 1.6.5. + 0.6.1 ======================================= Fixes: - - Adds all interactives to required files. - - Typo in Interactive documentation. +- Adds all interactives to required files. +- Typo in interactive tag documentation. 0.6.0 ======================================= Features: - - Added :doc:`processors/image-inline` processor, intended for use in tables. - - Added :doc:`processors/scratch-inline` processor for inline scratch support. +- Added :doc:`processors/image-inline` processor, intended for use in tables. +- Added :doc:`processors/scratch-inline` processor for inline scratch support. Fixes: - - Removed ``beautifulsoup4`` dependency. - - Typo in VertoResult documentation (*heading_root* -> *heading_tree*). +- Removed ``beautifulsoup4`` dependency. +- Typo in VertoResult documentation (*heading_root* -> *heading_tree*). 0.5.3 ======================================= @@ -29,46 +46,46 @@ In this hotfix Verto result data for unique identifiers and required files is no Fixes: - - Remove implicit Beautify processor, fixing white-spacing issues. - - All terms are added to glossary correctly now. +- Remove implicit Beautify processor, fixing white-spacing issues. +- All terms are added to glossary correctly now. 0.5.2 ======================================= Fixes: - - Verto container tags, are now supported in markdown lists. +- Verto container tags, are now supported in markdown lists. 0.5.1 ======================================= Fixes: - - Verto tags and custom tags, are now support embedding into markdown lists. +- Verto tags and custom tags, are now support embedding into markdown lists. 0.5.0 ======================================= Fixes: - - A new more descriptive error when an argument is given and not readable. - - Custom HTML string parsing has been implemented, allowing for correct parsing of HTML and XHTML in templates. +- A new more descriptive error when an argument is given and not readable. +- Custom HTML string parsing has been implemented, allowing for correct parsing of HTML and XHTML in templates. Documentation: - - Basic example in README. - - New contributing documentation. - - Fixed reference to incorrect file in the image processor documentation. - - Added new documentation for implicit processors. +- Basic example in README. +- New contributing documentation. +- Fixed reference to incorrect file in the image processor documentation. +- Added new documentation for implicit processors. 0.4.1 ======================================= Fixes: - - pypi configuration fixes. - - pyup configuration to use develop branch. - - Improved asset file loading for deployed package. +- pypi configuration fixes. +- pyup configuration to use develop branch. +- Improved asset file loading for deployed package. 0.4.0 ======================================= @@ -78,21 +95,21 @@ Fourth prerelease of the Verto converter. Adds support for the following processors: - - :doc:`processors/iframe` - - :doc:`processors/interactive` - - :doc:`processors/heading` - - :doc:`processors/scratch` - - :doc:`processors/table-of-contents` +- :doc:`processors/iframe` +- :doc:`processors/interactive` +- :doc:`processors/heading` +- :doc:`processors/scratch` +- :doc:`processors/table-of-contents` Features: - - The :doc:`processors/scratch` processor supports ``split`` and ``random`` options. +- The :doc:`processors/scratch` processor supports ``split`` and ``random`` options. Fixes: - - Scratch blocks work with other extensions. - - Glossary slugs are now added to the output of Verto. - - Processors are now ordered correctly. +- Scratch blocks work with other extensions. +- Glossary slugs are now added to the output of Verto. +- Processors are now ordered correctly. 0.3.1 @@ -100,7 +117,7 @@ Fixes: Fixes: - - Updated documentation and changelog. +- Updated documentation and changelog. 0.3.0 ======================================= @@ -109,17 +126,17 @@ Third prerelease of the Verto converter. Adds support for the following processors: - - :doc:`processors/heading` - - :doc:`processors/iframe` - - :doc:`processors/interactive` - - :doc:`processors/scratch` - - :doc:`processors/table-of-contents` +- :doc:`processors/heading` +- :doc:`processors/iframe` +- :doc:`processors/interactive` +- :doc:`processors/scratch` +- :doc:`processors/table-of-contents` Fixes: - - Verto now orders tags correctly in the markdown pipeline. - - System tests for multiple calls to Verto and for multi-line templates. - - Glossary tags now correctly store slugs for the Verto result as per documentation. +- Verto now orders tags correctly in the markdown pipeline. +- System tests for multiple calls to Verto and for multi-line templates. +- Glossary tags now correctly store slugs for the Verto result as per documentation. 0.2.0 ======================================= diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index 49f390d1..0aac7bbb 100644 --- a/docs/source/contributing.rst +++ b/docs/source/contributing.rst @@ -152,6 +152,7 @@ The json description of a generic processor must contain the attributes: - ``arguments``: An object describing arguments passed to the tag. - ``template_parameters``: An object describing template parameters. - (Optional) ``template_name``: A custom name for the html-template to use. Defaults to the processor name otherwise. + - (Optional) ``tag_argument``: The text given at the beginning of a tag (e.g. the tag argument for ``{image file-path="example.png"}`` is ``image``). This is only necessary for processors with different names sharing the same resources (e.g. both ``image-container`` and ``image-tag`` share the ``tag_argument``). The ``argument`` parameter is a dictionary (or object) containing argument name, argument-info pairs. Where the argument-info contains the attributes: @@ -161,7 +162,7 @@ The ``argument`` parameter is a dictionary (or object) containing argument name, These arguments are transformed for use in the html-template by the ``template_parameters`` attribute. This attribute is similar to the ``argument`` attribute by containing parameter name, parameter-info pairs. Where the parameter-info contains the attributes: - - ``argument``: The name of the argument to retrieve the value of to use/transform into the parameter value. + - ``argument``: The name of the argument to retrieve the value of to use/transform into the parameter value. - (Optional) ``default``: The value the parameter defaults to if the argument is not given otherwise defaults to ``None``. - (Optional) ``transform``: The name of the transform to modify the argument value by or defaults to null for no transformation. The avaliable transforms are detailed below. - (Optional) ``transform_condition``: A function that takes the context after parameters are set but before transformation (The transformations are done in order they appear in the json document). If the function returns ``True`` then the transformation is applied. diff --git a/docs/source/processors/image-inline.rst b/docs/source/processors/image-inline.rst index a30fff53..b54ba2cc 100644 --- a/docs/source/processors/image-inline.rst +++ b/docs/source/processors/image-inline.rst @@ -49,30 +49,53 @@ Overriding HTML for Images When overriding the HTML for images, the following Jinja2 placeholders are available: -- ``{{ file_path }}`` - The location for the path to the URL. +- ``{{ full_file_path }}`` - The location for the path to the URL. - ``{{ alt }}`` - The alternative text for the image. - ``{{ hover_text }}`` - The text to display when the user hovers over the image (see `image title attribute `_). - ``{{ caption }}`` - The text for the image caption. - ``{{ caption_link }}`` - The URL for the caption link . - ``{{ source_link }}`` - The URL for the source . +- ``{{ file_relative }}`` - If the ``full_file_path`` is a relative link, this is the boolean value ``True``, otherwise ``False``. -If the ``file_path`` provided is a relative link, the link is passed through the ``relative-file-link.html`` template. -The default HTML for relative images is: + If ``{{ file_relative }}`` is ``True``, the following placeholders are also available to allow finer control of output of relative images (see *Example 2* below): -.. literalinclude:: ../../../verto/html-templates/relative-file-link.html - :language: css+jinja + - ``{{ file_path }}`` - The file path of the image, with file extension removed. + - ``{{ file_extension }}`` - The file extension for the image. + - ``{{ file_width_value }}`` - If the file name of the image ends in a width suffix (for example: ``apple@200px.png``), this is the numerical width value as an integer (in the example before: ``200``). + - ``{{ file_width_unit }}`` - If the file name of the image ends in a width suffix (for example: ``apple@200px.png``), this is the width unit (in the example before: ``px``). + +**Example 1** For example, providing the following HTML: .. literalinclude:: ../../../verto/tests/assets/image-inline/doc_example_override_html_template.html - :language: css+jinja + :language: css+jinja with the following tag: .. literalinclude:: ../../../verto/tests/assets/image-inline/doc_example_override_html.md - :language: none + :language: none would result in: .. literalinclude:: ../../../verto/tests/assets/image-inline/doc_example_override_html_expected.html - :language: html + :language: html + +**Example 2** + +This is an example of using the ``scrset`` attribute for relative images. + +The following HTML for ``image.html``: + +.. literalinclude:: ../../../verto/tests/assets/image-inline/doc_example_2_override_html_template.html + :language: css+jinja + +with the following tag: + +.. literalinclude:: ../../../verto/tests/assets/image-inline/doc_example_2_override_html.md + :language: none + +would result in: + +.. literalinclude:: ../../../verto/tests/assets/image-inline/doc_example_2_override_html_expected.html + :language: html diff --git a/docs/source/processors/image.rst b/docs/source/processors/image.rst index 2ac1eac7..f1b55d3e 100644 --- a/docs/source/processors/image.rst +++ b/docs/source/processors/image.rst @@ -1,13 +1,27 @@ Image ####################################### -**Processor name:** ``image`` +**Processor name:** ``image-tag`` and ``image-container`` You can include an image using the following text tag: .. code-block:: none - {image file-path="http://placehold.it/350x150"} + {image file-path="http://placehold.it/350x150" caption="true"} + + This is the caption text. + + {image end} + +The caption is the first block of text within the image block. +It is within the block rather than given as a parameter to allow translation systems to easily identify which text should be translated. + +If a caption is not needed, an end tag is not required (see example below). + +.. code-block:: none + + {image file-path="http://placehold.it/350x150" caption="false"} + Required Tag Parameters *************************************** @@ -21,10 +35,17 @@ Optional Tag Parameters *************************************** - ``alt`` - Description text of the image used when an image is not displayed, or can be read when using a screen reader (for those with reading difficulties). -- ``caption`` - Lists the given text as a caption under the image. + +- ``caption`` - Boolean flag to indicate whether the image should display a caption. + + - If given as ``true``, the the subtitle is the first block of text with the image block. + - ``caption-link`` (requires caption parameter) - Converts the caption text into a link to the given caption link URL. + - ``source`` (optional) - Adds the text 'Source' under the image with a link to the given source URL. Displays after the caption if a caption is given. + - ``alignment`` - Valid values are 'left', 'center', or 'right'. Providing one of these values Will add CSS classes to the image for alignment. + - ``hover-text`` - Additional text to be displayed when the user hovers their cursor over the image (note this won't appear on touch devices so use sparingly). The default HTML for image is: @@ -34,12 +55,12 @@ The default HTML for image is: Using the following example tag: -.. literalinclude:: ../../../verto/tests/assets/image/doc_example_basic_usage.md +.. literalinclude:: ../../../verto/tests/assets/image-tag/doc_example_basic_usage.md :language: none The resulting HTML would be: -.. literalinclude:: ../../../verto/tests/assets/image/doc_example_basic_usage_expected.html +.. literalinclude:: ../../../verto/tests/assets/image-tag/doc_example_basic_usage_expected.html :language: html Overriding HTML for Images @@ -47,57 +68,54 @@ Overriding HTML for Images When overriding the HTML for images, the following Jinja2 placeholders are available: -- ``{{ file_path }}`` - The location for the path to the URL. +- ``{{ full_file_path }}`` - The location for the path to the URL. - ``{{ alt }}`` - The alternative text for the image. - ``{{ hover_text }}`` - The text to display when the user hovers over the image (see `image title attribute `_). - ``{{ alignment }}`` - The location to add extra CSS classes for alignment. - ``{{ caption }}`` - The text for the image caption. - ``{{ caption_link }}`` - The URL for the caption link . - ``{{ source_link }}`` - The URL for the source . +- ``{{ file_relative }}`` - If the ``full_file_path`` is a relative link, this is the boolean value ``True``, otherwise ``False``. -If the ``file_path`` provided is a relative link, the link is passed through the ``relative-file-link.html`` template. -The default HTML for relative images is: + If ``{{ file_relative }}`` is ``True``, the following placeholders are also available to allow finer control of output of relative images (see *Example 2* below): -.. literalinclude:: ../../../verto/html-templates/relative-file-link.html - :language: css+jinja + - ``{{ file_path }}`` - The file path of the image, with file extension removed. + - ``{{ file_extension }}`` - The file extension for the image. + - ``{{ file_width_value }}`` - If the file name of the image ends in a width suffix (for example: ``apple@200px.png``), this is the numerical width value as an integer (in the example before: ``200``). + - ``{{ file_width_unit }}`` - If the file name of the image ends in a width suffix (for example: ``apple@200px.png``), this is the width unit (in the example before: ``px``). **Example 1** For example, providing the following HTML: -.. literalinclude:: ../../../verto/tests/assets/image/doc_example_override_html_template.html - :language: css+jinja +.. literalinclude:: ../../../verto/tests/assets/image-tag/doc_example_override_html_template.html + :language: css+jinja with the following tag: -.. literalinclude:: ../../../verto/tests/assets/image/doc_example_override_html.md - :language: none +.. literalinclude:: ../../../verto/tests/assets/image-tag/doc_example_override_html.md + :language: none would result in: -.. literalinclude:: ../../../verto/tests/assets/image/doc_example_override_html_expected.html - :language: html +.. literalinclude:: ../../../verto/tests/assets/image-tag/doc_example_override_html_expected.html + :language: html **Example 2** -If you know all relative images are located within a specific folder, you could change the ``relative-file-link.html`` template. +This is an example of using the ``scrset`` attribute for relative images. -For example, providing the following HTML for ``image.html``: +The following HTML for ``image.html``: -.. literalinclude:: ../../../verto/tests/assets/image/doc_example_2_override_html_template.html - :language: css+jinja - -and providing the following HTML for ``relative-file-link.html``: - -.. literalinclude:: ../../../verto/tests/assets/image/doc_example_2_override_link_html_template.html - :language: css+jinja +.. literalinclude:: ../../../verto/tests/assets/image-tag/doc_example_2_override_html_template.html + :language: css+jinja with the following tag: -.. literalinclude:: ../../../verto/tests/assets/image/doc_example_2_override_html.md - :language: none +.. literalinclude:: ../../../verto/tests/assets/image-tag/doc_example_2_override_html.md + :language: none would result in: -.. literalinclude:: ../../../verto/tests/assets/image/doc_example_2_override_html_expected.html - :language: html +.. literalinclude:: ../../../verto/tests/assets/image-tag/doc_example_2_override_html_expected.html + :language: html diff --git a/docs/source/processors/panel.rst b/docs/source/processors/panel.rst index b7efc6ac..ac9c5649 100644 --- a/docs/source/processors/panel.rst +++ b/docs/source/processors/panel.rst @@ -8,6 +8,9 @@ You can include an panel using the following text tag: .. literalinclude:: ../../../verto/tests/assets/panel/doc_example_basic_usage.md :language: none +The title and subtitle are the first Level 1 and Level 2 Headings within the panel. +They are within the panel rather than given as parameters to allow translation systems to easily identify which text should be translated. + Required Tag Parameters *************************************** @@ -15,12 +18,13 @@ Required Tag Parameters - The type is saved as a CCS class (with ``panel-`` prefix) in the panel (this allows colouring of all the same types of panels). -- ``title`` - Text to display as the panel's title. - Optional Tag Parameters *************************************** -- ``subtitle`` - Text to display as the panel's subtitle after the title. +- ``subtitle`` - Boolean flag to indicate whether the panel should display a subtitle. + + - If given as ``true``, then the subtitle is the first Level 2 Heading within the panel. + - ``expanded`` - A value to state the panel's state: - If given as 'true', the panel contains the CSS class ``panel-expanded`` to state it should be expanded on load. diff --git a/docs/source/processors/relative-link.rst b/docs/source/processors/relative-link.rst index 91b265ab..52e6ad38 100644 --- a/docs/source/processors/relative-link.rst +++ b/docs/source/processors/relative-link.rst @@ -27,6 +27,7 @@ Overriding HTML for Relative Links When overriding the HTML for relative links, the following Jinja2 placeholders are available: - ``{{ link_path }}`` - The given link URL. +- ``{{ link_query }}`` - The given link query parameters. **Example** diff --git a/requirements.txt b/requirements.txt index 49eaeb7c..d79b89a3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,9 @@ # Required dependencies for Verto (installed automatically in setup.py) -markdown==2.6.8 -Jinja2==2.9.6 +markdown==2.6.10 +Jinja2==2.10 python-slugify==1.2.4 -setuptools==36.0.1 +setuptools==38.2.5 # Required dependencies for building documentation -sphinx==1.6.2 +sphinx==1.6.5 sphinx_rtd_theme==0.2.4 diff --git a/verto/Verto.py b/verto/Verto.py index 0cec7e09..1f572dec 100644 --- a/verto/Verto.py +++ b/verto/Verto.py @@ -10,7 +10,8 @@ 'style', 'heading', 'iframe', - 'image', + 'image-container', + 'image-tag', 'image-inline', 'interactive', 'panel', diff --git a/verto/VertoExtension.py b/verto/VertoExtension.py index 284a0b5a..9241d422 100644 --- a/verto/VertoExtension.py +++ b/verto/VertoExtension.py @@ -4,7 +4,8 @@ from verto.processors.CommentPreprocessor import CommentPreprocessor from verto.processors.VideoBlockProcessor import VideoBlockProcessor from verto.processors.ImageInlinePattern import ImageInlinePattern -from verto.processors.ImageBlockProcessor import ImageBlockProcessor +from verto.processors.ImageTagBlockProcessor import ImageTagBlockProcessor +from verto.processors.ImageContainerBlockProcessor import ImageContainerBlockProcessor from verto.processors.InteractiveBlockProcessor import InteractiveBlockProcessor from verto.processors.RelativeLinkPattern import RelativeLinkPattern from verto.processors.RemoveTitlePreprocessor import RemoveTitlePreprocessor @@ -21,6 +22,7 @@ from verto.processors.ScratchCompatibilityPreprocessor import FENCED_BLOCK_RE_OVERRIDE from verto.processors.GenericTagBlockProcessor import GenericTagBlockProcessor from verto.processors.GenericContainerBlockProcessor import GenericContainerBlockProcessor +from verto.processors.PanelBlockProcessor import PanelBlockProcessor from verto.utils.UniqueSlugify import UniqueSlugify from verto.utils.HeadingNode import HeadingNode @@ -105,15 +107,13 @@ def update_processors(processors, markdown_processors): md.parser.blockprocessors['olist'] = OListProcessor(md.parser) md.parser.blockprocessors['ulist'] = UListProcessor(md.parser) - if ('fenced_code_block' in self.compatibility - and 'scratch' in self.processors): - md.preprocessors['fenced_code_block'].FENCED_BLOCK_RE = FENCED_BLOCK_RE_OVERRIDE + if ('fenced_code_block' in self.compatibility and 'scratch' in self.processors): + md.preprocessors['fenced_code_block'].FENCED_BLOCK_RE = FENCED_BLOCK_RE_OVERRIDE - if ('hilite' in self.compatibility - and 'fenced_code_block' in self.compatibility - and 'scratch' in self.processors): - processor = ScratchCompatibilityPreprocessor(self, md) - md.preprocessors.add('scratch-compatibility', processor, ' - {% if caption and caption_link -%} diff --git a/verto/html-templates/image.html b/verto/html-templates/image.html index b9f4013d..fc4c5bfa 100644 --- a/verto/html-templates/image.html +++ b/verto/html-templates/image.html @@ -1,5 +1,12 @@
- diff --git a/verto/html-templates/relative-link.html b/verto/html-templates/relative-link.html index 5a99930a..1c7d83a0 100644 --- a/verto/html-templates/relative-link.html +++ b/verto/html-templates/relative-link.html @@ -1 +1 @@ -{{ text }} +{{ text }} diff --git a/verto/processor-info.json b/verto/processor-info.json index 3a34f88a..a576de53 100644 --- a/verto/processor-info.json +++ b/verto/processor-info.json @@ -120,9 +120,11 @@ } } }, - "image": { + "image-tag": { "class": "custom", - "pattern": "(^|\\n) *\\{image (?P[^\\}]*)\\} *(\\n|$)", + "pattern": "(^|\\n) *\\{image (?P[^\\}]*)?(?Pcaption=\"true\")(?P[^\\}]*)?\\} *(\\n|$)", + "tag_argument": "image", + "template_name": "image", "arguments": { "file-path": { "required": true, @@ -133,9 +135,86 @@ "dependencies": [] }, "caption": { + "required": false, + "dependencies": [], + "values": ["true", "false"] + }, + "caption-link": { + "required": false, + "dependencies": ["caption"] + }, + "source": { "required": false, "dependencies": [] }, + "alignment": { + "required": false, + "dependencies": [], + "values": ["left", "center", "right"] + }, + "hover-text": { + "required": false, + "dependencies": [] + } + }, + "template_parameters": { + "full_file_path": { + "argument": "full_file_path" + }, + "file_path": { + "argument": "file_path" + }, + "file_width_value": { + "argument": "file_width_value" + }, + "file_width_unit": { + "argument": "file_width_unit" + }, + "file_extension": { + "argument": "file_extension" + }, + "file_relative": { + "argument": "file_relative" + }, + "alt": { + "argument": "alt" + }, + "caption": { + "argument": "caption" + }, + "caption_link": { + "argument": "caption-link" + }, + "source_link": { + "argument": "source" + }, + "alignment": { + "argument": "alignment" + }, + "hover_text": { + "argument": "hover-text" + } + } + }, + "image-container": { + "class": "custom", + "pattern": "(^|\\n) *\\{image (?P[^\\}]*)?(?Pcaption=\"true\")(?P[^\\}]*)?\\} *(\\n|$)", + "tag_argument": "image", + "template_name": "image", + "arguments": { + "file-path": { + "required": true, + "dependencies": [] + }, + "alt": { + "required": false, + "dependencies": [] + }, + "caption": { + "required": false, + "dependencies": [], + "values": ["true", "false"] + }, "caption-link": { "required": false, "dependencies": ["caption"] @@ -153,6 +232,44 @@ "required": false, "dependencies": [] } + }, + "template_parameters": { + "full_file_path": { + "argument": "full_file_path" + }, + "file_path": { + "argument": "file_path" + }, + "file_width_value": { + "argument": "file_width_value" + }, + "file_width_unit": { + "argument": "file_width_unit" + }, + "file_extension": { + "argument": "file_extension" + }, + "file_relative": { + "argument": "file_relative" + }, + "alt": { + "argument": "alt" + }, + "caption": { + "argument": "caption" + }, + "caption_link": { + "argument": "caption-link" + }, + "source_link": { + "argument": "source" + }, + "alignment": { + "argument": "alignment" + }, + "hover_text": { + "argument": "hover-text" + } } }, "image-inline": { @@ -212,16 +329,14 @@ } }, "panel": { - "class": "generic_container", + "class": "custom", "arguments": { "type": { "required": true }, - "title": { - "required": true - }, "subtitle": { - "required": false + "required": false, + "values": ["true", "false"] }, "expanded": { "required": false, @@ -253,7 +368,7 @@ }, "relative-link": { "class": "custom", - "pattern": "\\[(?P[^\\]]+)\\]\\((?!(https?|ftps?|mailto|news):)(?P[^\\)]+)\\)" + "pattern": "\\[(?P[^\\]]+)\\]\\((?!(https?|ftps?|mailto|news):)(?P[^\\?\\)]+)(?P\\?[^\\)]*)?\\)" }, "scratch": { "class": "custom", diff --git a/verto/processors/ConditionalProcessor.py b/verto/processors/ConditionalProcessor.py index e02e87d9..38b13199 100644 --- a/verto/processors/ConditionalProcessor.py +++ b/verto/processors/ConditionalProcessor.py @@ -103,8 +103,7 @@ def run(self, parent, blocks): context['has_else'] = has_else context['else_content'] = else_content - if (next_tag is None - or (next_tag is not None and not parse_flag('end', next_tag.group('args')))): + if (next_tag is None or (next_tag is not None and not parse_flag('end', next_tag.group('args')))): msg = 'end conditional not found' raise TagNotMatchedError(self.processor, block, msg) diff --git a/verto/processors/GenericContainerBlockProcessor.py b/verto/processors/GenericContainerBlockProcessor.py index 1843ae25..25247898 100644 --- a/verto/processors/GenericContainerBlockProcessor.py +++ b/verto/processors/GenericContainerBlockProcessor.py @@ -15,10 +15,11 @@ def __init__(self, processor, ext, *args, **kwargs): ''' super().__init__(*args, **kwargs) self.processor = processor - self.p_start = re.compile(r'(^|\n) *\{{{0} ?(?P[^\}}]*)(?[^\}}]*)(? end_tag.start())): + if ((start_tag is None and end_tag is not None) or + (start_tag and end_tag and start_tag.end() > end_tag.start())): raise TagNotMatchedError(self.processor, block, 'end tag found before start tag') before = block[:start_tag.start()] @@ -75,8 +80,7 @@ def run(self, parent, blocks): inner_tag = self.p_start.search(block) end_tag = self.p_end.search(block) - if ((inner_tag and end_tag is None) - or (inner_tag and end_tag and inner_tag.start() < end_tag.end())): + if ((inner_tag and end_tag is None) or (inner_tag and end_tag and inner_tag.start() < end_tag.end())): inner_start_tags += 1 if end_tag and inner_start_tags == inner_end_tags: @@ -88,6 +92,9 @@ def run(self, parent, blocks): end_tag = None content_blocks.append(block) + content_blocks, extra_args = self.custom_parsing(content_blocks, argument_values) + argument_values.update(extra_args) + if the_rest.strip() != '': blocks.insert(0, the_rest) @@ -113,3 +120,17 @@ def run(self, parent, blocks): parser = HtmlParser() parser.feed(html_string).close() parent.append(parser.get_root()) + + def custom_parsing(self, content_blocks, argument_values): + ''' + This serves as a placeholder method, to be used by processes that use the + GenericContainerBlockProcessor but need to carry out further parsing of + the block's contents. + + Args: + content_blocks: List of strings to either be parsed or inserted as content in template. + argument_values: Dictionary of values to be inserted in template. + Returns: + Tuple containing content_blocks (unchanged) and empty dictionary. + ''' + return (content_blocks, {}) diff --git a/verto/processors/GenericTagBlockProcessor.py b/verto/processors/GenericTagBlockProcessor.py index dda305fb..ff8587d6 100644 --- a/verto/processors/GenericTagBlockProcessor.py +++ b/verto/processors/GenericTagBlockProcessor.py @@ -15,9 +15,10 @@ def __init__(self, processor, ext, *args, **kwargs): ''' super().__init__(*args, **kwargs) self.processor = processor - self.pattern = re.compile(r'(^|\n) *\{{{0} ?(?P[^\}}]*)\}} *(\n|$)'.format(self.processor)) + tag_argument = ext.processor_info[self.processor].get('tag_argument', self.processor) + self.pattern = re.compile(r'(^|\n) *\{{{0} ?(?P[^\}}]*)(?"} - adding any internal images to the verto extension final result. - ''' - - def __init__(self, ext, *args, **kwargs): - ''' - Args: - ext: The parent node of the element tree that children will - reside in. - ''' - super().__init__('image', ext, *args, **kwargs) - self.pattern = re.compile(ext.processor_info[self.processor]['pattern']) - self.relative_image_template = ext.jinja_templates['relative-file-link'] - self.required = ext.required_files['images'] - - def test(self, parent, block): - ''' Tests a block to see if the run method should be applied. - - Args: - parent: The parent node of the element tree that children - will reside in. - block: The block to be tested. - Returns: - True if the block matches the pattern regex of a HeadingBlock. - ''' - return self.pattern.search(block) is not None - - def run(self, parent, blocks): - ''' Processes the block matching the image pattern, adding - any internal images to the VertoExtension result. - - Args: - parent: The parent node of the element tree that children - will reside in. - blocks: A list of strings of the document, where the - first block tests true. - ''' - block = blocks.pop(0) - - match = self.pattern.match(block) - before = block[:match.start()] - after = block[match.end():] - - if before.strip() != '': - self.parser.parseChunk(parent, before) - if after.strip() != '': - blocks.insert(0, after) - - arguments = match.group('args') - argument_values = parse_arguments(self.processor, arguments, self.arguments) - - # check if internal or external image - file_path = argument_values['file-path'] - external_path_match = re.search(r'^http', file_path) - if external_path_match is None: # internal image - self.required.add(file_path) - file_path = self.relative_image_template.render({'file_path': file_path}) - - context = dict() - context['file_path'] = file_path - context['alt'] = argument_values.get('alt', None) - context['caption'] = argument_values.get('caption', None) - context['caption_link'] = argument_values.get('caption-link', None) - context['source_link'] = argument_values.get('source', None) - context['alignment'] = argument_values.get('alignment', None) - context['hover_text'] = argument_values.get('hover-text', None) - - html_string = self.template.render(context) - parser = HtmlParser() - parser.feed(html_string).close() - parent.append(parser.get_root()) diff --git a/verto/processors/ImageContainerBlockProcessor.py b/verto/processors/ImageContainerBlockProcessor.py new file mode 100644 index 00000000..1e24ef18 --- /dev/null +++ b/verto/processors/ImageContainerBlockProcessor.py @@ -0,0 +1,72 @@ +from verto.processors.GenericContainerBlockProcessor import GenericContainerBlockProcessor +from verto.errors.ImageMissingCaptionError import ImageMissingCaptionError +from verto.errors.ImageCaptionContainsImageError import ImageCaptionContainsImageError +from verto.utils.image_file_name_components import image_file_name_components +import re + + +class ImageContainerBlockProcessor(GenericContainerBlockProcessor): + ''' Searches a Document for image tags e.g. {image file-path=""} + adding any internal images to the verto extension final result. + ''' + + def __init__(self, ext, *args, **kwargs): + ''' + Args: + ext: The parent node of the element tree that children will + reside in. + ''' + self.processor = 'image-container' + super().__init__(self.processor, ext, *args, **kwargs) + self.pattern = re.compile(ext.processor_info[self.processor]['pattern']) + self.required = ext.required_files['images'] + + def test(self, parent, block): + ''' Tests a block to see if the run method should be applied. + + Args: + parent: The parent node of the element tree that children + will reside in. + block: The block to be tested. + + Returns: + True if there are any start or end tags within the block. + ''' + return self.pattern.search(block) is not None or self.p_end.search(block) is not None + + def custom_parsing(self, content_blocks, argument_values): + ''' + Extracts the caption of an image block and creates file path based on whether internal or external image. + + Args: + content_blocks: List of strings to either be parsed or inserted as caption in template. + Returns: + Tuple containing blocks and extra_args to update the content_blocks list and argument_values dict. + Raises: + ImageCaptionContainsImageError: If the first line of an image block is another image block. + ImageMissingCaptionError: If no caption can be found in the image block. + ''' + for block in content_blocks: + if self.p_start.search(block): + raise ImageCaptionContainsImageError(self.processor) + + extra_args = {} + + argument = 'caption' + if len(content_blocks) == 0 or content_blocks[0] == '': + raise ImageMissingCaptionError(self.processor, argument) + extra_args[argument] = content_blocks[0] + + file_path = argument_values['file-path'] + del(argument_values['file-path']) + external_path_match = re.search(r'^http', file_path) + if external_path_match is None: # internal image + self.required.add(file_path) + file_relative = True + extra_args.update(image_file_name_components(file_path)) + else: + file_relative = False + extra_args['full_file_path'] = file_path + extra_args['file_relative'] = file_relative + + return (content_blocks, extra_args) diff --git a/verto/processors/ImageInlinePattern.py b/verto/processors/ImageInlinePattern.py index eadeafc1..7a878340 100644 --- a/verto/processors/ImageInlinePattern.py +++ b/verto/processors/ImageInlinePattern.py @@ -1,5 +1,6 @@ from verto.utils.HtmlParser import HtmlParser from verto.processors.utils import parse_arguments +from verto.utils.image_file_name_components import image_file_name_components from markdown.inlinepatterns import Pattern import re @@ -34,15 +35,18 @@ def handleMatch(self, match): arguments = match.group('args') argument_values = parse_arguments(self.processor, arguments, self.arguments) + context = dict() # check if internal or external image file_path = argument_values['file-path'] external_path_match = re.search(r'^http', file_path) if external_path_match is None: # internal image self.required.add(file_path) - file_path = self.relative_image_template.render({'file_path': file_path}) - - context = dict() - context['file_path'] = file_path + file_relative = True + context.update(image_file_name_components(file_path)) + else: + file_relative = False + context['full_file_path'] = file_path + context['file_relative'] = file_relative context['alt'] = argument_values.get('alt', None) context['caption'] = argument_values.get('caption', None) context['caption_link'] = argument_values.get('caption-link', None) diff --git a/verto/processors/ImageTagBlockProcessor.py b/verto/processors/ImageTagBlockProcessor.py new file mode 100644 index 00000000..7342be56 --- /dev/null +++ b/verto/processors/ImageTagBlockProcessor.py @@ -0,0 +1,63 @@ +from verto.processors.GenericTagBlockProcessor import GenericTagBlockProcessor +from verto.utils.image_file_name_components import image_file_name_components +import re + + +class ImageTagBlockProcessor(GenericTagBlockProcessor): + ''' Searches a Document for image tags e.g. {image file-path=""} + adding any internal images to the verto extension final result. + ''' + + def __init__(self, ext, *args, **kwargs): + ''' + Args: + ext: The parent node of the element tree that children will + reside in. + ''' + self.processor = 'image-tag' + super().__init__(self.processor, ext, *args, **kwargs) + self.caption_pattern = re.compile(ext.processor_info[self.processor]['pattern']) + self.required = ext.required_files['images'] + + def test(self, parent, block): + ''' Tests a block to see if the run method should be applied. + + Args: + parent: The parent node of the element tree that children + will reside in. + block: The block to be tested. + + Returns: + True if there are any start tags within the block. + ''' + return self.caption_pattern.search(block) is None and self.pattern.search(block) is not None + + def custom_parsing(self, argument_values): + ''' + Extracts the caption of an image block and creates file path based on whether internal or external image. + + Args: + content_blocks: List of strings to either be parsed or inserted as caption in template. + Returns: + extra_args: dictionary to update the argument_values dict. + ''' + extra_args = {} + + argument = 'caption' + caption_value = argument_values.get(argument) + if caption_value: + del argument_values[argument] # delete from dictionary so as to not be included in template + + # check if internal or external image + file_path = argument_values['file-path'] + del(argument_values['file-path']) + external_path_match = re.search(r'^http', file_path) + if external_path_match is None: # internal image + self.required.add(file_path) + file_relative = True + extra_args.update(image_file_name_components(file_path)) + else: + file_relative = False + extra_args['full_file_path'] = file_path + extra_args['file_relative'] = file_relative + return extra_args diff --git a/verto/processors/PanelBlockProcessor.py b/verto/processors/PanelBlockProcessor.py new file mode 100644 index 00000000..d677c464 --- /dev/null +++ b/verto/processors/PanelBlockProcessor.py @@ -0,0 +1,55 @@ +from verto.processors.GenericContainerBlockProcessor import GenericContainerBlockProcessor +from verto.errors.PanelMissingTitleError import PanelMissingTitleError +from verto.errors.PanelMissingSubtitleError import PanelMissingSubtitleError +import re + + +class PanelBlockProcessor(GenericContainerBlockProcessor): + def __init__(self, *args, **kwargs): + ''' + Args: + ext: An instance of the Verto Extension. + ''' + self.processor = 'panel' + super().__init__(self.processor, *args, **kwargs) + + def custom_parsing(self, content_blocks, argument_values): + ''' + Extracts the title and subtitle of panel block's contents. + + Args: + content_blocks: List of strings to either be parsed or inserted as content in template. + argument_values: Dictionary of values to be inserted in template. + Returns: + Tuple containing blocks and extra_args to update the content_blocks list and argument_values dict. + Raises: + PanelMissingTitleError: If no title can be found in a panel. + PanelMissingSubtitleError: If no subtitle can be found in a panel where it is expected. + ''' + extra_args = {} + blocks = [] + + argument = 'title' + title_r = re.compile(r'(^|\n)# ((\w| )*)(?P)') + title = title_r.search(content_blocks[0]) + if title: + extra_args[argument] = title.groups()[1] + else: + raise PanelMissingTitleError(self.processor, argument) + + argument = 'subtitle' + if argument_values.get(argument) == 'true': + subtitle_r = re.compile(r'(^|\n)## ((\w| )*)(?P)') + subtitle = subtitle_r.search(content_blocks[1]) + if subtitle: + extra_args[argument] = subtitle.groups()[1] + blocks = content_blocks[2:] + else: + raise PanelMissingSubtitleError(self.processor, argument) + elif argument_values.get(argument) == 'false': + del argument_values[argument] # delete from argument dict so as to not be included in template + blocks = content_blocks[1:] + else: + blocks = content_blocks[1:] + + return (blocks, extra_args) diff --git a/verto/processors/RelativeLinkPattern.py b/verto/processors/RelativeLinkPattern.py index 865eadc7..6a4967ef 100644 --- a/verto/processors/RelativeLinkPattern.py +++ b/verto/processors/RelativeLinkPattern.py @@ -38,6 +38,9 @@ def handleMatch(self, match): ''' context = dict() context['link_path'] = escape(match.group('link_url')) + link_query = match.group('link_query') + if link_query: + context['link_query'] = link_query context['text'] = match.group('link_text') html_string = self.template.render(context) diff --git a/verto/processors/StylePreprocessor.py b/verto/processors/StylePreprocessor.py index e8069e07..bd7da521 100644 --- a/verto/processors/StylePreprocessor.py +++ b/verto/processors/StylePreprocessor.py @@ -43,18 +43,18 @@ def run(self, lines): important_lines = (list(enumerate(lines))[max(0, i - 1): i + 2]) line_nums, error_lines = zip(*map(lambda x: (x[0] + 1, x[1].strip()), important_lines)) - # Remove all empty lines Should only be one line left + # Remove all empty lines, should only be one line left if len([line for line in error_lines if line != '']) != 1: raise StyleError(line_nums, error_lines, 'Blocks must be separated by whitespace.') start_index, end_index = block_match.span() rest = line[:start_index] + line[end_index+1:] - if (self.LIST_RE.match(line[:start_index]) - and not all(map(lambda char: char.isspace(), line[end_index+1:]))): + if (self.LIST_RE.match(line[:start_index]) and + not all(map(lambda char: char.isspace(), line[end_index+1:]))): raise StyleError(line_nums, error_lines, 'Content after block in list.') - elif (not self.LIST_RE.match(line[:start_index]) - and not all(map(lambda char: char.isspace(), rest))): + elif (not self.LIST_RE.match(line[:start_index]) and + not all(map(lambda char: char.isspace(), rest))): raise StyleError(line_nums, error_lines, 'Blocks must be the only thing on the line.') return lines diff --git a/verto/processors/utils.py b/verto/processors/utils.py index 3999124d..dc948999 100644 --- a/verto/processors/utils.py +++ b/verto/processors/utils.py @@ -42,7 +42,7 @@ def parse_flag(argument_key, arguments, default=False): arguments: A string of the argument inputs. default: The default value if not found. Returns: - Value of an argument as a string if found, otherwise None. + True if argument is found, otherwise None. ''' result = re.search(r'(^|\s+){}($|\s)'.format(argument_key), arguments) if result: @@ -77,8 +77,8 @@ def parse_arguments(processor, inputs, arguments): elif not is_required and (is_arg or is_flag): dependencies = argument_info.get('dependencies', []) for other_argument in dependencies: - if (parse_argument(other_argument, inputs, None) is None - and parse_flag(other_argument, inputs, None) is None): + if (parse_argument(other_argument, inputs, None) is None and + parse_flag(other_argument, inputs, None) is None): message = '{} is a required argument because {} exists.'.format(other_argument, argument) raise ArgumentMissingError(processor, argument, message) diff --git a/verto/tests/ConfigurationTest.py b/verto/tests/ConfigurationTest.py index efbc7941..10bf8e72 100644 --- a/verto/tests/ConfigurationTest.py +++ b/verto/tests/ConfigurationTest.py @@ -30,8 +30,7 @@ def __init__(self, *args, **kwargs): } def test_multiple_calls(self): - '''Checks all fields of VertoResult are correct for multiple - Verto calls. + '''Checks all fields of VertoResult are correct for multiple Verto calls. ''' test_cases = [ ('all_processors.md', @@ -141,8 +140,7 @@ def test_multiple_calls(self): verto.clear_saved_data() def test_multiple_calls_without_clearing(self): - '''Tests that if the verto extension is not cleared that - information such as required_files and slugs are persistant. + '''Tests that if the verto extension is not cleared that information such as required_files and slugs are persistent. ''' filename = 'all_processors.md' other_filename = 'otherfile.md' @@ -233,10 +231,9 @@ def test_multiple_calls_without_clearing(self): self.assertDictEqual(verto_result.required_glossary_terms, expected_otherfile_result.required_glossary_terms) def test_custom_processors_and_custom_templates_on_creation(self): - '''Checks if custom processors and custom templates work - together on creation of verto. + '''Checks if custom processors and custom templates work together on creation of verto. ''' - processors = {'image', 'boxed-text'} + processors = {'image-tag', 'boxed-text'} verto = Verto(processors=processors, html_templates=self.custom_templates) test_string = self.read_test_file(self.test_name, 'all_processors.md') converted_test_string = verto.convert(test_string).html_string @@ -244,10 +241,9 @@ def test_custom_processors_and_custom_templates_on_creation(self): self.assertEqual(expected_string, converted_test_string) def test_custom_processors_and_custom_templates_after_creation(self): - '''Checks if custom processors and custom templates work - together after creation of verto. + '''Checks if custom processors and custom templates work together after creation of verto. ''' - processors = {'image', 'boxed-text'} + processors = {'image-tag', 'boxed-text'} verto = Verto() verto.update_processors(processors) verto.update_templates(self.custom_templates) @@ -257,8 +253,7 @@ def test_custom_processors_and_custom_templates_after_creation(self): self.assertEqual(expected_string, converted_test_string) def test_default_processors_on_creation(self): - '''Checks if all expected default processors work on default - creation. + '''Checks if all expected default processors work on default creation. ''' verto = Verto() test_string = self.read_test_file(self.test_name, 'all_processors.md') @@ -269,7 +264,7 @@ def test_default_processors_on_creation(self): def test_custom_processors_on_creation(self): '''Checks if system only uses specified processors. ''' - processors = {'panel', 'image'} + processors = {'panel', 'image-container'} verto = Verto(processors=processors) test_string = self.read_test_file(self.test_name, 'all_processors.md') converted_test_string = verto.convert(test_string).html_string @@ -293,8 +288,7 @@ def test_custom_processors_after_creation(self): self.assertEqual(expected_string, converted_test_string) def test_unique_custom_processors(self): - '''Checks if unique processors are stored when duplicates - provided. + '''Checks if unique processors are stored when duplicates provided. ''' processors = ['comment', 'comment', 'comment'] verto = Verto(processors=processors) @@ -336,13 +330,12 @@ def test_reset_templates_after_custom(self): self.assertEqual(expected_string, converted_test_string) def test_multiline_custom_templates(self): - '''Checks that multiple multiline custom templates are loaded - and used correctly. + '''Checks that multiple multiline custom templates are loaded and used correctly. ''' custom_templates = { 'image': \ '''
- +
''', 'boxed-text': \ diff --git a/verto/tests/ImageContainerTest.py b/verto/tests/ImageContainerTest.py new file mode 100644 index 00000000..f6db09d0 --- /dev/null +++ b/verto/tests/ImageContainerTest.py @@ -0,0 +1,497 @@ +import markdown +from unittest.mock import Mock +from collections import defaultdict + +from verto.VertoExtension import VertoExtension +from verto.processors.ImageContainerBlockProcessor import ImageContainerBlockProcessor +from verto.errors.ImageMissingCaptionError import ImageMissingCaptionError +from verto.errors.ImageCaptionContainsImageError import ImageCaptionContainsImageError +from verto.errors.ArgumentMissingError import ArgumentMissingError +from verto.errors.ArgumentValueError import ArgumentValueError +from verto.errors.TagNotMatchedError import TagNotMatchedError +from verto.tests.ProcessorTest import ProcessorTest + + +class ImageContainerTest(ProcessorTest): + '''The image container processor is a simple tag with a multitude of + different possible arguments that modify output slightly. + Internally linked file features need to be considered + when testing images, such that required files are modified + and need to be checked to see if updated correctly. + ''' + + def __init__(self, *args, **kwargs): + '''Set processor name and tag argument in class for file names. + ''' + ProcessorTest.__init__(self, *args, **kwargs) + self.processor_name = 'image-container' + self.tag_argument = 'image' + self.ext = Mock() + self.ext.jinja_templates = { + 'image': ProcessorTest.loadJinjaTemplate(self, 'image'), + 'relative-file-link': ProcessorTest.loadJinjaTemplate(self, 'relative-file-link') + } + self.ext.processor_info = ProcessorTest.loadProcessorInfo(self) + self.ext.required_files = defaultdict(set) + + def test_caption_true(self): + '''Tests to ensure that caption is rendered correctly and expected images are updated. + ''' + test_string = self.read_test_file(self.processor_name, 'caption_true.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([False, True, False, True, False], [ImageContainerBlockProcessor(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_string = self.read_test_file(self.processor_name, 'caption_true_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + images = self.verto_extension.required_files['images'] + expected_images = { + 'cats.png' + } + self.assertSetEqual(expected_images, images) + + def test_caption_false(self): + '''Tests processor does not match image tag when caption argument is not included. + ''' + test_string = self.read_test_file(self.processor_name, 'caption_false.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([False, False, False], [ImageContainerBlockProcessor(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_string = self.read_test_file(self.processor_name, 'caption_false_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + def test_no_caption(self): + '''Tests processor does not match image tag when caption argument is not included. + ''' + test_string = self.read_test_file(self.processor_name, 'no_caption.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([False, False, False], [ImageContainerBlockProcessor(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_string = self.read_test_file(self.processor_name, 'no_caption_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + def test_alt_hover_caption(self): + '''Tests that multiple arguments are rendered correctly when caption argument is included and expected images are updated. + ''' + test_string = self.read_test_file(self.processor_name, 'alt_hover_caption.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([False, True, False, True, False, True, False, True, False], [ImageContainerBlockProcessor(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_string = self.read_test_file(self.processor_name, 'alt_hover_caption_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + images = self.verto_extension.required_files['images'] + expected_images = { + 'finite-state-automata-no-trap-example.png', + 'finite-state-automata-trap-added-example.png' + } + self.assertSetEqual(expected_images, images) + + def test_caption_true_not_provided(self): + '''Tests that ImageMissingCaptionError is thrown when caption argument is true but not provided. + ''' + test_string = self.read_test_file(self.processor_name, 'caption_true_not_provided.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([False, True, True, False], [ImageContainerBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + self.assertRaises(ImageMissingCaptionError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) + + def test_caption_true_missing_end_tag(self): # throw error + '''Tests that TagNotMatchedError is thrown when image tag is missing end tag. + ''' + test_string = self.read_test_file(self.processor_name, 'caption_true_missing_end_tag.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([False, True, False, False], [ImageContainerBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + self.assertRaises(TagNotMatchedError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) + + def test_caption_true_not_provided_numbered_list(self): + '''Tests that ImageMissingCaptionError is thrown when caption argument is true but not provided in numbered list. + ''' + test_string = self.read_test_file(self.processor_name, 'caption_true_not_provided_numbered_list.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([False, False, False, True, True, False], [ImageContainerBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + self.assertRaises(ImageMissingCaptionError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) + + def test_caption_true_numbered_list_missing_end_tag(self): + '''Tests that TagNotMatchedError is thrown when image tag is missing end tag. + ''' + test_string = self.read_test_file(self.processor_name, 'caption_true_numbered_list_missing_end_tag.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([False, False, False, True, False, False], [ImageContainerBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + self.assertRaises(TagNotMatchedError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) + + def test_image_in_image_tag(self): + '''Test that ImageCaptionContainsImageError is raised when the first line in an image container block is another image container block. + ''' + test_string = self.read_test_file(self.processor_name, 'image_in_image_tag.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, True, False, True, False, True], [ImageContainerBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + self.assertRaises(ImageCaptionContainsImageError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) + + def test_multiple_images_captions_true(self): + '''Tests to ensure that multiple internally reference images ar rendered correctly and expected images is updated. + ''' + test_string = self.read_test_file(self.processor_name, 'multiple_images_captions_true.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([False, True, False, True, True, False, True, True, False, True, False], [ImageContainerBlockProcessor(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_string = self.read_test_file(self.processor_name, 'multiple_images_captions_true_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + images = self.verto_extension.required_files['images'] + expected_images = { + 'the-first-image.png', + 'Lipsum.png', + 'pixel-diamond.png' + } + self.assertSetEqual(expected_images, images) + + def test_contains_multiple_images_some_captions(self): + '''Tests to ensure that multiple internally reference images ar rendered correctly and expected images is updated and that images without captions are ignored. + ''' + test_string = self.read_test_file(self.processor_name, 'contains_multiple_images_some_captions.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([False, True, False, True, False, True, False, True, False, False], [ImageContainerBlockProcessor(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_string = self.read_test_file(self.processor_name, 'contains_multiple_images_some_captions_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + images = self.verto_extension.required_files['images'] + expected_images = { + 'finite-state-automata-no-trap-example.png', + 'finite-state-automata-trap-added-example.png' + } + self.assertSetEqual(expected_images, images) + + def test_external_image(self): + '''Tests that external images are processed and that the expected images are unchanged. + ''' + test_string = self.read_test_file(self.processor_name, 'external_image.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, True, False], [ImageContainerBlockProcessor(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_string = self.read_test_file(self.processor_name, 'external_image_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + def test_contains_hover_text(self): + '''Tests that argument for hover-text produces expected output and expected images are updated. + ''' + test_string = self.read_test_file(self.processor_name, 'contains_hover_text.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, True], [ImageContainerBlockProcessor(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_string = self.read_test_file(self.processor_name, 'contains_hover_text_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + images = self.verto_extension.required_files['images'] + expected_images = { + 'computer-studying-turing-test.png' + } + self.assertSetEqual(expected_images, images) + + def test_contains_caption_link(self): + '''Tests that argument for caption-link produces expected output and expected images are updated. + ''' + test_string = self.read_test_file(self.processor_name, 'contains_caption_link.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, True], [ImageContainerBlockProcessor(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_string = self.read_test_file(self.processor_name, 'contains_caption_link_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + images = self.verto_extension.required_files['images'] + expected_images = { + 'computer-studying-turing-test.png' + } + self.assertSetEqual(expected_images, images) + + def test_contains_alt(self): + '''Tests that argument for alt produces expected output and expected images are updated. + ''' + test_string = self.read_test_file(self.processor_name, 'contains_alt.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, True], [ImageContainerBlockProcessor(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_string = self.read_test_file(self.processor_name, 'contains_alt_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + images = self.verto_extension.required_files['images'] + expected_images = { + 'computer-studying-turing-test.png' + } + self.assertSetEqual(expected_images, images) + + def test_contains_source(self): + '''Tests that argument for source produces expected output and expected images are updated. + ''' + test_string = self.read_test_file(self.processor_name, 'contains_source.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, True], [ImageContainerBlockProcessor(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_string = self.read_test_file(self.processor_name, 'contains_source_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + images = self.verto_extension.required_files['images'] + expected_images = { + 'computer-studying-turing-test.png' + } + self.assertSetEqual(expected_images, images) + + def test_align_left(self): + '''Tests that argument for align produces expected output when set to left and expected images are updated. + ''' + test_string = self.read_test_file(self.processor_name, 'align_left.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, True], [ImageContainerBlockProcessor(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_string = self.read_test_file(self.processor_name, 'align_left_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + images = self.verto_extension.required_files['images'] + expected_images = { + 'computer-studying-turing-test.png' + } + self.assertSetEqual(expected_images, images) + + def test_align_right(self): + '''Tests that argument for align produces expected output when set to right and expected images are updated. + ''' + test_string = self.read_test_file(self.processor_name, 'align_right.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, True], [ImageContainerBlockProcessor(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_string = self.read_test_file(self.processor_name, 'align_right_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + images = self.verto_extension.required_files['images'] + expected_images = { + 'computer-studying-turing-test.png' + } + self.assertSetEqual(expected_images, images) + + def test_align_center(self): + '''Tests that argument for align produces expected output when set to center and expected images are updated. + ''' + test_string = self.read_test_file(self.processor_name, 'align_center.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, True], [ImageContainerBlockProcessor(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_string = self.read_test_file(self.processor_name, 'align_center_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + images = self.verto_extension.required_files['images'] + expected_images = { + 'computer-studying-turing-test.png' + } + self.assertSetEqual(expected_images, images) + + def test_align_undefined_error(self): + '''Tests that ArgumentValueError is raised when undefined align value is given. + ''' + test_string = self.read_test_file(self.processor_name, 'align_undefined_error.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, True], [ImageContainerBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + self.assertRaises(ArgumentValueError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) + + def test_image_in_numbered_list(self): + '''Tests that image with in numbered list is rendered correctly and expected images are updated. + ''' + test_string = self.read_test_file(self.processor_name, 'image_in_numbered_list.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([False, False, False, True, False, True, False], [ImageContainerBlockProcessor(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_string = self.read_test_file(self.processor_name, 'image_in_numbered_list_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + images = self.verto_extension.required_files['images'] + expected_images = set() + self.assertSetEqual(expected_images, images) + + def test_image_width_value(self): + '''Test image rendered correctly with width value. + ''' + test_string = self.read_test_file(self.processor_name, 'file_width_value.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, True], [ImageContainerBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + html_template = self.read_test_file(self.processor_name, 'file_width_value_html_template.html', strip=True) + verto_extension = VertoExtension([self.processor_name], html_templates={self.tag_argument: html_template}) + converted_test_string = markdown.markdown(test_string, extensions=[verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'file_width_value_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + images = self.verto_extension.required_files['images'] + expected_images = set() + self.assertSetEqual(expected_images, images) + + def test_image_width_value_no_units(self): + '''Test image rendered correctly with width value with no units. + ''' + test_string = self.read_test_file(self.processor_name, 'file_width_value_no_units.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, True], [ImageContainerBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + html_template = self.read_test_file(self.processor_name, 'file_width_value_no_units_html_template.html', strip=True) + verto_extension = VertoExtension([self.processor_name], html_templates={self.tag_argument: html_template}) + converted_test_string = markdown.markdown(test_string, extensions=[verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'file_width_value_no_units_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + images = self.verto_extension.required_files['images'] + expected_images = set() + self.assertSetEqual(expected_images, images) + + def test_image_invalid_width_value_1(self): + '''Test image rendered correctly with width value. + ''' + test_string = self.read_test_file(self.processor_name, 'file_invalid_width_value_1.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, True], [ImageContainerBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + html_template = self.read_test_file(self.processor_name, 'file_invalid_width_value_1_html_template.html', strip=True) + verto_extension = VertoExtension([self.processor_name], html_templates={self.tag_argument: html_template}) + converted_test_string = markdown.markdown(test_string, extensions=[verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'file_invalid_width_value_1_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + images = self.verto_extension.required_files['images'] + expected_images = set() + self.assertSetEqual(expected_images, images) + + def test_image_invalid_width_value_2(self): + '''Test image rendered correctly with width value. + ''' + test_string = self.read_test_file(self.processor_name, 'file_invalid_width_value_2.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, True], [ImageContainerBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + html_template = self.read_test_file(self.processor_name, 'file_invalid_width_value_2_html_template.html', strip=True) + verto_extension = VertoExtension([self.processor_name], html_templates={self.tag_argument: html_template}) + converted_test_string = markdown.markdown(test_string, extensions=[verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'file_invalid_width_value_2_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + images = self.verto_extension.required_files['images'] + expected_images = set() + self.assertSetEqual(expected_images, images) + + def test_image_width_value_external_image(self): + '''Test image rendered correctly with width value. + ''' + test_string = self.read_test_file(self.processor_name, 'file_width_value_external_image.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, True], [ImageContainerBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + html_template = self.read_test_file(self.processor_name, 'file_width_value_external_image_html_template.html', strip=True) + verto_extension = VertoExtension([self.processor_name], html_templates={self.tag_argument: html_template}) + converted_test_string = markdown.markdown(test_string, extensions=[verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'file_width_value_external_image_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + images = self.verto_extension.required_files['images'] + expected_images = set() + self.assertSetEqual(expected_images, images) + + #~ + # Doc Tests + #~ + + def test_doc_example_basic(self): + '''Basic example of common usage. + ''' + test_string = self.read_test_file(self.processor_name, 'doc_example_basic_usage.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, True], [ImageContainerBlockProcessor(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_string = self.read_test_file(self.processor_name, 'doc_example_basic_usage_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + images = self.verto_extension.required_files['images'] + expected_images = set() + self.assertSetEqual(expected_images, images) + + def test_doc_example_override_html(self): + '''Basic example showing how to override the html-template. + ''' + test_string = self.read_test_file(self.processor_name, 'doc_example_override_html.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, True], [ImageContainerBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + html_template = self.read_test_file(self.processor_name, 'doc_example_override_html_template.html', strip=True) + verto_extension = VertoExtension([self.processor_name], html_templates={self.tag_argument: html_template}) + + converted_test_string = markdown.markdown(test_string, extensions=[verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'doc_example_override_html_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + images = self.verto_extension.required_files['images'] + expected_images = set() + self.assertSetEqual(expected_images, images) + + def test_doc_example_2_override_html(self): # TODO check docstring + '''Basic example showing how to override the html-template for relative files in a specific file only. + ''' + test_string = self.read_test_file(self.processor_name, 'doc_example_2_override_html.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, True], [ImageContainerBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + html_template = self.read_test_file(self.processor_name, 'doc_example_2_override_html_template.html', strip=True) + verto_extension = VertoExtension([self.processor_name], html_templates={self.tag_argument: html_template}) + + converted_test_string = markdown.markdown(test_string, extensions=[verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'doc_example_2_override_html_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + images = self.verto_extension.required_files['images'] + expected_images = set() + self.assertSetEqual(expected_images, images) diff --git a/verto/tests/ImageInlineTest.py b/verto/tests/ImageInlineTest.py index ce0aa86c..cb6ba0b5 100644 --- a/verto/tests/ImageInlineTest.py +++ b/verto/tests/ImageInlineTest.py @@ -198,6 +198,75 @@ def test_argument_hover_text(self): expected_images = set() self.assertSetEqual(expected_images, images) + def test_image_width_value(self): + '''Test image rendered correctly with width value. + ''' + test_string = self.read_test_file(self.processor_name, 'file_width_value.md') + processor = ImageInlinePattern(self.ext, self.md.parser) + self.assertIsNotNone(re.search(processor.compiled_re, test_string)) + html_template = self.read_test_file(self.processor_name, 'file_width_value_html_template.html', strip=True) + verto_extension = VertoExtension([self.processor_name], html_templates={self.processor_name: html_template}) + converted_test_string = markdown.markdown(test_string, extensions=[verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'file_width_value_expected.html', strip=True).strip() + self.assertEqual(expected_string, converted_test_string) + images = verto_extension.required_files['images'] + expected_images = {'path/to/image@500px.png'} + self.assertSetEqual(expected_images, images) + + def test_image_width_value_no_units(self): + '''Test image rendered correctly with width value with no units. + ''' + test_string = self.read_test_file(self.processor_name, 'file_width_value_no_units.md') + processor = ImageInlinePattern(self.ext, self.md.parser) + self.assertIsNotNone(re.search(processor.compiled_re, test_string)) + html_template = self.read_test_file(self.processor_name, 'file_width_value_no_units_html_template.html', strip=True) + verto_extension = VertoExtension([self.processor_name], html_templates={self.processor_name: html_template}) + converted_test_string = markdown.markdown(test_string, extensions=[verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'file_width_value_no_units_expected.html', strip=True).strip() + self.assertEqual(expected_string, converted_test_string) + images = verto_extension.required_files['images'] + expected_images = {'path/to/image@900.png'} + self.assertSetEqual(expected_images, images) + + def test_image_invalid_width_value_1(self): + '''Test image rendered correctly with width value. + ''' + test_string = self.read_test_file(self.processor_name, 'file_invalid_width_value_1.md') + processor = ImageInlinePattern(self.ext, self.md.parser) + self.assertIsNotNone(re.search(processor.compiled_re, test_string)) + converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'file_invalid_width_value_1_expected.html', strip=True).strip() + self.assertEqual(expected_string, converted_test_string) + images = self.verto_extension.required_files['images'] + expected_images = {'path/to/image@.png'} + self.assertSetEqual(expected_images, images) + + def test_image_invalid_width_value_2(self): + '''Test image rendered correctly with width value. + ''' + test_string = self.read_test_file(self.processor_name, 'file_invalid_width_value_2.md') + processor = ImageInlinePattern(self.ext, self.md.parser) + self.assertIsNotNone(re.search(processor.compiled_re, test_string)) + converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'file_invalid_width_value_2_expected.html', strip=True).strip() + self.assertEqual(expected_string, converted_test_string) + images = self.verto_extension.required_files['images'] + expected_images = {'path/to/image@em20.png'} + self.assertSetEqual(expected_images, images) + + def test_image_width_value_external_image(self): + '''Test image rendered correctly with width value. + ''' + test_string = self.read_test_file(self.processor_name, 'file_width_value_external_image.md') + processor = ImageInlinePattern(self.ext, self.md.parser) + self.assertIsNotNone(re.search(processor.compiled_re, test_string)) + converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'file_width_value_external_image_expected.html', strip=True).strip() + self.assertEqual(expected_string, converted_test_string) + images = self.verto_extension.required_files['images'] + expected_images = set() + self.assertSetEqual(expected_images, images) + #~ # Embed test. #~ diff --git a/verto/tests/ImageTest.py b/verto/tests/ImageTagTest.py similarity index 52% rename from verto/tests/ImageTest.py rename to verto/tests/ImageTagTest.py index 992dac19..9c885cfb 100644 --- a/verto/tests/ImageTest.py +++ b/verto/tests/ImageTagTest.py @@ -3,13 +3,14 @@ from collections import defaultdict from verto.VertoExtension import VertoExtension -from verto.processors.ImageBlockProcessor import ImageBlockProcessor +from verto.processors.ImageTagBlockProcessor import ImageTagBlockProcessor from verto.errors.ArgumentMissingError import ArgumentMissingError from verto.errors.ArgumentValueError import ArgumentValueError from verto.tests.ProcessorTest import ProcessorTest -class ImageTest(ProcessorTest): - '''The image processor is a simple tag with a multitude of + +class ImageTagTest(ProcessorTest): + '''The image tag processor is a simple tag with a multitude of different possible arguments that modify output slightly. Internally linked file features need to be considered when testing images, such that required files are modified @@ -17,172 +18,157 @@ class ImageTest(ProcessorTest): ''' def __init__(self, *args, **kwargs): - '''Set processor name in class for file names. + '''Set processor name and tag argument in class for file names. ''' ProcessorTest.__init__(self, *args, **kwargs) - self.processor_name = 'image' + self.processor_name = 'image-tag' + self.tag_argument = 'image' self.ext = Mock() self.ext.jinja_templates = { - self.processor_name: ProcessorTest.loadJinjaTemplate(self, self.processor_name), + 'image': ProcessorTest.loadJinjaTemplate(self, 'image'), 'relative-file-link': ProcessorTest.loadJinjaTemplate(self, 'relative-file-link') } self.ext.processor_info = ProcessorTest.loadProcessorInfo(self) self.ext.required_files = defaultdict(set) - def test_internal_image(self): - '''Tests to ensure that an internally reference image - produces the desired output, including changing the - expected images of the verto extension. + def test_caption(self): # should not be matched + '''Tests to ensure that an image with a caption is ignored. ''' - test_string = self.read_test_file(self.processor_name, 'internal_image.md') + test_string = self.read_test_file(self.processor_name, 'caption.md') blocks = self.to_blocks(test_string) - self.assertListEqual([False, True, False], [ImageBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([False, False, False, False, False], [ImageTagBlockProcessor(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_string = self.read_test_file(self.processor_name, 'internal_image_expected.html', strip=True) + expected_string = self.read_test_file(self.processor_name, 'caption_expected.html', strip=True) self.assertEqual(expected_string, converted_test_string) - images = self.verto_extension.required_files['images'] - expected_images = { - 'pixel-diamond.png' - } - self.assertSetEqual(expected_images, images) - - def test_external_image(self): - '''Tests that external images are processed and that - the expected images are unchanged. + def test_no_caption(self): + '''Tests to ensure that an image with no caption is rendered correctly and expected images are updated. ''' - test_string = self.read_test_file(self.processor_name, 'external_image.md') + test_string = self.read_test_file(self.processor_name, 'no_caption.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True, False], [ImageBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([False, True, False], [ImageTagBlockProcessor(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_string = self.read_test_file(self.processor_name, 'external_image_expected.html', strip=True) - self.assertEqual(expected_string, converted_test_string) - - def test_default_image(self): - '''Tests that old image tags retain compatability. - ''' - test_string = self.read_test_file(self.processor_name, 'default_image.md') - blocks = self.to_blocks(test_string) - - self.assertListEqual([True, False], [ImageBlockProcessor(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_string = self.read_test_file(self.processor_name, 'default_image_expected.html', strip=True) + expected_string = self.read_test_file(self.processor_name, 'no_caption_expected.html', strip=True) self.assertEqual(expected_string, converted_test_string) images = self.verto_extension.required_files['images'] expected_images = { - 'computer-studying-turing-test.png' + 'pixel-diamond.png' } self.assertSetEqual(expected_images, images) - def test_contains_multiple_images(self): - '''Tests that multiple internal images are processed correctly - and that the expected images are updated. + def test_caption_false(self): + '''Tests caption argument is ignored when set to false and that expected images are updated. ''' - test_string = self.read_test_file(self.processor_name, 'contains_multiple_images.md') + test_string = self.read_test_file(self.processor_name, 'caption_false.md') blocks = self.to_blocks(test_string) - self.assertListEqual([False, True, False, True, False, True, False], [ImageBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([False, True, False], [ImageTagBlockProcessor(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_string = self.read_test_file(self.processor_name, 'contains_multiple_images_expected.html', strip=True) + expected_string = self.read_test_file(self.processor_name, 'caption_false_expected.html', strip=True) self.assertEqual(expected_string, converted_test_string) images = self.verto_extension.required_files['images'] expected_images = { - 'finite-state-automata-no-trap-example.png', - 'finite-state-automata-trap-added-example.png', - 'finite-state-automata-trap-added-extreme-example.png' + 'cats.png' } self.assertSetEqual(expected_images, images) - def test_text_contains_the_word_image(self): - '''Tests that text containing the processor name is - not matched erroneously. + def test_invalid_caption_parameter(self): + '''Tests that ArgumentValueError is raised when aaption-link argument is give but a caption is not provided. ''' - test_string = self.read_test_file(self.processor_name, 'text_contains_the_word_image.md') + test_string = self.read_test_file(self.processor_name, 'invalid_caption_error.md') blocks = self.to_blocks(test_string) - self.assertListEqual([False], [ImageBlockProcessor(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_string = self.read_test_file(self.processor_name, 'text_contains_the_word_image_expected.html', strip=True) - self.assertEqual(expected_string, converted_test_string) + self.assertListEqual([False, True, False], [ImageTagBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) - images = self.verto_extension.required_files['images'] - expected_images = set() - self.assertSetEqual(expected_images, images) + self.assertRaises(ArgumentValueError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) - def test_contains_image_and_text_contains_word_image(self): - '''Tests that text containing the processor name does - not affect processing of actual image tags. + def test_source_hover_no_caption(self): + '''Tests that multiple arguments are rendered correctly when no caption argument is included and expected images are updated. ''' - test_string = self.read_test_file(self.processor_name, 'contains_image_and_text_contains_word_image.md') + test_string = self.read_test_file(self.processor_name, 'source_hover_no_caption.md') blocks = self.to_blocks(test_string) - self.assertListEqual([False, True, False], [ImageBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([False, True, False, True, False], [ImageTagBlockProcessor(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_string = self.read_test_file(self.processor_name, 'contains_image_and_text_contains_word_image_expected.html', strip=True) + expected_string = self.read_test_file(self.processor_name, 'source_hover_no_caption_expected.html', strip=True) self.assertEqual(expected_string, converted_test_string) images = self.verto_extension.required_files['images'] expected_images = { - 'pixel-diamond.png' + 'finite-state-automata-no-trap-example.png', + 'finite-state-automata-trap-added-example.png' } self.assertSetEqual(expected_images, images) - def test_contains_hover_text(self): - '''Tests that argument for hover-text produces expected output. + def test_alt_hover_caption_false(self): + '''Tests that multiple arguments are rendered correctly when caption argument is false and expected images are updated. ''' - test_string = self.read_test_file(self.processor_name, 'contains_hover_text.md') + test_string = self.read_test_file(self.processor_name, 'alt_hover_caption_false.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True], [ImageBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([False, True, False, True, False], [ImageTagBlockProcessor(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_string = self.read_test_file(self.processor_name, 'contains_hover_text_expected.html', strip=True) + expected_string = self.read_test_file(self.processor_name, 'alt_hover_caption_false_expected.html', strip=True) self.assertEqual(expected_string, converted_test_string) images = self.verto_extension.required_files['images'] expected_images = { - 'computer-studying-turing-test.png' + 'finite-state-automata-no-trap-example.png', + 'finite-state-automata-trap-added-example.png' } self.assertSetEqual(expected_images, images) - def test_contains_caption_link(self): - '''Tests that argument for caption-link produces expected output. + def test_multiple_images_captions_false(self): + '''Tests to ensure that multiple internally reference images produce the desired output and expected images are updated. ''' - test_string = self.read_test_file(self.processor_name, 'contains_caption_link.md') + test_string = self.read_test_file(self.processor_name, 'multiple_images_captions_false.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True], [ImageBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([False, True, True, False, True, False], [ImageTagBlockProcessor(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_string = self.read_test_file(self.processor_name, 'contains_caption_link_expected.html', strip=True) + expected_string = self.read_test_file(self.processor_name, 'multiple_images_captions_false_expected.html', strip=True) self.assertEqual(expected_string, converted_test_string) images = self.verto_extension.required_files['images'] expected_images = { - 'computer-studying-turing-test.png' + 'the-first-image.png', + 'Lipsum.png', + 'pixel-diamond.png' } self.assertSetEqual(expected_images, images) - def test_contains_alt(self): - '''Tests that argument for alt produces expected output. + def test_external_image(self): + '''Tests that external images are processed and that the expected images are unchanged. ''' - test_string = self.read_test_file(self.processor_name, 'contains_alt.md') + test_string = self.read_test_file(self.processor_name, 'external_image.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True], [ImageBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True, False], [ImageTagBlockProcessor(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_string = self.read_test_file(self.processor_name, 'contains_alt_expected.html', strip=True) + expected_string = self.read_test_file(self.processor_name, 'external_image_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + def test_contains_hover_text(self): + '''Tests that argument for hover-text produces expected output and expected images are updated. + ''' + test_string = self.read_test_file(self.processor_name, 'contains_hover_text.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([False, True], [ImageTagBlockProcessor(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_string = self.read_test_file(self.processor_name, 'contains_hover_text_expected.html', strip=True) self.assertEqual(expected_string, converted_test_string) images = self.verto_extension.required_files['images'] @@ -191,16 +177,16 @@ def test_contains_alt(self): } self.assertSetEqual(expected_images, images) - def test_contains_caption(self): - '''Tests that argument for caption produces expected output. + def test_contains_alt(self): + '''Tests that argument for alt produces expected output and expected images are updated. ''' - test_string = self.read_test_file(self.processor_name, 'contains_caption.md') + test_string = self.read_test_file(self.processor_name, 'contains_alt.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True], [ImageBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True, False], [ImageTagBlockProcessor(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_string = self.read_test_file(self.processor_name, 'contains_caption_expected.html', strip=True) + expected_string = self.read_test_file(self.processor_name, 'contains_alt_expected.html', strip=True) self.assertEqual(expected_string, converted_test_string) images = self.verto_extension.required_files['images'] @@ -210,12 +196,12 @@ def test_contains_caption(self): self.assertSetEqual(expected_images, images) def test_contains_source(self): - '''Tests that argument for source produces expected output. + '''Tests that argument for source produces expected output and expected images are updated. ''' test_string = self.read_test_file(self.processor_name, 'contains_source.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True], [ImageBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([False, True], [ImageTagBlockProcessor(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_string = self.read_test_file(self.processor_name, 'contains_source_expected.html', strip=True) @@ -228,13 +214,12 @@ def test_contains_source(self): self.assertSetEqual(expected_images, images) def test_align_left(self): - '''Tests that argument for align produces expected output - when set to left. + '''Tests that argument for align produces expected output when set to left and expected images are updated. ''' test_string = self.read_test_file(self.processor_name, 'align_left.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True], [ImageBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True], [ImageTagBlockProcessor(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_string = self.read_test_file(self.processor_name, 'align_left_expected.html', strip=True) @@ -247,13 +232,12 @@ def test_align_left(self): self.assertSetEqual(expected_images, images) def test_align_right(self): - '''Tests that argument for align produces expected output - when set to right. + '''Tests that argument for align produces expected output when set to right and expected images are updated. ''' test_string = self.read_test_file(self.processor_name, 'align_right.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True], [ImageBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True], [ImageTagBlockProcessor(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_string = self.read_test_file(self.processor_name, 'align_right_expected.html', strip=True) @@ -266,13 +250,12 @@ def test_align_right(self): self.assertSetEqual(expected_images, images) def test_align_center(self): - '''Tests that argument for align produces expected output - when set to center. + '''Tests that argument for align produces expected output when set to center and expected images are updated. ''' test_string = self.read_test_file(self.processor_name, 'align_center.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True], [ImageBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([False, True, False], [ImageTagBlockProcessor(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_string = self.read_test_file(self.processor_name, 'align_center_expected.html', strip=True) @@ -285,33 +268,32 @@ def test_align_center(self): self.assertSetEqual(expected_images, images) def test_caption_link_error(self): - '''Tests that the argument for caption-link throughs the - ArgumentMissingError when caption is not provided. + '''Tests that ArgumentMissingError is raised when caption-link argument is give but a caption is not provided. ''' test_string = self.read_test_file(self.processor_name, 'caption_link_error.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True], [ImageBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True], [ImageTagBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) self.assertRaises(ArgumentMissingError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) def test_align_undefined_error(self): - '''Tests that undefined align value produces - the ArgumentValueError. + '''Tests that ArgumentValueError is raised when undefined align value is given. ''' test_string = self.read_test_file(self.processor_name, 'align_undefined_error.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True], [ImageBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True], [ImageTagBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) self.assertRaises(ArgumentValueError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) def test_image_in_numbered_list(self): - '''Basic example of common usage.''' + '''Test image rendered correctly in numbered list. + ''' test_string = self.read_test_file(self.processor_name, 'image_in_numbered_list.md') blocks = self.to_blocks(test_string) - self.assertListEqual([False, False, False, True, False], [ImageBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([False, False, False, True, False], [ImageTagBlockProcessor(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_string = self.read_test_file(self.processor_name, 'image_in_numbered_list_expected.html', strip=True) @@ -321,16 +303,92 @@ def test_image_in_numbered_list(self): expected_images = set() self.assertSetEqual(expected_images, images) + def test_image_width_value(self): + '''Test image rendered correctly with width value. + ''' + test_string = self.read_test_file(self.processor_name, 'file_width_value.md') + blocks = self.to_blocks(test_string) + self.assertListEqual([True], [ImageTagBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + html_template = self.read_test_file(self.processor_name, 'file_width_value_html_template.html', strip=True) + verto_extension = VertoExtension([self.processor_name], html_templates={self.tag_argument: html_template}) + converted_test_string = markdown.markdown(test_string, extensions=[verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'file_width_value_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + images = self.verto_extension.required_files['images'] + expected_images = set() + self.assertSetEqual(expected_images, images) + + def test_image_width_value_no_units(self): + '''Test image rendered correctly with width value with no units. + ''' + test_string = self.read_test_file(self.processor_name, 'file_width_value_no_units.md') + blocks = self.to_blocks(test_string) + self.assertListEqual([True], [ImageTagBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + html_template = self.read_test_file(self.processor_name, 'file_width_value_no_units_html_template.html', strip=True) + verto_extension = VertoExtension([self.processor_name], html_templates={self.tag_argument: html_template}) + converted_test_string = markdown.markdown(test_string, extensions=[verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'file_width_value_no_units_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + images = self.verto_extension.required_files['images'] + expected_images = set() + self.assertSetEqual(expected_images, images) + + def test_image_invalid_width_value_1(self): + '''Test image rendered correctly with width value. + ''' + test_string = self.read_test_file(self.processor_name, 'file_invalid_width_value_1.md') + blocks = self.to_blocks(test_string) + self.assertListEqual([True], [ImageTagBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + html_template = self.read_test_file(self.processor_name, 'file_invalid_width_value_1_html_template.html', strip=True) + verto_extension = VertoExtension([self.processor_name], html_templates={self.tag_argument: html_template}) + converted_test_string = markdown.markdown(test_string, extensions=[verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'file_invalid_width_value_1_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + images = self.verto_extension.required_files['images'] + expected_images = set() + self.assertSetEqual(expected_images, images) + + def test_image_invalid_width_value_2(self): + '''Test image rendered correctly with width value. + ''' + test_string = self.read_test_file(self.processor_name, 'file_invalid_width_value_2.md') + blocks = self.to_blocks(test_string) + self.assertListEqual([True], [ImageTagBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + html_template = self.read_test_file(self.processor_name, 'file_invalid_width_value_2_html_template.html', strip=True) + verto_extension = VertoExtension([self.processor_name], html_templates={self.tag_argument: html_template}) + converted_test_string = markdown.markdown(test_string, extensions=[verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'file_invalid_width_value_2_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + images = self.verto_extension.required_files['images'] + expected_images = set() + self.assertSetEqual(expected_images, images) + + def test_image_width_value_external_image(self): + '''Test image rendered correctly with width value. + ''' + test_string = self.read_test_file(self.processor_name, 'file_width_value_external_image.md') + blocks = self.to_blocks(test_string) + self.assertListEqual([True], [ImageTagBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + html_template = self.read_test_file(self.processor_name, 'file_width_value_external_image_html_template.html', strip=True) + verto_extension = VertoExtension([self.processor_name], html_templates={self.tag_argument: html_template}) + converted_test_string = markdown.markdown(test_string, extensions=[verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'file_width_value_external_image_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + images = self.verto_extension.required_files['images'] + expected_images = set() + self.assertSetEqual(expected_images, images) + #~ # Doc Tests #~ def test_doc_example_basic(self): - '''Basic example of common usage.''' + '''Basic example of common usage. + ''' test_string = self.read_test_file(self.processor_name, 'doc_example_basic_usage.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True], [ImageBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True], [ImageTagBlockProcessor(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_string = self.read_test_file(self.processor_name, 'doc_example_basic_usage_expected.html', strip=True) @@ -346,10 +404,10 @@ def test_doc_example_override_html(self): test_string = self.read_test_file(self.processor_name, 'doc_example_override_html.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True], [ImageBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True], [ImageTagBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) html_template = self.read_test_file(self.processor_name, 'doc_example_override_html_template.html', strip=True) - verto_extension = VertoExtension([self.processor_name], html_templates={self.processor_name: html_template}) + verto_extension = VertoExtension([self.processor_name], html_templates={self.tag_argument: html_template}) converted_test_string = markdown.markdown(test_string, extensions=[verto_extension]) expected_string = self.read_test_file(self.processor_name, 'doc_example_override_html_expected.html', strip=True) @@ -360,17 +418,15 @@ def test_doc_example_override_html(self): self.assertSetEqual(expected_images, images) def test_doc_example_2_override_html(self): - '''Basic example showing how to override the html-template - for relative files in a specific file only. + '''Basic example showing how to override the html-template for relative files in a specific file only. ''' test_string = self.read_test_file(self.processor_name, 'doc_example_2_override_html.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True], [ImageBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True], [ImageTagBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) html_template = self.read_test_file(self.processor_name, 'doc_example_2_override_html_template.html', strip=True) - link_template = self.read_test_file(self.processor_name, 'doc_example_2_override_link_html_template.html', strip=True) - verto_extension = VertoExtension([self.processor_name], html_templates={self.processor_name: html_template, 'relative-file-link': link_template}) + verto_extension = VertoExtension([self.processor_name], html_templates={self.tag_argument: html_template}) converted_test_string = markdown.markdown(test_string, extensions=[verto_extension]) expected_string = self.read_test_file(self.processor_name, 'doc_example_2_override_html_expected.html', strip=True) diff --git a/verto/tests/PanelTest.py b/verto/tests/PanelTest.py index f66e4e1f..d3f4b4f6 100644 --- a/verto/tests/PanelTest.py +++ b/verto/tests/PanelTest.py @@ -2,11 +2,14 @@ from unittest.mock import Mock from verto.VertoExtension import VertoExtension -from verto.processors.GenericContainerBlockProcessor import GenericContainerBlockProcessor +from verto.processors.PanelBlockProcessor import PanelBlockProcessor from verto.errors.TagNotMatchedError import TagNotMatchedError from verto.errors.ArgumentValueError import ArgumentValueError +from verto.errors.PanelMissingTitleError import PanelMissingTitleError +from verto.errors.PanelMissingSubtitleError import PanelMissingSubtitleError from verto.tests.ProcessorTest import ProcessorTest + class PanelTest(ProcessorTest): '''The panel processor inherits from the generic container. The tests contained here test that arguments and the output @@ -22,7 +25,147 @@ def __init__(self, *args, **kwargs): self.ext = Mock() self.ext.jinja_templates = {self.processor_name: ProcessorTest.loadJinjaTemplate(self, self.processor_name)} self.ext.processor_info = ProcessorTest.loadProcessorInfo(self) - self.block_processor = GenericContainerBlockProcessor(self.processor_name, self.ext, Mock()) + self.block_processor = PanelBlockProcessor(self.ext, Mock()) + + def test_heading_no_subtitle(self): + '''Tests that a heading is parsed correctly + ''' + test_string = self.read_test_file(self.processor_name, 'heading_no_subtitle.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'heading_no_subtitle_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + def test_heading_subtitle_false(self): + '''Tests that a heading is parsed correctly + ''' + test_string = self.read_test_file(self.processor_name, 'heading_subtitle_false.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'heading_subtitle_false_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + def test_heading_subtitle_false_h2_heading_in_panel(self): + '''Tests that a heading is parsed correctly + ''' + test_string = self.read_test_file(self.processor_name, 'heading_subtitle_false_h2_heading_in_panel.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'heading_subtitle_false_h2_heading_in_panel_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + def test_heading_with_subtitle(self): + '''Tests that both a heading and subtitle is parsed correctly + ''' + test_string = self.read_test_file(self.processor_name, 'heading_with_subtitle.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'heading_with_subtitle_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + def test_heading_with_subtitle_h2_heading_in_panel(self): + '''Tests that both a heading and subtitle is parsed correctly + ''' + test_string = self.read_test_file(self.processor_name, 'heading_with_subtitle_h2_heading_in_panel.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, False, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'heading_with_subtitle_h2_heading_in_panel_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + def test_missing_heading_with_subtitle(self): + '''Tests that correct error raised when heading is missing + ''' + test_string = self.read_test_file(self.processor_name, 'missing_heading_with_subtitle.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + self.assertRaises(PanelMissingTitleError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) + + def test_heading_missing_subtitle(self): + '''Tests that correct error raised when subtitle is missing + ''' + test_string = self.read_test_file(self.processor_name, 'heading_missing_subtitle.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + self.assertRaises(PanelMissingSubtitleError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) + + def test_heading_invalid_subtitle_argument(self): + '''Tests that correct error raised when incorrect valude givent for subtitle argument + ''' + test_string = self.read_test_file(self.processor_name, 'heading_invalid_subtitle_argument.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + self.assertRaises(ArgumentValueError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) + + def test_missing_heading_missing_subtitle(self): + '''Tests that correct error raised when heading and subtitle are missing + ''' + test_string = self.read_test_file(self.processor_name, 'missing_heading_missing_subtitle.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + self.assertRaises(PanelMissingTitleError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) + + def test_incorrect_heading_no_subtitle(self): + '''Tests that correct error raised when heading is incorrect + ''' + test_string = self.read_test_file(self.processor_name, 'incorrect_heading_no_subtitle.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + self.assertRaises(PanelMissingTitleError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) + + def test_incorrect_heading_with_subtitle(self): + '''Tests that correct error raised when heading is incorrect + ''' + test_string = self.read_test_file(self.processor_name, 'incorrect_heading_with_subtitle.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + self.assertRaises(PanelMissingTitleError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) + + def test_heading_incorrect_subtitle(self): + '''Tests that correct error raised when subtitle is incorrect + ''' + test_string = self.read_test_file(self.processor_name, 'heading_incorrect_subtitle.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + self.assertRaises(PanelMissingSubtitleError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) + + def test_incorrect_heading_incorrect_subtitle(self): + '''Tests that correct error raised when heading and subtitle are incorrect + ''' + test_string = self.read_test_file(self.processor_name, 'incorrect_heading_incorrect_subtitle.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + self.assertRaises(PanelMissingTitleError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) def test_parses_blank(self): '''Tests that a blank panel is processed with empty content. @@ -30,9 +173,9 @@ def test_parses_blank(self): test_string = self.read_test_file(self.processor_name, 'parses_blank.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) - self.assertRaises(ArgumentValueError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]),test_string) + self.assertRaises(ArgumentValueError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) def test_parses_no_blank_lines_single_paragraph(self): '''Tests that a block of text as content is added to the panel. @@ -40,7 +183,7 @@ def test_parses_no_blank_lines_single_paragraph(self): test_string = self.read_test_file(self.processor_name, 'parses_no_blank_lines_single_paragraph.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True, False, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) expected_string = self.read_test_file(self.processor_name, 'parses_no_blank_lines_single_paragraph_expected.html', strip=True) @@ -52,7 +195,7 @@ def test_parses_expanded_panel(self): test_string = self.read_test_file(self.processor_name, 'parses_expanded_panel.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True, False, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) expected_string = self.read_test_file(self.processor_name, 'parses_expanded_panel_expected.html', strip=True) @@ -64,7 +207,7 @@ def test_parses_always_expanded_panel(self): test_string = self.read_test_file(self.processor_name, 'parses_always_expanded_panel.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True, False, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) expected_string = self.read_test_file(self.processor_name, 'parses_always_expanded_panel_expected.html', strip=True) @@ -77,7 +220,7 @@ def test_parses_blank_lines_multiple_paragraphs(self): test_string = self.read_test_file(self.processor_name, 'parses_blank_lines_multiple_paragraphs.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True, False, False, False, False, False, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True, False, False, False, False, False, False, False, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) expected_string = self.read_test_file(self.processor_name, 'parses_blank_lines_multiple_paragraphs_expected.html', strip=True) @@ -89,7 +232,7 @@ def test_contains_multiple_panels(self): test_string = self.read_test_file(self.processor_name, 'contains_multiple_panels.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True, False, False, True, True, False, True, True, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True, False, False, False, True, True, False, False, False, True, True, False, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) expected_string = self.read_test_file(self.processor_name, 'contains_multiple_panels_expected.html', strip=True) @@ -101,12 +244,22 @@ def test_contains_inner_panel(self): test_string = self.read_test_file(self.processor_name, 'contains_inner_panel.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True, False, True, False, True, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True, False, False, False, True, False, False, False, True, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) expected_string = self.read_test_file(self.processor_name, 'contains_inner_panel_expected.html', strip=True) self.assertEqual(expected_string, converted_test_string) + def test_contains_inner_panel_missing_subtitle(self): + '''Tests that panels can contain other panels and subtitles are rendered correctly. + ''' + test_string = self.read_test_file(self.processor_name, 'contains_inner_panel_missing_subtitle.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, False, False, True, False, False, True, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + self.assertRaises(PanelMissingSubtitleError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) + def test_missing_start_tag(self): '''Tests that TagNotMatchedErrors are thown when an end tag is encountered alone. @@ -114,7 +267,7 @@ def test_missing_start_tag(self): test_string = self.read_test_file(self.processor_name, 'missing_start_tag.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True, False, True, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True, False, False, True, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) self.assertRaises(TagNotMatchedError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) @@ -125,7 +278,7 @@ def test_missing_end_tag(self): test_string = self.read_test_file(self.processor_name, 'missing_end_tag.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True, False, True, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True, False, False, True, True, False], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) self.assertRaises(TagNotMatchedError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) @@ -136,19 +289,17 @@ def test_missing_tag_inner(self): test_string = self.read_test_file(self.processor_name, 'missing_tag_inner.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True, True, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True, False, False, True, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) self.assertRaises(TagNotMatchedError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) def test_contains_inner_image(self): - '''Tests that other processors within a panel - still renders correctly. - ''' - verto_extension = VertoExtension([self.processor_name, 'image'], {}) + '''Tests that other processors within a panel still renders correctly.''' + verto_extension = VertoExtension([self.processor_name, 'image-container'], {}) test_string = self.read_test_file(self.processor_name, 'contains_inner_image.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True, False, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True, False, False, False, False, False, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) converted_test_string = markdown.markdown(test_string, extensions=[verto_extension]) expected_string = self.read_test_file(self.processor_name, 'contains_inner_image_expected.html', strip=True) @@ -160,7 +311,7 @@ def test_panel_in_numbered_list(self): test_string = self.read_test_file(self.processor_name, 'panel_in_numbered_list.md') blocks = self.to_blocks(test_string) - self.assertListEqual([False, False, False, True, False, True, False], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([False, False, False, True, False, False, False, True, False], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) expected_string = self.read_test_file(self.processor_name, 'panel_in_numbered_list_expected.html', strip=True) @@ -172,7 +323,7 @@ def test_panel_only_in_numbered_list(self): test_string = self.read_test_file(self.processor_name, 'panel_only_in_numbered_list.md') blocks = self.to_blocks(test_string) - self.assertListEqual([False, False, False, False, True, False], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([False, False, False, False, False, False, True, False], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) expected_string = self.read_test_file(self.processor_name, 'panel_only_in_numbered_list_expected.html', strip=True) @@ -188,7 +339,7 @@ def test_doc_example_basic(self): test_string = self.read_test_file(self.processor_name, 'doc_example_basic_usage.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True, False, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) 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) @@ -200,7 +351,7 @@ def test_doc_example_override_html(self): test_string = self.read_test_file(self.processor_name, 'doc_example_override_html.md') blocks = self.to_blocks(test_string) - self.assertListEqual([True, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + self.assertListEqual([True, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) html_template = self.read_test_file(self.processor_name, 'doc_example_override_html_template.html', strip=True) verto_extension = VertoExtension([self.processor_name], html_templates={self.processor_name: html_template}) diff --git a/verto/tests/RelativeLinkTest.py b/verto/tests/RelativeLinkTest.py index a0b636f9..ae9694e8 100644 --- a/verto/tests/RelativeLinkTest.py +++ b/verto/tests/RelativeLinkTest.py @@ -43,6 +43,42 @@ def test_long_path(self): expected_string = self.read_test_file(self.processor_name, 'long_path_expected.html', strip=True).strip() self.assertEqual(expected_string, converted_test_string) + def test_query_parameter(self): + '''Tests that paths with query parameter work. + ''' + test_string = self.read_test_file(self.processor_name, 'query_parameter.md') + + processor = RelativeLinkPattern(self.ext, self.md.parser) + self.assertIsNotNone(re.search(processor.compiled_re, test_string)) + + converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'query_parameter_expected.html', strip=True).strip() + self.assertEqual(expected_string, converted_test_string) + + def test_multiple_query_parameters(self): + '''Tests that paths with multiple query parameters work. + ''' + test_string = self.read_test_file(self.processor_name, 'multiple_query_parameters.md') + + processor = RelativeLinkPattern(self.ext, self.md.parser) + self.assertIsNotNone(re.search(processor.compiled_re, test_string)) + + converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'multiple_query_parameters_expected.html', strip=True).strip() + self.assertEqual(expected_string, converted_test_string) + + def test_trailing_question_mark(self): + '''Tests that paths with trailing question marks. + ''' + test_string = self.read_test_file(self.processor_name, 'trailing_question_mark.md') + + processor = RelativeLinkPattern(self.ext, self.md.parser) + self.assertIsNotNone(re.search(processor.compiled_re, test_string)) + + converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'trailing_question_mark_expected.html', strip=True).strip() + self.assertEqual(expected_string, converted_test_string) + def test_multiple_links(self): '''Tests that multiple links are processed. ''' diff --git a/verto/tests/assets/comment/comment_within_block_container.md b/verto/tests/assets/comment/comment_within_block_container.md index 80b64a2b..ae602cfa 100644 --- a/verto/tests/assets/comment/comment_within_block_container.md +++ b/verto/tests/assets/comment/comment_within_block_container.md @@ -1,4 +1,6 @@ -{panel type="lipsum" title="Lipsum Lorem"} +{panel type="lipsum"} + +# Lipsum Lorem {comment This is a comment for other authors to read} diff --git a/verto/tests/assets/configuration/all_processors.md b/verto/tests/assets/configuration/all_processors.md index b3178d32..f73584be 100644 --- a/verto/tests/assets/configuration/all_processors.md +++ b/verto/tests/assets/configuration/all_processors.md @@ -8,13 +8,23 @@ This is a sentence. Check out this [resource](resource/134). -{panel type="teacher-note" title="Teacher Note" subtitle="Guides for Algorithms"} +{panel type="teacher-note" subtitle="true"} + +# Teacher Note + +## Guides for Algorithms This text is the panel's contents. {panel end} -{image file-path="http://placehold.it/350x150" caption="Placeholder image" source="https://placehold.it/" hover-text="This is hover text" alignment="left"} +{image file-path="http://placehold.it/350x150" caption="true" source="https://placehold.it/" hover-text="This is hover text" alignment="left"} + +Dancing with our hands tied. + +{image end} + +{image file-path="http://placehold.it/250x50" caption="false" source="https://placehold.it/" hover-text="This is hover text" alignment="left"} {boxed-text} diff --git a/verto/tests/assets/configuration/all_processors_custom_html_expected.html b/verto/tests/assets/configuration/all_processors_custom_html_expected.html index 5c2190d4..36e2992d 100644 --- a/verto/tests/assets/configuration/all_processors_custom_html_expected.html +++ b/verto/tests/assets/configuration/all_processors_custom_html_expected.html @@ -20,7 +20,7 @@

This text is the panel's contents.

-
+

Computer Science Report for 2.44

Put your introduction to what bits are here.

diff --git a/verto/tests/assets/configuration/all_processors_except_comment_expected.html b/verto/tests/assets/configuration/all_processors_except_comment_expected.html index 7e832970..1bb2e934 100644 --- a/verto/tests/assets/configuration/all_processors_except_comment_expected.html +++ b/verto/tests/assets/configuration/all_processors_except_comment_expected.html @@ -23,7 +23,11 @@

-

Placeholder image

+

Dancing with our hands tied.

+

Source

+
+
+

Source

diff --git a/verto/tests/assets/configuration/all_processors_expected.html b/verto/tests/assets/configuration/all_processors_expected.html index 760895c5..40f8370c 100644 --- a/verto/tests/assets/configuration/all_processors_expected.html +++ b/verto/tests/assets/configuration/all_processors_expected.html @@ -22,7 +22,11 @@

-

Placeholder image

+

Dancing with our hands tied.

+

Source

+
+
+

Source

diff --git a/verto/tests/assets/configuration/custom_processors_custom_templates_expected.html b/verto/tests/assets/configuration/custom_processors_custom_templates_expected.html index d10198a7..4274fac0 100644 --- a/verto/tests/assets/configuration/custom_processors_custom_templates_expected.html +++ b/verto/tests/assets/configuration/custom_processors_custom_templates_expected.html @@ -3,9 +3,14 @@

Example Title

Example Title 2

{comment This is a comment for other authors to read}

Check out this resource.

-

{panel type="teacher-note" title="Teacher Note" subtitle="Guides for Algorithms"}

+

{panel type="teacher-note" subtitle="true"}

+

Teacher Note

+

Guides for Algorithms

This text is the panel's contents.

{panel end}

+

{image file-path="http://placehold.it/350x150" caption="true" source="https://placehold.it/" hover-text="This is hover text" alignment="left"}

+

Dancing with our hands tied.

+

{image end}

Computer Science Report for 2.44

Put your introduction to what bits are here.

diff --git a/verto/tests/assets/configuration/custom_processors_expected.html b/verto/tests/assets/configuration/custom_processors_expected.html index 21a4ddbb..981fad7c 100644 --- a/verto/tests/assets/configuration/custom_processors_expected.html +++ b/verto/tests/assets/configuration/custom_processors_expected.html @@ -13,9 +13,10 @@

Example Title 2

-

Placeholder image

+

Dancing with our hands tied.

Source

+

{image file-path="http://placehold.it/250x50" caption="false" source="https://placehold.it/" hover-text="This is hover text" alignment="left"}

{boxed-text}

Computer Science Report for 2.44

Put your introduction to what bits are here.

diff --git a/verto/tests/assets/configuration/multiline_templates_expected.html b/verto/tests/assets/configuration/multiline_templates_expected.html index 6ecd7608..f9034627 100644 --- a/verto/tests/assets/configuration/multiline_templates_expected.html +++ b/verto/tests/assets/configuration/multiline_templates_expected.html @@ -23,6 +23,9 @@

+
+ +

Computer Science Report for 2.44

diff --git a/verto/tests/assets/image-container/align_center.md b/verto/tests/assets/image-container/align_center.md new file mode 100644 index 00000000..b26706b7 --- /dev/null +++ b/verto/tests/assets/image-container/align_center.md @@ -0,0 +1,5 @@ +{image file-path="computer-studying-turing-test.png" caption="true" alignment="center"} + +This is a caption for a computer studying the turing test. + +{image end} diff --git a/verto/tests/assets/image-container/align_center_expected.html b/verto/tests/assets/image-container/align_center_expected.html new file mode 100644 index 00000000..262ae566 --- /dev/null +++ b/verto/tests/assets/image-container/align_center_expected.html @@ -0,0 +1,4 @@ +
+ +

This is a caption for a computer studying the turing test.

+
diff --git a/verto/tests/assets/image/align_center.md b/verto/tests/assets/image-container/align_left.md similarity index 55% rename from verto/tests/assets/image/align_center.md rename to verto/tests/assets/image-container/align_left.md index b1f9ad8e..88ac54c1 100644 --- a/verto/tests/assets/image/align_center.md +++ b/verto/tests/assets/image-container/align_left.md @@ -1 +1,5 @@ -{image file-path="computer-studying-turing-test.png" alignment="center"} +{image file-path="computer-studying-turing-test.png" alignment="left" caption="true"} + +Cats cats cats. + +{image end} diff --git a/verto/tests/assets/image-container/align_left_expected.html b/verto/tests/assets/image-container/align_left_expected.html new file mode 100644 index 00000000..2369410c --- /dev/null +++ b/verto/tests/assets/image-container/align_left_expected.html @@ -0,0 +1,4 @@ +
+ +

Cats cats cats.

+
diff --git a/verto/tests/assets/image-container/align_right.md b/verto/tests/assets/image-container/align_right.md new file mode 100644 index 00000000..4d997b94 --- /dev/null +++ b/verto/tests/assets/image-container/align_right.md @@ -0,0 +1,5 @@ +{image caption="true" file-path="computer-studying-turing-test.png" alignment="right"} + +Hey hey hey, look who it is! A caption! + +{image end} diff --git a/verto/tests/assets/image-container/align_right_expected.html b/verto/tests/assets/image-container/align_right_expected.html new file mode 100644 index 00000000..dfb21c1a --- /dev/null +++ b/verto/tests/assets/image-container/align_right_expected.html @@ -0,0 +1,4 @@ +
+ +

Hey hey hey, look who it is! A caption!

+
diff --git a/verto/tests/assets/image-container/align_undefined_error.md b/verto/tests/assets/image-container/align_undefined_error.md new file mode 100644 index 00000000..e9e15de6 --- /dev/null +++ b/verto/tests/assets/image-container/align_undefined_error.md @@ -0,0 +1,5 @@ +{image file-path="computer-studying-turing-test.png" alignment="around-about-here" caption="true"} + +This is the caption. + +{image end} diff --git a/verto/tests/assets/image-container/alt_hover_caption.md b/verto/tests/assets/image-container/alt_hover_caption.md new file mode 100644 index 00000000..1d28391f --- /dev/null +++ b/verto/tests/assets/image-container/alt_hover_caption.md @@ -0,0 +1,19 @@ +Here's another FSA to consider: + +{image file-path="finite-state-automata-no-trap-example.png" hover-text="hover text is me" caption="true" alt="FSA with missing transitions"} + +This is the caption. + +{image end} + +It's fairly clear what it will accept: strings like "ab", "abab", "abababababab", and, of course {math}\epsilon{math end}. +But there are some missing transitions: if you are in state 1 and get a "b" there's nowhere to go. +If an input cannot be accepted, it will be rejected, as in this case. We could have put in a trap state to make this clear: + +{image file-path="finite-state-automata-trap-added-example.png" caption="true" alt="FSA with missing transitions" hover-text="also some hover text"} + +This is the caption. + +{image end} + +But things can get out of hand. What if there are more letters in the alphabet? We'd need something like this: diff --git a/verto/tests/assets/image-container/alt_hover_caption_expected.html b/verto/tests/assets/image-container/alt_hover_caption_expected.html new file mode 100644 index 00000000..6b3e7951 --- /dev/null +++ b/verto/tests/assets/image-container/alt_hover_caption_expected.html @@ -0,0 +1,13 @@ +

Here's another FSA to consider:

+
+FSA with missing transitions +

This is the caption.

+
+

It's fairly clear what it will accept: strings like "ab", "abab", "abababababab", and, of course {math}\epsilon{math end}. +But there are some missing transitions: if you are in state 1 and get a "b" there's nowhere to go. +If an input cannot be accepted, it will be rejected, as in this case. We could have put in a trap state to make this clear:

+
+FSA with missing transitions +

This is the caption.

+
+

But things can get out of hand. What if there are more letters in the alphabet? We'd need something like this:

diff --git a/verto/tests/assets/image-container/caption_false.md b/verto/tests/assets/image-container/caption_false.md new file mode 100644 index 00000000..b62e915e --- /dev/null +++ b/verto/tests/assets/image-container/caption_false.md @@ -0,0 +1,7 @@ +Here's another FSA to consider: + +{image file-path="cats.png" alt="FSA with missing transitions" caption="false"} + +It's fairly clear what it will accept: strings like "ab", "abab", "abababababab", and, of course {math}\epsilon{math end}. +But there are some missing transitions: if you are in state 1 and get a "b" there's nowhere to go. +If an input cannot be accepted, it will be rejected, as in this case. We could have put in a trap state to make this clear: diff --git a/verto/tests/assets/image-container/caption_false_expected.html b/verto/tests/assets/image-container/caption_false_expected.html new file mode 100644 index 00000000..b48079d5 --- /dev/null +++ b/verto/tests/assets/image-container/caption_false_expected.html @@ -0,0 +1,5 @@ +

Here's another FSA to consider:

+

{image file-path="cats.png" alt="FSA with missing transitions" caption="false"}

+

It's fairly clear what it will accept: strings like "ab", "abab", "abababababab", and, of course {math}\epsilon{math end}. +But there are some missing transitions: if you are in state 1 and get a "b" there's nowhere to go. +If an input cannot be accepted, it will be rejected, as in this case. We could have put in a trap state to make this clear:

diff --git a/verto/tests/assets/image-container/caption_true.md b/verto/tests/assets/image-container/caption_true.md new file mode 100644 index 00000000..60eecedd --- /dev/null +++ b/verto/tests/assets/image-container/caption_true.md @@ -0,0 +1,11 @@ +Here's another FSA to consider: + +{image file-path="cats.png" alt="FSA with missing transitions" caption="true"} + +This is a caption. + +{image end} + +It's fairly clear what it will accept: strings like "ab", "abab", "abababababab", and, of course {math}\epsilon{math end}. +But there are some missing transitions: if you are in state 1 and get a "b" there's nowhere to go. +If an input cannot be accepted, it will be rejected, as in this case. We could have put in a trap state to make this clear: diff --git a/verto/tests/assets/image-container/caption_true_expected.html b/verto/tests/assets/image-container/caption_true_expected.html new file mode 100644 index 00000000..f641f8c1 --- /dev/null +++ b/verto/tests/assets/image-container/caption_true_expected.html @@ -0,0 +1,8 @@ +

Here's another FSA to consider:

+
+FSA with missing transitions +

This is a caption.

+
+

It's fairly clear what it will accept: strings like "ab", "abab", "abababababab", and, of course {math}\epsilon{math end}. +But there are some missing transitions: if you are in state 1 and get a "b" there's nowhere to go. +If an input cannot be accepted, it will be rejected, as in this case. We could have put in a trap state to make this clear:

diff --git a/verto/tests/assets/image/multiple_internal_image.md b/verto/tests/assets/image-container/caption_true_missing_end_tag.md similarity index 71% rename from verto/tests/assets/image/multiple_internal_image.md rename to verto/tests/assets/image-container/caption_true_missing_end_tag.md index 42376c4b..7339c63d 100644 --- a/verto/tests/assets/image/multiple_internal_image.md +++ b/verto/tests/assets/image-container/caption_true_missing_end_tag.md @@ -1,9 +1,7 @@ Imagine we have the following simple black and white image. -{image file-path="pixel-diamond.png" alt="A diamond shape made out of pixels"} +{image file-path="pixel-diamond.png" alt="A diamond shape made out of pixels" caption="true"} -{image file-path="Lipsum.png" alt="A diamond shape made out of pixels"} - -{image file-path="pixel-diamond.png" alt="A diamond shape made out of pixels"} +This is the caption. One very simple way a computer can store this image in binary is by using a format where '0' means white and '1' means black (this is a "bit map", because we've mapped the pixels onto the values of bits). Using this method, the above image would be represented in the following way: diff --git a/verto/tests/assets/image/internal_image.md b/verto/tests/assets/image-container/caption_true_not_provided.md similarity index 84% rename from verto/tests/assets/image/internal_image.md rename to verto/tests/assets/image-container/caption_true_not_provided.md index 49c6287f..07d1ce33 100644 --- a/verto/tests/assets/image/internal_image.md +++ b/verto/tests/assets/image-container/caption_true_not_provided.md @@ -1,5 +1,7 @@ Imagine we have the following simple black and white image. -{image file-path="pixel-diamond.png" alt="A diamond shape made out of pixels"} +{image file-path="pixel-diamond.png" alt="A diamond shape made out of pixels" caption="true"} -One very simple way a computer can store this image in binary is by using a format where '0' means white and '1' means black (this is a "bit map", because we've mapped the pixels onto the values of bits). Using this method, the above image would be represented in the following way: \ No newline at end of file +{image end} + +One very simple way a computer can store this image in binary is by using a format where '0' means white and '1' means black (this is a "bit map", because we've mapped the pixels onto the values of bits). Using this method, the above image would be represented in the following way: diff --git a/verto/tests/assets/image-container/caption_true_not_provided_numbered_list.md b/verto/tests/assets/image-container/caption_true_not_provided_numbered_list.md new file mode 100644 index 00000000..ecb5bf2e --- /dev/null +++ b/verto/tests/assets/image-container/caption_true_not_provided_numbered_list.md @@ -0,0 +1,13 @@ +1. Lipsum + + * Ichi + * Ni + * San + +2. Lorem + + {image file-path="http://placehold.it/350x150" caption="true" source="https://placehold.it/" hover-text="This is hover text" alignment="left"} + + {image end} + +3. Ipsem diff --git a/verto/tests/assets/image-container/caption_true_numbered_list_missing_end_tag.md b/verto/tests/assets/image-container/caption_true_numbered_list_missing_end_tag.md new file mode 100644 index 00000000..3183eb06 --- /dev/null +++ b/verto/tests/assets/image-container/caption_true_numbered_list_missing_end_tag.md @@ -0,0 +1,13 @@ +1. Lipsum + + * Ichi + * Ni + * San + +2. Lorem + + {image file-path="http://placehold.it/350x150" caption="true" source="https://placehold.it/" hover-text="This is hover text" alignment="left"} + + This is a caption + +3. Ipsem diff --git a/verto/tests/assets/image-container/contains_alt.md b/verto/tests/assets/image-container/contains_alt.md new file mode 100644 index 00000000..be75ef92 --- /dev/null +++ b/verto/tests/assets/image-container/contains_alt.md @@ -0,0 +1,5 @@ +{image file-path="computer-studying-turing-test.png" caption="true" alt="Lipsum"} + +Dress. + +{image end} diff --git a/verto/tests/assets/image/contains_alt_expected.html b/verto/tests/assets/image-container/contains_alt_expected.html similarity index 87% rename from verto/tests/assets/image/contains_alt_expected.html rename to verto/tests/assets/image-container/contains_alt_expected.html index 10225441..8f82f93a 100644 --- a/verto/tests/assets/image/contains_alt_expected.html +++ b/verto/tests/assets/image-container/contains_alt_expected.html @@ -1,3 +1,4 @@
Lipsum +

Dress.

diff --git a/verto/tests/assets/image/contains_caption_expected.html b/verto/tests/assets/image-container/contains_caption_expected.html similarity index 100% rename from verto/tests/assets/image/contains_caption_expected.html rename to verto/tests/assets/image-container/contains_caption_expected.html diff --git a/verto/tests/assets/image-container/contains_caption_link.md b/verto/tests/assets/image-container/contains_caption_link.md new file mode 100644 index 00000000..1b743b6a --- /dev/null +++ b/verto/tests/assets/image-container/contains_caption_link.md @@ -0,0 +1,5 @@ +{image file-path="computer-studying-turing-test.png" caption="true" caption-link="example.com"} + +Lipsum + +{image end} diff --git a/verto/tests/assets/image/contains_caption_link_expected.html b/verto/tests/assets/image-container/contains_caption_link_expected.html similarity index 100% rename from verto/tests/assets/image/contains_caption_link_expected.html rename to verto/tests/assets/image-container/contains_caption_link_expected.html diff --git a/verto/tests/assets/image-container/contains_hover_text.md b/verto/tests/assets/image-container/contains_hover_text.md new file mode 100644 index 00000000..715bd4d0 --- /dev/null +++ b/verto/tests/assets/image-container/contains_hover_text.md @@ -0,0 +1,5 @@ +{image file-path="computer-studying-turing-test.png" hover-text="Lipsum" caption="true"} + +This is why we can't have nice things. + +{image end} diff --git a/verto/tests/assets/image-container/contains_hover_text_expected.html b/verto/tests/assets/image-container/contains_hover_text_expected.html new file mode 100644 index 00000000..17a98075 --- /dev/null +++ b/verto/tests/assets/image-container/contains_hover_text_expected.html @@ -0,0 +1,4 @@ +
+ +

This is why we can't have nice things.

+
diff --git a/verto/tests/assets/image/contains_multiple_images.md b/verto/tests/assets/image-container/contains_multiple_images_some_captions.md similarity index 72% rename from verto/tests/assets/image/contains_multiple_images.md rename to verto/tests/assets/image-container/contains_multiple_images_some_captions.md index be934884..5d31983a 100644 --- a/verto/tests/assets/image/contains_multiple_images.md +++ b/verto/tests/assets/image-container/contains_multiple_images_some_captions.md @@ -1,15 +1,21 @@ Here's another FSA to consider: -{image file-path="finite-state-automata-no-trap-example.png" alt="FSA with missing transitions"} +{image file-path="finite-state-automata-no-trap-example.png" caption="true" alt="FSA with missing transitions"} + +Reputation precedes me. + +{image end} It's fairly clear what it will accept: strings like "ab", "abab", "abababababab", and, of course {math}\epsilon{math end}. But there are some missing transitions: if you are in state 1 and get a "b" there's nowhere to go. If an input cannot be accepted, it will be rejected, as in this case. We could have put in a trap state to make this clear: -{image file-path="finite-state-automata-trap-added-example.png" alt="FSA with missing transitions"} +{image file-path="finite-state-automata-trap-added-example.png" caption="true" alt="FSA with missing transitions"} + +I wanna be your end game -But things can get out of hand. What if there are more letters in the alphabet? We'd need something like this: +{image end} {image file-path="finite-state-automata-trap-added-extreme-example.png" alt="FSA with missing transitions"} -So, instead, we just say that any unspecified transition causes the input to be rejected (that is, it behaves as though it goes into a trap state). In other words, it's fine to use the simple version above, with just two transitions. \ No newline at end of file +So, instead, we just say that any unspecified transition causes the input to be rejected (that is, it behaves as though it goes into a trap state). In other words, it's fine to use the simple version above, with just two transitions. diff --git a/verto/tests/assets/image/contains_multiple_images_expected.html b/verto/tests/assets/image-container/contains_multiple_images_some_captions_expected.html similarity index 77% rename from verto/tests/assets/image/contains_multiple_images_expected.html rename to verto/tests/assets/image-container/contains_multiple_images_some_captions_expected.html index e266029e..b26f1323 100644 --- a/verto/tests/assets/image/contains_multiple_images_expected.html +++ b/verto/tests/assets/image-container/contains_multiple_images_some_captions_expected.html @@ -1,15 +1,14 @@

Here's another FSA to consider:

FSA with missing transitions +

Reputation precedes me.

It's fairly clear what it will accept: strings like "ab", "abab", "abababababab", and, of course {math}\epsilon{math end}. But there are some missing transitions: if you are in state 1 and get a "b" there's nowhere to go. If an input cannot be accepted, it will be rejected, as in this case. We could have put in a trap state to make this clear:

FSA with missing transitions +

I wanna be your end game

-

But things can get out of hand. What if there are more letters in the alphabet? We'd need something like this:

-
-FSA with missing transitions -
+

{image file-path="finite-state-automata-trap-added-extreme-example.png" alt="FSA with missing transitions"}

So, instead, we just say that any unspecified transition causes the input to be rejected (that is, it behaves as though it goes into a trap state). In other words, it's fine to use the simple version above, with just two transitions.

diff --git a/verto/tests/assets/image-container/contains_source.md b/verto/tests/assets/image-container/contains_source.md new file mode 100644 index 00000000..25aeb33f --- /dev/null +++ b/verto/tests/assets/image-container/contains_source.md @@ -0,0 +1,5 @@ +{image caption="true" file-path="computer-studying-turing-test.png" source="example.com"} + +Dancing with our hands tied. + +{image end} diff --git a/verto/tests/assets/image-container/contains_source_expected.html b/verto/tests/assets/image-container/contains_source_expected.html new file mode 100644 index 00000000..ba041d06 --- /dev/null +++ b/verto/tests/assets/image-container/contains_source_expected.html @@ -0,0 +1,5 @@ +
+ +

Dancing with our hands tied.

+

Source

+
diff --git a/verto/tests/assets/image-container/doc_example_2_override_html.md b/verto/tests/assets/image-container/doc_example_2_override_html.md new file mode 100644 index 00000000..b9349730 --- /dev/null +++ b/verto/tests/assets/image-container/doc_example_2_override_html.md @@ -0,0 +1,5 @@ +{image file-path="apple.png" caption="true"} + +Don't pretend it's such a mystery. + +{image end} diff --git a/verto/tests/assets/image-container/doc_example_2_override_html_expected.html b/verto/tests/assets/image-container/doc_example_2_override_html_expected.html new file mode 100644 index 00000000..b5f8b829 --- /dev/null +++ b/verto/tests/assets/image-container/doc_example_2_override_html_expected.html @@ -0,0 +1,4 @@ +
+ +

Caption:

Don't pretend it's such a mystery. +
diff --git a/verto/tests/assets/image-container/doc_example_2_override_html_template.html b/verto/tests/assets/image-container/doc_example_2_override_html_template.html new file mode 100644 index 00000000..8c8660e2 --- /dev/null +++ b/verto/tests/assets/image-container/doc_example_2_override_html_template.html @@ -0,0 +1,4 @@ +
+ +

Caption:

{{ caption }} +
diff --git a/verto/tests/assets/image-container/doc_example_basic_usage.md b/verto/tests/assets/image-container/doc_example_basic_usage.md new file mode 100644 index 00000000..c9946610 --- /dev/null +++ b/verto/tests/assets/image-container/doc_example_basic_usage.md @@ -0,0 +1,5 @@ +{image file-path="http://placehold.it/350x150" caption="true" source="https://placehold.it/" hover-text="This is hover text" alignment="left"} + +This is the caption text. + +{image end} diff --git a/verto/tests/assets/image-container/doc_example_basic_usage_expected.html b/verto/tests/assets/image-container/doc_example_basic_usage_expected.html new file mode 100644 index 00000000..a0ecbb06 --- /dev/null +++ b/verto/tests/assets/image-container/doc_example_basic_usage_expected.html @@ -0,0 +1,5 @@ +
+ +

This is the caption text.

+

Source

+
diff --git a/verto/tests/assets/image-container/doc_example_override_html.md b/verto/tests/assets/image-container/doc_example_override_html.md new file mode 100644 index 00000000..06449b4b --- /dev/null +++ b/verto/tests/assets/image-container/doc_example_override_html.md @@ -0,0 +1,5 @@ +{image file-path="http://placehold.it/350x150" caption="true" source="https://placehold.it/"} + +This is the caption text. + +{image end} diff --git a/verto/tests/assets/image-container/doc_example_override_html_expected.html b/verto/tests/assets/image-container/doc_example_override_html_expected.html new file mode 100644 index 00000000..e1a30e24 --- /dev/null +++ b/verto/tests/assets/image-container/doc_example_override_html_expected.html @@ -0,0 +1,4 @@ +
+ +

This is the caption text.

+
diff --git a/verto/tests/assets/image-container/doc_example_override_html_template.html b/verto/tests/assets/image-container/doc_example_override_html_template.html new file mode 100644 index 00000000..886e565a --- /dev/null +++ b/verto/tests/assets/image-container/doc_example_override_html_template.html @@ -0,0 +1,4 @@ +
+ +

{{ caption }}

+
diff --git a/verto/tests/assets/image-container/external_image.md b/verto/tests/assets/image-container/external_image.md new file mode 100644 index 00000000..31d6bd00 --- /dev/null +++ b/verto/tests/assets/image-container/external_image.md @@ -0,0 +1,7 @@ +{image file-path="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3b/UDP_encapsulation.svg/800px-UDP_encapsulation.svg.png" caption="true" alt="UDP Encapsulation"} + +So it goes... + +{image end} + +TODO: Upload this image to field guide, and link back to svg page. diff --git a/verto/tests/assets/image-container/external_image_expected.html b/verto/tests/assets/image-container/external_image_expected.html new file mode 100644 index 00000000..380665b8 --- /dev/null +++ b/verto/tests/assets/image-container/external_image_expected.html @@ -0,0 +1,5 @@ +
+UDP Encapsulation +

So it goes...

+
+

TODO: Upload this image to field guide, and link back to svg page.

diff --git a/verto/tests/assets/image-container/file_invalid_width_value_1.md b/verto/tests/assets/image-container/file_invalid_width_value_1.md new file mode 100644 index 00000000..50779ab5 --- /dev/null +++ b/verto/tests/assets/image-container/file_invalid_width_value_1.md @@ -0,0 +1,5 @@ +{image file-path="path/to/image@.png" caption="true" hover-text="This is hover text" alignment="left"} + +This is the caption text. + +{image end} diff --git a/verto/tests/assets/image-container/file_invalid_width_value_1_expected.html b/verto/tests/assets/image-container/file_invalid_width_value_1_expected.html new file mode 100644 index 00000000..1fa1577a --- /dev/null +++ b/verto/tests/assets/image-container/file_invalid_width_value_1_expected.html @@ -0,0 +1,4 @@ +
+ +

This is the caption text.

+
diff --git a/verto/tests/assets/image-container/file_invalid_width_value_1_html_template.html b/verto/tests/assets/image-container/file_invalid_width_value_1_html_template.html new file mode 100644 index 00000000..75fe263f --- /dev/null +++ b/verto/tests/assets/image-container/file_invalid_width_value_1_html_template.html @@ -0,0 +1,27 @@ +
+ 400 %}, {{ "{% static '" }}{{ file_path }}@400px{{ file_extension }}{{ "' %}" }} 400w{% endif -%} +{% if file_width_value > 600 %}, {{ "{% static '" }}{{ file_path }}@600px{{ file_extension }}{{ "' %}" }} 600w{% endif -%} +{% if file_width_value > 800 %}, {{ "{% static '" }}{{ file_path }}@800px{{ file_extension }}{{ "' %}" }} 800w{% endif -%}" +{%- endif -%} +src="{{ "{% static '" }}{{ full_file_path }}{{ "' %}" }}" +{%- else -%} +src="{{ full_file_path }}" +{%- endif -%} +{%- endautoescape -%} +{% if alt %} alt="{{ alt }}" {% endif -%} +{%- if hover_text %} title="{{ hover_text }}" {% endif -%} + class="{% if alignment == 'left' %}left-align{% elif alignment =='center' %}center-align{% elif alignment =='right' %}right-align{% endif %}"/> +{% if caption and caption_link -%} +

{{ caption }}

+{%- elif caption -%} +

{{ caption }}

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

Source

+{%- endif -%} +
diff --git a/verto/tests/assets/image-container/file_invalid_width_value_2.md b/verto/tests/assets/image-container/file_invalid_width_value_2.md new file mode 100644 index 00000000..67ee5a4f --- /dev/null +++ b/verto/tests/assets/image-container/file_invalid_width_value_2.md @@ -0,0 +1,5 @@ +{image file-path="path/to/image@em20.png" caption="true" hover-text="This is hover text" alignment="left"} + +This is the caption text. + +{image end} diff --git a/verto/tests/assets/image-container/file_invalid_width_value_2_expected.html b/verto/tests/assets/image-container/file_invalid_width_value_2_expected.html new file mode 100644 index 00000000..5d932441 --- /dev/null +++ b/verto/tests/assets/image-container/file_invalid_width_value_2_expected.html @@ -0,0 +1,4 @@ +
+ +

This is the caption text.

+
diff --git a/verto/tests/assets/image-container/file_invalid_width_value_2_html_template.html b/verto/tests/assets/image-container/file_invalid_width_value_2_html_template.html new file mode 100644 index 00000000..75fe263f --- /dev/null +++ b/verto/tests/assets/image-container/file_invalid_width_value_2_html_template.html @@ -0,0 +1,27 @@ +
+ 400 %}, {{ "{% static '" }}{{ file_path }}@400px{{ file_extension }}{{ "' %}" }} 400w{% endif -%} +{% if file_width_value > 600 %}, {{ "{% static '" }}{{ file_path }}@600px{{ file_extension }}{{ "' %}" }} 600w{% endif -%} +{% if file_width_value > 800 %}, {{ "{% static '" }}{{ file_path }}@800px{{ file_extension }}{{ "' %}" }} 800w{% endif -%}" +{%- endif -%} +src="{{ "{% static '" }}{{ full_file_path }}{{ "' %}" }}" +{%- else -%} +src="{{ full_file_path }}" +{%- endif -%} +{%- endautoescape -%} +{% if alt %} alt="{{ alt }}" {% endif -%} +{%- if hover_text %} title="{{ hover_text }}" {% endif -%} + class="{% if alignment == 'left' %}left-align{% elif alignment =='center' %}center-align{% elif alignment =='right' %}right-align{% endif %}"/> +{% if caption and caption_link -%} +

{{ caption }}

+{%- elif caption -%} +

{{ caption }}

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

Source

+{%- endif -%} +
diff --git a/verto/tests/assets/image-container/file_width_value.md b/verto/tests/assets/image-container/file_width_value.md new file mode 100644 index 00000000..018577b6 --- /dev/null +++ b/verto/tests/assets/image-container/file_width_value.md @@ -0,0 +1,5 @@ +{image file-path="path/to/image@500px.png" caption="true" hover-text="This is hover text" alignment="left"} + +This is the caption text. + +{image end} diff --git a/verto/tests/assets/image-container/file_width_value_expected.html b/verto/tests/assets/image-container/file_width_value_expected.html new file mode 100644 index 00000000..eb89417f --- /dev/null +++ b/verto/tests/assets/image-container/file_width_value_expected.html @@ -0,0 +1,4 @@ +
+ +

This is the caption text.

+
diff --git a/verto/tests/assets/image-container/file_width_value_external_image.md b/verto/tests/assets/image-container/file_width_value_external_image.md new file mode 100644 index 00000000..40cb4077 --- /dev/null +++ b/verto/tests/assets/image-container/file_width_value_external_image.md @@ -0,0 +1,5 @@ +{image file-path="https://www.verto.io/images/image@200px.png" caption="true" hover-text="This is hover text" alignment="left"} + +This is the caption text. + +{image end} diff --git a/verto/tests/assets/image-container/file_width_value_external_image_expected.html b/verto/tests/assets/image-container/file_width_value_external_image_expected.html new file mode 100644 index 00000000..838b6e67 --- /dev/null +++ b/verto/tests/assets/image-container/file_width_value_external_image_expected.html @@ -0,0 +1,4 @@ +
+ +

This is the caption text.

+
diff --git a/verto/tests/assets/image-container/file_width_value_external_image_html_template.html b/verto/tests/assets/image-container/file_width_value_external_image_html_template.html new file mode 100644 index 00000000..75fe263f --- /dev/null +++ b/verto/tests/assets/image-container/file_width_value_external_image_html_template.html @@ -0,0 +1,27 @@ +
+ 400 %}, {{ "{% static '" }}{{ file_path }}@400px{{ file_extension }}{{ "' %}" }} 400w{% endif -%} +{% if file_width_value > 600 %}, {{ "{% static '" }}{{ file_path }}@600px{{ file_extension }}{{ "' %}" }} 600w{% endif -%} +{% if file_width_value > 800 %}, {{ "{% static '" }}{{ file_path }}@800px{{ file_extension }}{{ "' %}" }} 800w{% endif -%}" +{%- endif -%} +src="{{ "{% static '" }}{{ full_file_path }}{{ "' %}" }}" +{%- else -%} +src="{{ full_file_path }}" +{%- endif -%} +{%- endautoescape -%} +{% if alt %} alt="{{ alt }}" {% endif -%} +{%- if hover_text %} title="{{ hover_text }}" {% endif -%} + class="{% if alignment == 'left' %}left-align{% elif alignment =='center' %}center-align{% elif alignment =='right' %}right-align{% endif %}"/> +{% if caption and caption_link -%} +

{{ caption }}

+{%- elif caption -%} +

{{ caption }}

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

Source

+{%- endif -%} +
diff --git a/verto/tests/assets/image-container/file_width_value_html_template.html b/verto/tests/assets/image-container/file_width_value_html_template.html new file mode 100644 index 00000000..75fe263f --- /dev/null +++ b/verto/tests/assets/image-container/file_width_value_html_template.html @@ -0,0 +1,27 @@ +
+ 400 %}, {{ "{% static '" }}{{ file_path }}@400px{{ file_extension }}{{ "' %}" }} 400w{% endif -%} +{% if file_width_value > 600 %}, {{ "{% static '" }}{{ file_path }}@600px{{ file_extension }}{{ "' %}" }} 600w{% endif -%} +{% if file_width_value > 800 %}, {{ "{% static '" }}{{ file_path }}@800px{{ file_extension }}{{ "' %}" }} 800w{% endif -%}" +{%- endif -%} +src="{{ "{% static '" }}{{ full_file_path }}{{ "' %}" }}" +{%- else -%} +src="{{ full_file_path }}" +{%- endif -%} +{%- endautoescape -%} +{% if alt %} alt="{{ alt }}" {% endif -%} +{%- if hover_text %} title="{{ hover_text }}" {% endif -%} + class="{% if alignment == 'left' %}left-align{% elif alignment =='center' %}center-align{% elif alignment =='right' %}right-align{% endif %}"/> +{% if caption and caption_link -%} +

{{ caption }}

+{%- elif caption -%} +

{{ caption }}

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

Source

+{%- endif -%} +
diff --git a/verto/tests/assets/image-container/file_width_value_no_units.md b/verto/tests/assets/image-container/file_width_value_no_units.md new file mode 100644 index 00000000..75353b01 --- /dev/null +++ b/verto/tests/assets/image-container/file_width_value_no_units.md @@ -0,0 +1,5 @@ +{image file-path="path/to/image@700.png" caption="true"} + +This is the caption text. + +{image end} diff --git a/verto/tests/assets/image-container/file_width_value_no_units_expected.html b/verto/tests/assets/image-container/file_width_value_no_units_expected.html new file mode 100644 index 00000000..1b4706cf --- /dev/null +++ b/verto/tests/assets/image-container/file_width_value_no_units_expected.html @@ -0,0 +1,4 @@ +
+ +

This is the caption text.

+
diff --git a/verto/tests/assets/image-container/file_width_value_no_units_html_template.html b/verto/tests/assets/image-container/file_width_value_no_units_html_template.html new file mode 100644 index 00000000..8f1b76f7 --- /dev/null +++ b/verto/tests/assets/image-container/file_width_value_no_units_html_template.html @@ -0,0 +1,24 @@ +
+ 400 %}, {{ "{% static '" }}{{ file_path }}@400px{{ file_extension }}{{ "' %}" }} 400w{% endif -%} +{% if file_width_value > 600 %}, {{ "{% static '" }}{{ file_path }}@600px{{ file_extension }}{{ "' %}" }} 600w{% endif -%} +{% if file_width_value > 800 %}, {{ "{% static '" }}{{ file_path }}@800px{{ file_extension }}{{ "' %}" }} 800w{% endif -%}" +{%- endif -%} +src="{{ "{% static '" }}{{ full_file_path }}{{ "' %}" }}" +{%- else -%} +src="{{ full_file_path }}" +{%- endif -%} +{%- endautoescape -%}/> +{% if caption and caption_link -%} +

{{ caption }}

+{%- elif caption -%} +

{{ caption }}

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

Source

+{%- endif -%} +
diff --git a/verto/tests/assets/image-container/image_in_image_tag.md b/verto/tests/assets/image-container/image_in_image_tag.md new file mode 100644 index 00000000..c269d275 --- /dev/null +++ b/verto/tests/assets/image-container/image_in_image_tag.md @@ -0,0 +1,11 @@ +{image file-path="http://placehold.it/350x150" caption="true" source="https://placehold.it/" hover-text="This is hover text" alignment="left"} + +{image file-path="http://placehold.it/350x150" caption="true" source="https://placehold.it/" alignment="left"} + +This is the second caption. + +{image end} + +This is a caption. + +{image end} diff --git a/verto/tests/assets/image-container/image_in_numbered_list.md b/verto/tests/assets/image-container/image_in_numbered_list.md new file mode 100644 index 00000000..45f94c35 --- /dev/null +++ b/verto/tests/assets/image-container/image_in_numbered_list.md @@ -0,0 +1,15 @@ +1. Lipsum + + * Ichi + * Ni + * San + +2. Lorem + + {image file-path="http://placehold.it/350x150" caption="true" source="https://placehold.it/" hover-text="This is hover text" alignment="left"} + + Placeholder image + + {image end} + +3. Ipsem diff --git a/verto/tests/assets/image/image_in_numbered_list_expected.html b/verto/tests/assets/image-container/image_in_numbered_list_expected.html similarity index 100% rename from verto/tests/assets/image/image_in_numbered_list_expected.html rename to verto/tests/assets/image-container/image_in_numbered_list_expected.html diff --git a/verto/tests/assets/image-container/multiple_images_captions_true.md b/verto/tests/assets/image-container/multiple_images_captions_true.md new file mode 100644 index 00000000..4efba9f4 --- /dev/null +++ b/verto/tests/assets/image-container/multiple_images_captions_true.md @@ -0,0 +1,21 @@ +Imagine we have the following simple black and white image. + +{image file-path="the-first-image.png" caption="true"} + +This is the first caption. + +{image end} + +{image file-path="Lipsum.png" caption="true" alt="A diamond shape made out of pixels"} + +This is the second caption. + +{image end} + +{image file-path="pixel-diamond.png" alt="A diamond shape made out of pixels" caption="true"} + +This is the third caption. + +{image end} + +One very simple way a computer can store this image in binary is by using a format where '0' means white and '1' means black (this is a "bit map", because we've mapped the pixels onto the values of bits). Using this method, the above image would be represented in the following way: diff --git a/verto/tests/assets/image-container/multiple_images_captions_true_expected.html b/verto/tests/assets/image-container/multiple_images_captions_true_expected.html new file mode 100644 index 00000000..209044bf --- /dev/null +++ b/verto/tests/assets/image-container/multiple_images_captions_true_expected.html @@ -0,0 +1,14 @@ +

Imagine we have the following simple black and white image.

+
+ +

This is the first caption.

+
+
+A diamond shape made out of pixels +

This is the second caption.

+
+
+A diamond shape made out of pixels +

This is the third caption.

+
+

One very simple way a computer can store this image in binary is by using a format where '0' means white and '1' means black (this is a "bit map", because we've mapped the pixels onto the values of bits). Using this method, the above image would be represented in the following way:

diff --git a/verto/tests/assets/image-container/no_caption.md b/verto/tests/assets/image-container/no_caption.md new file mode 100644 index 00000000..d5cadef2 --- /dev/null +++ b/verto/tests/assets/image-container/no_caption.md @@ -0,0 +1,7 @@ +Here's another FSA to consider: + +{image file-path="cats.png" alt="FSA with missing transitions"} + +It's fairly clear what it will accept: strings like "ab", "abab", "abababababab", and, of course {math}\epsilon{math end}. +But there are some missing transitions: if you are in state 1 and get a "b" there's nowhere to go. +If an input cannot be accepted, it will be rejected, as in this case. We could have put in a trap state to make this clear: diff --git a/verto/tests/assets/image-container/no_caption_expected.html b/verto/tests/assets/image-container/no_caption_expected.html new file mode 100644 index 00000000..44095508 --- /dev/null +++ b/verto/tests/assets/image-container/no_caption_expected.html @@ -0,0 +1,5 @@ +

Here's another FSA to consider:

+

{image file-path="cats.png" alt="FSA with missing transitions"}

+

It's fairly clear what it will accept: strings like "ab", "abab", "abababababab", and, of course {math}\epsilon{math end}. +But there are some missing transitions: if you are in state 1 and get a "b" there's nowhere to go. +If an input cannot be accepted, it will be rejected, as in this case. We could have put in a trap state to make this clear:

diff --git a/verto/tests/assets/image-inline/doc_example_2_override_html.md b/verto/tests/assets/image-inline/doc_example_2_override_html.md new file mode 100644 index 00000000..1dd140e3 --- /dev/null +++ b/verto/tests/assets/image-inline/doc_example_2_override_html.md @@ -0,0 +1 @@ +An inline image: {image-inline file-path="path/to/image@500px.png"}. diff --git a/verto/tests/assets/image-inline/doc_example_2_override_html_expected.html b/verto/tests/assets/image-inline/doc_example_2_override_html_expected.html new file mode 100644 index 00000000..6e3cd862 --- /dev/null +++ b/verto/tests/assets/image-inline/doc_example_2_override_html_expected.html @@ -0,0 +1,3 @@ +

An inline image:

+ +
.

diff --git a/verto/tests/assets/image-inline/doc_example_2_override_html_template.html b/verto/tests/assets/image-inline/doc_example_2_override_html_template.html new file mode 100644 index 00000000..73d9a88f --- /dev/null +++ b/verto/tests/assets/image-inline/doc_example_2_override_html_template.html @@ -0,0 +1,16 @@ +
+ 400 %}, {{ "{% static '" }}{{ file_path }}@400px{{ file_extension }}{{ "' %}" }} 400w{% endif -%} +{% if file_width_value > 600 %}, {{ "{% static '" }}{{ file_path }}@600px{{ file_extension }}{{ "' %}" }} 600w{% endif -%} +{% if file_width_value > 800 %}, {{ "{% static '" }}{{ file_path }}@800px{{ file_extension }}{{ "' %}" }} 800w{% endif -%}" +{%- endif -%} +src="{{ "{% static '" }}{{ full_file_path }}{{ "' %}" }}" +{%- else -%} +src="{{ full_file_path }}" +{%- endif -%} +{%- endautoescape -%}> +
diff --git a/verto/tests/assets/image-inline/doc_example_override_html_template.html b/verto/tests/assets/image-inline/doc_example_override_html_template.html index 1ea96063..28028df8 100644 --- a/verto/tests/assets/image-inline/doc_example_override_html_template.html +++ b/verto/tests/assets/image-inline/doc_example_override_html_template.html @@ -1,3 +1,3 @@
- +
diff --git a/verto/tests/assets/image-inline/file_invalid_width_value_1.md b/verto/tests/assets/image-inline/file_invalid_width_value_1.md new file mode 100644 index 00000000..2b3edb48 --- /dev/null +++ b/verto/tests/assets/image-inline/file_invalid_width_value_1.md @@ -0,0 +1 @@ +An inline image: {image-inline file-path="path/to/image@.png"}. diff --git a/verto/tests/assets/image-inline/file_invalid_width_value_1_expected.html b/verto/tests/assets/image-inline/file_invalid_width_value_1_expected.html new file mode 100644 index 00000000..4fe1428f --- /dev/null +++ b/verto/tests/assets/image-inline/file_invalid_width_value_1_expected.html @@ -0,0 +1,3 @@ +

An inline image:

+ +
.

diff --git a/verto/tests/assets/image-inline/file_invalid_width_value_2.md b/verto/tests/assets/image-inline/file_invalid_width_value_2.md new file mode 100644 index 00000000..e04fc1e1 --- /dev/null +++ b/verto/tests/assets/image-inline/file_invalid_width_value_2.md @@ -0,0 +1 @@ +An inline image: {image-inline file-path="path/to/image@em20.png"}. diff --git a/verto/tests/assets/image-inline/file_invalid_width_value_2_expected.html b/verto/tests/assets/image-inline/file_invalid_width_value_2_expected.html new file mode 100644 index 00000000..a4bf5d06 --- /dev/null +++ b/verto/tests/assets/image-inline/file_invalid_width_value_2_expected.html @@ -0,0 +1,3 @@ +

An inline image:

+ +
.

diff --git a/verto/tests/assets/image-inline/file_width_value.md b/verto/tests/assets/image-inline/file_width_value.md new file mode 100644 index 00000000..1dd140e3 --- /dev/null +++ b/verto/tests/assets/image-inline/file_width_value.md @@ -0,0 +1 @@ +An inline image: {image-inline file-path="path/to/image@500px.png"}. diff --git a/verto/tests/assets/image-inline/file_width_value_expected.html b/verto/tests/assets/image-inline/file_width_value_expected.html new file mode 100644 index 00000000..6e3cd862 --- /dev/null +++ b/verto/tests/assets/image-inline/file_width_value_expected.html @@ -0,0 +1,3 @@ +

An inline image:

+ +
.

diff --git a/verto/tests/assets/image-inline/file_width_value_external_image.md b/verto/tests/assets/image-inline/file_width_value_external_image.md new file mode 100644 index 00000000..fdeda0a1 --- /dev/null +++ b/verto/tests/assets/image-inline/file_width_value_external_image.md @@ -0,0 +1 @@ +An inline image: {image-inline file-path="https://www.verto.io/images/image@200px.png"}. diff --git a/verto/tests/assets/image-inline/file_width_value_external_image_expected.html b/verto/tests/assets/image-inline/file_width_value_external_image_expected.html new file mode 100644 index 00000000..2ceca220 --- /dev/null +++ b/verto/tests/assets/image-inline/file_width_value_external_image_expected.html @@ -0,0 +1,3 @@ +

An inline image:

+ +
.

diff --git a/verto/tests/assets/image-inline/file_width_value_html_template.html b/verto/tests/assets/image-inline/file_width_value_html_template.html new file mode 100644 index 00000000..73d9a88f --- /dev/null +++ b/verto/tests/assets/image-inline/file_width_value_html_template.html @@ -0,0 +1,16 @@ +
+ 400 %}, {{ "{% static '" }}{{ file_path }}@400px{{ file_extension }}{{ "' %}" }} 400w{% endif -%} +{% if file_width_value > 600 %}, {{ "{% static '" }}{{ file_path }}@600px{{ file_extension }}{{ "' %}" }} 600w{% endif -%} +{% if file_width_value > 800 %}, {{ "{% static '" }}{{ file_path }}@800px{{ file_extension }}{{ "' %}" }} 800w{% endif -%}" +{%- endif -%} +src="{{ "{% static '" }}{{ full_file_path }}{{ "' %}" }}" +{%- else -%} +src="{{ full_file_path }}" +{%- endif -%} +{%- endautoescape -%}> +
diff --git a/verto/tests/assets/image-inline/file_width_value_no_units.md b/verto/tests/assets/image-inline/file_width_value_no_units.md new file mode 100644 index 00000000..3c1b94e7 --- /dev/null +++ b/verto/tests/assets/image-inline/file_width_value_no_units.md @@ -0,0 +1 @@ +An inline image: {image-inline file-path="path/to/image@900.png"}. diff --git a/verto/tests/assets/image-inline/file_width_value_no_units_expected.html b/verto/tests/assets/image-inline/file_width_value_no_units_expected.html new file mode 100644 index 00000000..78171b79 --- /dev/null +++ b/verto/tests/assets/image-inline/file_width_value_no_units_expected.html @@ -0,0 +1,3 @@ +

An inline image:

+ +
.

diff --git a/verto/tests/assets/image-inline/file_width_value_no_units_html_template.html b/verto/tests/assets/image-inline/file_width_value_no_units_html_template.html new file mode 100644 index 00000000..73d9a88f --- /dev/null +++ b/verto/tests/assets/image-inline/file_width_value_no_units_html_template.html @@ -0,0 +1,16 @@ +
+ 400 %}, {{ "{% static '" }}{{ file_path }}@400px{{ file_extension }}{{ "' %}" }} 400w{% endif -%} +{% if file_width_value > 600 %}, {{ "{% static '" }}{{ file_path }}@600px{{ file_extension }}{{ "' %}" }} 600w{% endif -%} +{% if file_width_value > 800 %}, {{ "{% static '" }}{{ file_path }}@800px{{ file_extension }}{{ "' %}" }} 800w{% endif -%}" +{%- endif -%} +src="{{ "{% static '" }}{{ full_file_path }}{{ "' %}" }}" +{%- else -%} +src="{{ full_file_path }}" +{%- endif -%} +{%- endautoescape -%}> +
diff --git a/verto/tests/assets/image-tag/align_center.md b/verto/tests/assets/image-tag/align_center.md new file mode 100644 index 00000000..d4e15401 --- /dev/null +++ b/verto/tests/assets/image-tag/align_center.md @@ -0,0 +1,5 @@ +Some text before. + +{image file-path="computer-studying-turing-test.png" caption="false" alignment="center"} + +Some text after. diff --git a/verto/tests/assets/image/align_center_expected.html b/verto/tests/assets/image-tag/align_center_expected.html similarity index 66% rename from verto/tests/assets/image/align_center_expected.html rename to verto/tests/assets/image-tag/align_center_expected.html index 130274a4..d25639fb 100644 --- a/verto/tests/assets/image/align_center_expected.html +++ b/verto/tests/assets/image-tag/align_center_expected.html @@ -1,3 +1,5 @@ +

Some text before.

+

Some text after.

diff --git a/verto/tests/assets/image/align_left.md b/verto/tests/assets/image-tag/align_left.md similarity index 100% rename from verto/tests/assets/image/align_left.md rename to verto/tests/assets/image-tag/align_left.md diff --git a/verto/tests/assets/image/align_left_expected.html b/verto/tests/assets/image-tag/align_left_expected.html similarity index 100% rename from verto/tests/assets/image/align_left_expected.html rename to verto/tests/assets/image-tag/align_left_expected.html diff --git a/verto/tests/assets/image/align_right.md b/verto/tests/assets/image-tag/align_right.md similarity index 100% rename from verto/tests/assets/image/align_right.md rename to verto/tests/assets/image-tag/align_right.md diff --git a/verto/tests/assets/image/align_right_expected.html b/verto/tests/assets/image-tag/align_right_expected.html similarity index 100% rename from verto/tests/assets/image/align_right_expected.html rename to verto/tests/assets/image-tag/align_right_expected.html diff --git a/verto/tests/assets/image/align_undefined_error.md b/verto/tests/assets/image-tag/align_undefined_error.md similarity index 100% rename from verto/tests/assets/image/align_undefined_error.md rename to verto/tests/assets/image-tag/align_undefined_error.md diff --git a/verto/tests/assets/image-tag/alt_hover_caption_false.md b/verto/tests/assets/image-tag/alt_hover_caption_false.md new file mode 100644 index 00000000..b4b62bef --- /dev/null +++ b/verto/tests/assets/image-tag/alt_hover_caption_false.md @@ -0,0 +1,11 @@ +Here's another FSA to consider: + +{image file-path="finite-state-automata-no-trap-example.png" hover-text="hover text is me" caption="false" alt="FSA with missing transitions"} + +It's fairly clear what it will accept: strings like "ab", "abab", "abababababab", and, of course {math}\epsilon{math end}. +But there are some missing transitions: if you are in state 1 and get a "b" there's nowhere to go. +If an input cannot be accepted, it will be rejected, as in this case. We could have put in a trap state to make this clear: + +{image file-path="finite-state-automata-trap-added-example.png" caption="false" alt="FSA with missing transitions" hover-text="also some hover text"} + +But things can get out of hand. What if there are more letters in the alphabet? We'd need something like this: diff --git a/verto/tests/assets/image-tag/alt_hover_caption_false_expected.html b/verto/tests/assets/image-tag/alt_hover_caption_false_expected.html new file mode 100644 index 00000000..fea0acdd --- /dev/null +++ b/verto/tests/assets/image-tag/alt_hover_caption_false_expected.html @@ -0,0 +1,11 @@ +

Here's another FSA to consider:

+
+FSA with missing transitions +
+

It's fairly clear what it will accept: strings like "ab", "abab", "abababababab", and, of course {math}\epsilon{math end}. +But there are some missing transitions: if you are in state 1 and get a "b" there's nowhere to go. +If an input cannot be accepted, it will be rejected, as in this case. We could have put in a trap state to make this clear:

+
+FSA with missing transitions +
+

But things can get out of hand. What if there are more letters in the alphabet? We'd need something like this:

diff --git a/verto/tests/assets/image-tag/caption.md b/verto/tests/assets/image-tag/caption.md new file mode 100644 index 00000000..320b763a --- /dev/null +++ b/verto/tests/assets/image-tag/caption.md @@ -0,0 +1,9 @@ +It was so nice throwing big parties + +{image file-path="cats.png" alt="this is the alt text" caption="true"} + +Jump into the pool from the balcony + +{image end} + +Everyone swimming in a champagne sea diff --git a/verto/tests/assets/image-tag/caption_expected.html b/verto/tests/assets/image-tag/caption_expected.html new file mode 100644 index 00000000..f1ec453c --- /dev/null +++ b/verto/tests/assets/image-tag/caption_expected.html @@ -0,0 +1,5 @@ +

It was so nice throwing big parties

+

{image file-path="cats.png" alt="this is the alt text" caption="true"}

+

Jump into the pool from the balcony

+

{image end}

+

Everyone swimming in a champagne sea

diff --git a/verto/tests/assets/image-tag/caption_false.md b/verto/tests/assets/image-tag/caption_false.md new file mode 100644 index 00000000..b62e915e --- /dev/null +++ b/verto/tests/assets/image-tag/caption_false.md @@ -0,0 +1,7 @@ +Here's another FSA to consider: + +{image file-path="cats.png" alt="FSA with missing transitions" caption="false"} + +It's fairly clear what it will accept: strings like "ab", "abab", "abababababab", and, of course {math}\epsilon{math end}. +But there are some missing transitions: if you are in state 1 and get a "b" there's nowhere to go. +If an input cannot be accepted, it will be rejected, as in this case. We could have put in a trap state to make this clear: diff --git a/verto/tests/assets/image-tag/caption_false_end_tag_provided.md b/verto/tests/assets/image-tag/caption_false_end_tag_provided.md new file mode 100644 index 00000000..07d1ce33 --- /dev/null +++ b/verto/tests/assets/image-tag/caption_false_end_tag_provided.md @@ -0,0 +1,7 @@ +Imagine we have the following simple black and white image. + +{image file-path="pixel-diamond.png" alt="A diamond shape made out of pixels" caption="true"} + +{image end} + +One very simple way a computer can store this image in binary is by using a format where '0' means white and '1' means black (this is a "bit map", because we've mapped the pixels onto the values of bits). Using this method, the above image would be represented in the following way: diff --git a/verto/tests/assets/image-tag/caption_false_expected.html b/verto/tests/assets/image-tag/caption_false_expected.html new file mode 100644 index 00000000..944b7d82 --- /dev/null +++ b/verto/tests/assets/image-tag/caption_false_expected.html @@ -0,0 +1,7 @@ +

Here's another FSA to consider:

+
+FSA with missing transitions +
+

It's fairly clear what it will accept: strings like "ab", "abab", "abababababab", and, of course {math}\epsilon{math end}. +But there are some missing transitions: if you are in state 1 and get a "b" there's nowhere to go. +If an input cannot be accepted, it will be rejected, as in this case. We could have put in a trap state to make this clear:

diff --git a/verto/tests/assets/image/caption_link_error.md b/verto/tests/assets/image-tag/caption_link_error.md similarity index 100% rename from verto/tests/assets/image/caption_link_error.md rename to verto/tests/assets/image-tag/caption_link_error.md diff --git a/verto/tests/assets/image/contains_alt.md b/verto/tests/assets/image-tag/contains_alt.md similarity index 78% rename from verto/tests/assets/image/contains_alt.md rename to verto/tests/assets/image-tag/contains_alt.md index 1f659cf2..ee2fd7ee 100644 --- a/verto/tests/assets/image/contains_alt.md +++ b/verto/tests/assets/image-tag/contains_alt.md @@ -1 +1,3 @@ {image file-path="computer-studying-turing-test.png" alt="Lipsum"} + +Some text after. diff --git a/verto/tests/assets/image-tag/contains_alt_expected.html b/verto/tests/assets/image-tag/contains_alt_expected.html new file mode 100644 index 00000000..52ddc6b3 --- /dev/null +++ b/verto/tests/assets/image-tag/contains_alt_expected.html @@ -0,0 +1,4 @@ +
+Lipsum +
+

Some text after.

diff --git a/verto/tests/assets/image/contains_hover_text.md b/verto/tests/assets/image-tag/contains_hover_text.md similarity index 79% rename from verto/tests/assets/image/contains_hover_text.md rename to verto/tests/assets/image-tag/contains_hover_text.md index f80b9ded..b5c9bc76 100644 --- a/verto/tests/assets/image/contains_hover_text.md +++ b/verto/tests/assets/image-tag/contains_hover_text.md @@ -1 +1,3 @@ +Some text before. + {image file-path="computer-studying-turing-test.png" hover-text="Lipsum"} diff --git a/verto/tests/assets/image/contains_hover_text_expected.html b/verto/tests/assets/image-tag/contains_hover_text_expected.html similarity index 80% rename from verto/tests/assets/image/contains_hover_text_expected.html rename to verto/tests/assets/image-tag/contains_hover_text_expected.html index c4f06812..7b64b2c0 100644 --- a/verto/tests/assets/image/contains_hover_text_expected.html +++ b/verto/tests/assets/image-tag/contains_hover_text_expected.html @@ -1,3 +1,4 @@ +

Some text before.

diff --git a/verto/tests/assets/image-tag/contains_source.md b/verto/tests/assets/image-tag/contains_source.md new file mode 100644 index 00000000..a87b3c4d --- /dev/null +++ b/verto/tests/assets/image-tag/contains_source.md @@ -0,0 +1,3 @@ +So it goes... + +{image caption="false" file-path="computer-studying-turing-test.png" source="example.com"} diff --git a/verto/tests/assets/image/contains_source_expected.html b/verto/tests/assets/image-tag/contains_source_expected.html similarity index 85% rename from verto/tests/assets/image/contains_source_expected.html rename to verto/tests/assets/image-tag/contains_source_expected.html index 1094670e..e12ecea6 100644 --- a/verto/tests/assets/image/contains_source_expected.html +++ b/verto/tests/assets/image-tag/contains_source_expected.html @@ -1,3 +1,4 @@ +

So it goes...

Source

diff --git a/verto/tests/assets/image-tag/doc_example_2_override_html.md b/verto/tests/assets/image-tag/doc_example_2_override_html.md new file mode 100644 index 00000000..d6818613 --- /dev/null +++ b/verto/tests/assets/image-tag/doc_example_2_override_html.md @@ -0,0 +1 @@ +{image file-path="path/to/image@500px.png"} diff --git a/verto/tests/assets/image-tag/doc_example_2_override_html_expected.html b/verto/tests/assets/image-tag/doc_example_2_override_html_expected.html new file mode 100644 index 00000000..9e55150c --- /dev/null +++ b/verto/tests/assets/image-tag/doc_example_2_override_html_expected.html @@ -0,0 +1 @@ + diff --git a/verto/tests/assets/image-tag/doc_example_2_override_html_template.html b/verto/tests/assets/image-tag/doc_example_2_override_html_template.html new file mode 100644 index 00000000..a1343960 --- /dev/null +++ b/verto/tests/assets/image-tag/doc_example_2_override_html_template.html @@ -0,0 +1,14 @@ + 400 %}, {{ "{% static '" }}{{ file_path }}@400px{{ file_extension }}{{ "' %}" }} 400w{% endif -%} +{% if file_width_value > 600 %}, {{ "{% static '" }}{{ file_path }}@600px{{ file_extension }}{{ "' %}" }} 600w{% endif -%} +{% if file_width_value > 800 %}, {{ "{% static '" }}{{ file_path }}@800px{{ file_extension }}{{ "' %}" }} 800w{% endif -%}" +{%- endif -%} +src="{{ "{% static '" }}{{ full_file_path }}{{ "' %}" }}" +{%- else -%} +src="{{ full_file_path }}" +{%- endif -%} +{%- endautoescape -%}> diff --git a/verto/tests/assets/image-tag/doc_example_basic_usage.md b/verto/tests/assets/image-tag/doc_example_basic_usage.md new file mode 100644 index 00000000..01424dcd --- /dev/null +++ b/verto/tests/assets/image-tag/doc_example_basic_usage.md @@ -0,0 +1 @@ +{image file-path="http://placehold.it/350x150" source="https://placehold.it/" hover-text="This is hover text" alignment="left"} diff --git a/verto/tests/assets/image/doc_example_basic_usage_expected.html b/verto/tests/assets/image-tag/doc_example_basic_usage_expected.html similarity index 85% rename from verto/tests/assets/image/doc_example_basic_usage_expected.html rename to verto/tests/assets/image-tag/doc_example_basic_usage_expected.html index 90829b68..068c6456 100644 --- a/verto/tests/assets/image/doc_example_basic_usage_expected.html +++ b/verto/tests/assets/image-tag/doc_example_basic_usage_expected.html @@ -1,5 +1,4 @@
-

Placeholder image

Source

diff --git a/verto/tests/assets/image-tag/doc_example_override_html.md b/verto/tests/assets/image-tag/doc_example_override_html.md new file mode 100644 index 00000000..17eb6ef7 --- /dev/null +++ b/verto/tests/assets/image-tag/doc_example_override_html.md @@ -0,0 +1 @@ +{image file-path="http://placehold.it/350x150" source="https://placehold.it/"} diff --git a/verto/tests/assets/image/doc_example_override_html_expected.html b/verto/tests/assets/image-tag/doc_example_override_html_expected.html similarity index 100% rename from verto/tests/assets/image/doc_example_override_html_expected.html rename to verto/tests/assets/image-tag/doc_example_override_html_expected.html diff --git a/verto/tests/assets/image-tag/doc_example_override_html_template.html b/verto/tests/assets/image-tag/doc_example_override_html_template.html new file mode 100644 index 00000000..28028df8 --- /dev/null +++ b/verto/tests/assets/image-tag/doc_example_override_html_template.html @@ -0,0 +1,3 @@ +
+ +
diff --git a/verto/tests/assets/image/external_image.md b/verto/tests/assets/image-tag/external_image.md similarity index 100% rename from verto/tests/assets/image/external_image.md rename to verto/tests/assets/image-tag/external_image.md diff --git a/verto/tests/assets/image/external_image_expected.html b/verto/tests/assets/image-tag/external_image_expected.html similarity index 100% rename from verto/tests/assets/image/external_image_expected.html rename to verto/tests/assets/image-tag/external_image_expected.html diff --git a/verto/tests/assets/image-tag/file_invalid_width_value_1.md b/verto/tests/assets/image-tag/file_invalid_width_value_1.md new file mode 100644 index 00000000..a3dbce88 --- /dev/null +++ b/verto/tests/assets/image-tag/file_invalid_width_value_1.md @@ -0,0 +1 @@ +{image file-path="path/to/image@.png"} diff --git a/verto/tests/assets/image-tag/file_invalid_width_value_1_expected.html b/verto/tests/assets/image-tag/file_invalid_width_value_1_expected.html new file mode 100644 index 00000000..e66fe9be --- /dev/null +++ b/verto/tests/assets/image-tag/file_invalid_width_value_1_expected.html @@ -0,0 +1 @@ + diff --git a/verto/tests/assets/image-tag/file_invalid_width_value_1_html_template.html b/verto/tests/assets/image-tag/file_invalid_width_value_1_html_template.html new file mode 100644 index 00000000..a1343960 --- /dev/null +++ b/verto/tests/assets/image-tag/file_invalid_width_value_1_html_template.html @@ -0,0 +1,14 @@ + 400 %}, {{ "{% static '" }}{{ file_path }}@400px{{ file_extension }}{{ "' %}" }} 400w{% endif -%} +{% if file_width_value > 600 %}, {{ "{% static '" }}{{ file_path }}@600px{{ file_extension }}{{ "' %}" }} 600w{% endif -%} +{% if file_width_value > 800 %}, {{ "{% static '" }}{{ file_path }}@800px{{ file_extension }}{{ "' %}" }} 800w{% endif -%}" +{%- endif -%} +src="{{ "{% static '" }}{{ full_file_path }}{{ "' %}" }}" +{%- else -%} +src="{{ full_file_path }}" +{%- endif -%} +{%- endautoescape -%}> diff --git a/verto/tests/assets/image-tag/file_invalid_width_value_2.md b/verto/tests/assets/image-tag/file_invalid_width_value_2.md new file mode 100644 index 00000000..5d538068 --- /dev/null +++ b/verto/tests/assets/image-tag/file_invalid_width_value_2.md @@ -0,0 +1 @@ +{image file-path="path/to/image@em20.png"} diff --git a/verto/tests/assets/image-tag/file_invalid_width_value_2_expected.html b/verto/tests/assets/image-tag/file_invalid_width_value_2_expected.html new file mode 100644 index 00000000..588b2037 --- /dev/null +++ b/verto/tests/assets/image-tag/file_invalid_width_value_2_expected.html @@ -0,0 +1 @@ + diff --git a/verto/tests/assets/image-tag/file_invalid_width_value_2_html_template.html b/verto/tests/assets/image-tag/file_invalid_width_value_2_html_template.html new file mode 100644 index 00000000..a1343960 --- /dev/null +++ b/verto/tests/assets/image-tag/file_invalid_width_value_2_html_template.html @@ -0,0 +1,14 @@ + 400 %}, {{ "{% static '" }}{{ file_path }}@400px{{ file_extension }}{{ "' %}" }} 400w{% endif -%} +{% if file_width_value > 600 %}, {{ "{% static '" }}{{ file_path }}@600px{{ file_extension }}{{ "' %}" }} 600w{% endif -%} +{% if file_width_value > 800 %}, {{ "{% static '" }}{{ file_path }}@800px{{ file_extension }}{{ "' %}" }} 800w{% endif -%}" +{%- endif -%} +src="{{ "{% static '" }}{{ full_file_path }}{{ "' %}" }}" +{%- else -%} +src="{{ full_file_path }}" +{%- endif -%} +{%- endautoescape -%}> diff --git a/verto/tests/assets/image-tag/file_width_value.md b/verto/tests/assets/image-tag/file_width_value.md new file mode 100644 index 00000000..d6818613 --- /dev/null +++ b/verto/tests/assets/image-tag/file_width_value.md @@ -0,0 +1 @@ +{image file-path="path/to/image@500px.png"} diff --git a/verto/tests/assets/image-tag/file_width_value_expected.html b/verto/tests/assets/image-tag/file_width_value_expected.html new file mode 100644 index 00000000..9e55150c --- /dev/null +++ b/verto/tests/assets/image-tag/file_width_value_expected.html @@ -0,0 +1 @@ + diff --git a/verto/tests/assets/image-tag/file_width_value_external_image.md b/verto/tests/assets/image-tag/file_width_value_external_image.md new file mode 100644 index 00000000..a4e7e4c6 --- /dev/null +++ b/verto/tests/assets/image-tag/file_width_value_external_image.md @@ -0,0 +1 @@ +{image file-path="https://www.verto.io/images/image@200px.png"} diff --git a/verto/tests/assets/image-tag/file_width_value_external_image_expected.html b/verto/tests/assets/image-tag/file_width_value_external_image_expected.html new file mode 100644 index 00000000..bf1003ff --- /dev/null +++ b/verto/tests/assets/image-tag/file_width_value_external_image_expected.html @@ -0,0 +1 @@ + diff --git a/verto/tests/assets/image-tag/file_width_value_external_image_html_template.html b/verto/tests/assets/image-tag/file_width_value_external_image_html_template.html new file mode 100644 index 00000000..a1343960 --- /dev/null +++ b/verto/tests/assets/image-tag/file_width_value_external_image_html_template.html @@ -0,0 +1,14 @@ + 400 %}, {{ "{% static '" }}{{ file_path }}@400px{{ file_extension }}{{ "' %}" }} 400w{% endif -%} +{% if file_width_value > 600 %}, {{ "{% static '" }}{{ file_path }}@600px{{ file_extension }}{{ "' %}" }} 600w{% endif -%} +{% if file_width_value > 800 %}, {{ "{% static '" }}{{ file_path }}@800px{{ file_extension }}{{ "' %}" }} 800w{% endif -%}" +{%- endif -%} +src="{{ "{% static '" }}{{ full_file_path }}{{ "' %}" }}" +{%- else -%} +src="{{ full_file_path }}" +{%- endif -%} +{%- endautoescape -%}> diff --git a/verto/tests/assets/image-tag/file_width_value_html_template.html b/verto/tests/assets/image-tag/file_width_value_html_template.html new file mode 100644 index 00000000..a1343960 --- /dev/null +++ b/verto/tests/assets/image-tag/file_width_value_html_template.html @@ -0,0 +1,14 @@ + 400 %}, {{ "{% static '" }}{{ file_path }}@400px{{ file_extension }}{{ "' %}" }} 400w{% endif -%} +{% if file_width_value > 600 %}, {{ "{% static '" }}{{ file_path }}@600px{{ file_extension }}{{ "' %}" }} 600w{% endif -%} +{% if file_width_value > 800 %}, {{ "{% static '" }}{{ file_path }}@800px{{ file_extension }}{{ "' %}" }} 800w{% endif -%}" +{%- endif -%} +src="{{ "{% static '" }}{{ full_file_path }}{{ "' %}" }}" +{%- else -%} +src="{{ full_file_path }}" +{%- endif -%} +{%- endautoescape -%}> diff --git a/verto/tests/assets/image-tag/file_width_value_no_units.md b/verto/tests/assets/image-tag/file_width_value_no_units.md new file mode 100644 index 00000000..a8287260 --- /dev/null +++ b/verto/tests/assets/image-tag/file_width_value_no_units.md @@ -0,0 +1 @@ +{image file-path="path/to/image@900.png"} diff --git a/verto/tests/assets/image-tag/file_width_value_no_units_expected.html b/verto/tests/assets/image-tag/file_width_value_no_units_expected.html new file mode 100644 index 00000000..df31a586 --- /dev/null +++ b/verto/tests/assets/image-tag/file_width_value_no_units_expected.html @@ -0,0 +1 @@ + diff --git a/verto/tests/assets/image-tag/file_width_value_no_units_html_template.html b/verto/tests/assets/image-tag/file_width_value_no_units_html_template.html new file mode 100644 index 00000000..a1343960 --- /dev/null +++ b/verto/tests/assets/image-tag/file_width_value_no_units_html_template.html @@ -0,0 +1,14 @@ + 400 %}, {{ "{% static '" }}{{ file_path }}@400px{{ file_extension }}{{ "' %}" }} 400w{% endif -%} +{% if file_width_value > 600 %}, {{ "{% static '" }}{{ file_path }}@600px{{ file_extension }}{{ "' %}" }} 600w{% endif -%} +{% if file_width_value > 800 %}, {{ "{% static '" }}{{ file_path }}@800px{{ file_extension }}{{ "' %}" }} 800w{% endif -%}" +{%- endif -%} +src="{{ "{% static '" }}{{ full_file_path }}{{ "' %}" }}" +{%- else -%} +src="{{ full_file_path }}" +{%- endif -%} +{%- endautoescape -%}> diff --git a/verto/tests/assets/image-tag/image_in_numbered_list.md b/verto/tests/assets/image-tag/image_in_numbered_list.md new file mode 100644 index 00000000..3d5a7b33 --- /dev/null +++ b/verto/tests/assets/image-tag/image_in_numbered_list.md @@ -0,0 +1,11 @@ +1. Lipsum + + * Ichi + * Ni + * San + +2. Lorem + + {image file-path="http://placehold.it/350x150" caption="false" source="https://placehold.it/" hover-text="This is hover text" alignment="left"} + +3. Ipsem diff --git a/verto/tests/assets/image-tag/image_in_numbered_list_expected.html b/verto/tests/assets/image-tag/image_in_numbered_list_expected.html new file mode 100644 index 00000000..15072345 --- /dev/null +++ b/verto/tests/assets/image-tag/image_in_numbered_list_expected.html @@ -0,0 +1,20 @@ +
    +
  1. +

    Lipsum

    +
      +
    • Ichi
    • +
    • Ni
    • +
    • San
    • +
    +
  2. +
  3. +

    Lorem

    +
    + +

    Source

    +
    +
  4. +
  5. +

    Ipsem

    +
  6. +
diff --git a/verto/tests/assets/image-tag/invalid_caption_error.md b/verto/tests/assets/image-tag/invalid_caption_error.md new file mode 100644 index 00000000..e5a6f7e5 --- /dev/null +++ b/verto/tests/assets/image-tag/invalid_caption_error.md @@ -0,0 +1,5 @@ +It was so nice throwing big parties + +{image file-path="cats.png" alt="this is the alt text" caption="cats"} + +Everyone swimming in a champagne sea diff --git a/verto/tests/assets/image-tag/multiple_images_captions_false.md b/verto/tests/assets/image-tag/multiple_images_captions_false.md new file mode 100644 index 00000000..3f90c160 --- /dev/null +++ b/verto/tests/assets/image-tag/multiple_images_captions_false.md @@ -0,0 +1,11 @@ +Imagine we have the following simple black and white image. + +{image file-path="the-first-image.png" caption="false"} + +{image file-path="Lipsum.png" caption="false" alt="A diamond shape made out of pixels"} + +My castle crumbled overnight. + +{image file-path="pixel-diamond.png" alt="A diamond shape made out of pixels" caption="false"} + +One very simple way a computer can store this image in binary is by using a format where '0' means white and '1' means black (this is a "bit map", because we've mapped the pixels onto the values of bits). Using this method, the above image would be represented in the following way: diff --git a/verto/tests/assets/image/internal_image_expected.html b/verto/tests/assets/image-tag/multiple_images_captions_false_expected.html similarity index 68% rename from verto/tests/assets/image/internal_image_expected.html rename to verto/tests/assets/image-tag/multiple_images_captions_false_expected.html index f0d98770..31c9eeab 100644 --- a/verto/tests/assets/image/internal_image_expected.html +++ b/verto/tests/assets/image-tag/multiple_images_captions_false_expected.html @@ -1,5 +1,12 @@

Imagine we have the following simple black and white image.

+ +
+
+A diamond shape made out of pixels +
+

My castle crumbled overnight.

+
A diamond shape made out of pixels

One very simple way a computer can store this image in binary is by using a format where '0' means white and '1' means black (this is a "bit map", because we've mapped the pixels onto the values of bits). Using this method, the above image would be represented in the following way:

diff --git a/verto/tests/assets/image-tag/multiple_images_captions_true_expected.html b/verto/tests/assets/image-tag/multiple_images_captions_true_expected.html new file mode 100644 index 00000000..671e74c9 --- /dev/null +++ b/verto/tests/assets/image-tag/multiple_images_captions_true_expected.html @@ -0,0 +1,11 @@ +

Imagine we have the following simple black and white image.

+
+ +
+
+A diamond shape made out of pixels +
+
+A diamond shape made out of pixels +
+

One very simple way a computer can store this image in binary is by using a format where '0' means white and '1' means black (this is a "bit map", because we've mapped the pixels onto the values of bits). Using this method, the above image would be represented in the following way:

diff --git a/verto/tests/assets/image/contains_image_and_text_contains_word_image.md b/verto/tests/assets/image-tag/no_caption.md similarity index 100% rename from verto/tests/assets/image/contains_image_and_text_contains_word_image.md rename to verto/tests/assets/image-tag/no_caption.md diff --git a/verto/tests/assets/image/contains_image_and_text_contains_word_image_expected.html b/verto/tests/assets/image-tag/no_caption_expected.html similarity index 100% rename from verto/tests/assets/image/contains_image_and_text_contains_word_image_expected.html rename to verto/tests/assets/image-tag/no_caption_expected.html diff --git a/verto/tests/assets/image-tag/source_hover_no_caption.md b/verto/tests/assets/image-tag/source_hover_no_caption.md new file mode 100644 index 00000000..b6e89cc3 --- /dev/null +++ b/verto/tests/assets/image-tag/source_hover_no_caption.md @@ -0,0 +1,11 @@ +Here's another FSA to consider: + +{image file-path="finite-state-automata-no-trap-example.png" hover-text="hover text is me" alt="FSA with missing transitions" source="example.com"} + +It's fairly clear what it will accept: strings like "ab", "abab", "abababababab", and, of course {math}\epsilon{math end}. +But there are some missing transitions: if you are in state 1 and get a "b" there's nowhere to go. +If an input cannot be accepted, it will be rejected, as in this case. We could have put in a trap state to make this clear: + +{image file-path="finite-state-automata-trap-added-example.png" source="example.com" alt="FSA with missing transitions" hover-text="also some hover text"} + +But things can get out of hand. What if there are more letters in the alphabet? We'd need something like this: diff --git a/verto/tests/assets/image-tag/source_hover_no_caption_expected.html b/verto/tests/assets/image-tag/source_hover_no_caption_expected.html new file mode 100644 index 00000000..fe82d37f --- /dev/null +++ b/verto/tests/assets/image-tag/source_hover_no_caption_expected.html @@ -0,0 +1,13 @@ +

Here's another FSA to consider:

+
+FSA with missing transitions +

Source

+
+

It's fairly clear what it will accept: strings like "ab", "abab", "abababababab", and, of course {math}\epsilon{math end}. +But there are some missing transitions: if you are in state 1 and get a "b" there's nowhere to go. +If an input cannot be accepted, it will be rejected, as in this case. We could have put in a trap state to make this clear:

+
+FSA with missing transitions +

Source

+
+

But things can get out of hand. What if there are more letters in the alphabet? We'd need something like this:

diff --git a/verto/tests/assets/image/contains_caption.md b/verto/tests/assets/image/contains_caption.md deleted file mode 100644 index 6329266a..00000000 --- a/verto/tests/assets/image/contains_caption.md +++ /dev/null @@ -1 +0,0 @@ -{image file-path="computer-studying-turing-test.png" caption="Lipsum"} diff --git a/verto/tests/assets/image/contains_caption_link.md b/verto/tests/assets/image/contains_caption_link.md deleted file mode 100644 index 2c29e793..00000000 --- a/verto/tests/assets/image/contains_caption_link.md +++ /dev/null @@ -1 +0,0 @@ -{image file-path="computer-studying-turing-test.png" caption="Lipsum" caption-link="example.com"} diff --git a/verto/tests/assets/image/contains_image.md b/verto/tests/assets/image/contains_image.md deleted file mode 100644 index c0d070b1..00000000 --- a/verto/tests/assets/image/contains_image.md +++ /dev/null @@ -1,3 +0,0 @@ -{image file-path="computer-studying-turing-test.png" alt="The computer is reading a book titled 'Talk like a human'"} - -Many humans take for granted the fact that they can easily have a conversation with another person, and choose appropriate things to say based on the conversation. The ability to do this is a form of intelligence, and for computers it isn’t so easy! Many attempts have been made to design computer programs that can have a conversation with a human and sound intelligent. These computer programs are called *chatterbots*, or just *chatbots*. diff --git a/verto/tests/assets/image/contains_image_expected.html b/verto/tests/assets/image/contains_image_expected.html deleted file mode 100644 index 2b98590e..00000000 --- a/verto/tests/assets/image/contains_image_expected.html +++ /dev/null @@ -1,4 +0,0 @@ -
-The computer is reading a book titled 'Talk like a human' -
-

Many humans take for granted the fact that they can easily have a conversation with another person, and choose appropriate things to say based on the conversation. The ability to do this is a form of intelligence, and for computers it isn’t so easy! Many attempts have been made to design computer programs that can have a conversation with a human and sound intelligent. These computer programs are called chatterbots, or just chatbots.

diff --git a/verto/tests/assets/image/contains_source.md b/verto/tests/assets/image/contains_source.md deleted file mode 100644 index 59ea9f28..00000000 --- a/verto/tests/assets/image/contains_source.md +++ /dev/null @@ -1 +0,0 @@ -{image file-path="computer-studying-turing-test.png" source="example.com"} diff --git a/verto/tests/assets/image/default_image.md b/verto/tests/assets/image/default_image.md deleted file mode 100644 index 5b391923..00000000 --- a/verto/tests/assets/image/default_image.md +++ /dev/null @@ -1,3 +0,0 @@ -{image file-path="computer-studying-turing-test.png" alt="The computer is reading a book titled 'Talk like a human'" title="title text" alignment="left" caption="caption text" caption-link="iamaurl.com" source="whatisthis.com"} - -Many humans take for granted the fact that they can easily have a conversation with another person, and choose appropriate things to say based on the conversation. The ability to do this is a form of intelligence, and for computers it isn’t so easy! Many attempts have been made to design computer programs that can have a conversation with a human and sound intelligent. These computer programs are called *chatterbots*, or just *chatbots*. diff --git a/verto/tests/assets/image/default_image_expected.html b/verto/tests/assets/image/default_image_expected.html deleted file mode 100644 index 39d3fe96..00000000 --- a/verto/tests/assets/image/default_image_expected.html +++ /dev/null @@ -1,6 +0,0 @@ - -

Many humans take for granted the fact that they can easily have a conversation with another person, and choose appropriate things to say based on the conversation. The ability to do this is a form of intelligence, and for computers it isn’t so easy! Many attempts have been made to design computer programs that can have a conversation with a human and sound intelligent. These computer programs are called chatterbots, or just chatbots.

diff --git a/verto/tests/assets/image/doc_example_2_override_html.md b/verto/tests/assets/image/doc_example_2_override_html.md deleted file mode 100644 index f6cf3551..00000000 --- a/verto/tests/assets/image/doc_example_2_override_html.md +++ /dev/null @@ -1 +0,0 @@ -{image file-path="apple.png"} diff --git a/verto/tests/assets/image/doc_example_2_override_html_expected.html b/verto/tests/assets/image/doc_example_2_override_html_expected.html deleted file mode 100644 index 91b50311..00000000 --- a/verto/tests/assets/image/doc_example_2_override_html_expected.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/verto/tests/assets/image/doc_example_2_override_html_template.html b/verto/tests/assets/image/doc_example_2_override_html_template.html deleted file mode 100644 index 1be3e5a3..00000000 --- a/verto/tests/assets/image/doc_example_2_override_html_template.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/verto/tests/assets/image/doc_example_2_override_link_html_template.html b/verto/tests/assets/image/doc_example_2_override_link_html_template.html deleted file mode 100644 index 0f9ddb49..00000000 --- a/verto/tests/assets/image/doc_example_2_override_link_html_template.html +++ /dev/null @@ -1 +0,0 @@ -https://www.example.com/images/{{ file_path }} diff --git a/verto/tests/assets/image/doc_example_basic_usage.md b/verto/tests/assets/image/doc_example_basic_usage.md deleted file mode 100644 index 396d7346..00000000 --- a/verto/tests/assets/image/doc_example_basic_usage.md +++ /dev/null @@ -1 +0,0 @@ -{image file-path="http://placehold.it/350x150" caption="Placeholder image" source="https://placehold.it/" hover-text="This is hover text" alignment="left"} diff --git a/verto/tests/assets/image/doc_example_override_html.md b/verto/tests/assets/image/doc_example_override_html.md deleted file mode 100644 index 49765d9b..00000000 --- a/verto/tests/assets/image/doc_example_override_html.md +++ /dev/null @@ -1 +0,0 @@ -{image file-path="http://placehold.it/350x150" caption="Placeholder image" source="https://placehold.it/"} diff --git a/verto/tests/assets/image/doc_example_override_html_template.html b/verto/tests/assets/image/doc_example_override_html_template.html deleted file mode 100644 index 1ea96063..00000000 --- a/verto/tests/assets/image/doc_example_override_html_template.html +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/verto/tests/assets/image/image_in_numbered_list.md b/verto/tests/assets/image/image_in_numbered_list.md deleted file mode 100644 index 7c79cfab..00000000 --- a/verto/tests/assets/image/image_in_numbered_list.md +++ /dev/null @@ -1,11 +0,0 @@ -1. Lipsum - - * Ichi - * Ni - * San - -2. Lorem - - {image file-path="http://placehold.it/350x150" caption="Placeholder image" source="https://placehold.it/" hover-text="This is hover text" alignment="left"} - -3. Ipsem diff --git a/verto/tests/assets/image/text_contains_the_word_image.md b/verto/tests/assets/image/text_contains_the_word_image.md deleted file mode 100644 index a3fc71c7..00000000 --- a/verto/tests/assets/image/text_contains_the_word_image.md +++ /dev/null @@ -1,6 +0,0 @@ -There is an image format that uses the simple one-symbol-per-pixel representation we have just described. The format is called "portable bitmap format" (PBM). -PBM files are saved with the file extension “.pbm”, and contain a simple header, followed by the image data. -The data in the file can be viewed by opening it in a text editor, much like opening a .txt file, -and the image itself can be viewed by opening it in a drawing or image viewing program that supports PBM files -(the format isn't very well supported, but a number of image viewing and editing programs can display them). -A pbm file for the diamond image used earlier would be as follows: diff --git a/verto/tests/assets/image/text_contains_the_word_image_expected.html b/verto/tests/assets/image/text_contains_the_word_image_expected.html deleted file mode 100644 index e9e3a96b..00000000 --- a/verto/tests/assets/image/text_contains_the_word_image_expected.html +++ /dev/null @@ -1,6 +0,0 @@ -

There is an image format that uses the simple one-symbol-per-pixel representation we have just described. The format is called "portable bitmap format" (PBM). -PBM files are saved with the file extension “.pbm”, and contain a simple header, followed by the image data. -The data in the file can be viewed by opening it in a text editor, much like opening a .txt file, -and the image itself can be viewed by opening it in a drawing or image viewing program that supports PBM files -(the format isn't very well supported, but a number of image viewing and editing programs can display them). -A pbm file for the diamond image used earlier would be as follows:

diff --git a/verto/tests/assets/panel/contains_inner_image.md b/verto/tests/assets/panel/contains_inner_image.md index d96ee30f..7fbdcc00 100644 --- a/verto/tests/assets/panel/contains_inner_image.md +++ b/verto/tests/assets/panel/contains_inner_image.md @@ -1,8 +1,16 @@ -{panel type="extra-for-experts" title="Lorem ipsum" subtitle="Nunc non accumsan" expanded="always"} +{panel type="extra-for-experts" subtitle="true" expanded="always"} + +# Lorem ipsum + +## Nunc non accumsan Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non accumsan libero, et suscipit velit. Phasellus quis lorem eget lacus rutrum lobortis. Integer tincidunt convallis arcu a porttitor. Ut urna sapien, egestas mollis lectus a, suscipit placerat ante. Vestibulum id congue tellus. Nullam dapibus felis eu ligula mattis, vel consectetur nibh aliquet. Maecenas nec elit orci. Curabitur ut massa maximus, ultrices diam at, porttitor erat. Praesent eu purus vitae ligula elementum iaculis in non eros. Quisque eu aliquet dolor, ut pharetra lacus. -{image file-path="http://placehold.it/350x150" caption="Placeholder image" source="https://placehold.it/" hover-text="This is hover text" alignment="left"} +{image file-path="http://placehold.it/350x150" caption="true" source="https://placehold.it/" hover-text="This is hover text" alignment="left"} + +Placeholder image + +{image end} Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non accumsan libero, et suscipit velit. Phasellus quis lorem eget lacus rutrum lobortis. Integer tincidunt convallis arcu a porttitor. Ut urna sapien, egestas mollis lectus a, suscipit placerat ante. Vestibulum id congue tellus. Nullam dapibus felis eu ligula mattis, vel consectetur nibh aliquet. Maecenas nec elit orci. Curabitur ut massa maximus, ultrices diam at, porttitor erat. Praesent eu purus vitae ligula elementum iaculis in non eros. Quisque eu aliquet dolor, ut pharetra lacus. diff --git a/verto/tests/assets/panel/contains_inner_panel.md b/verto/tests/assets/panel/contains_inner_panel.md index 9bce320c..e460e77b 100644 --- a/verto/tests/assets/panel/contains_inner_panel.md +++ b/verto/tests/assets/panel/contains_inner_panel.md @@ -1,8 +1,16 @@ -{panel type="extra-for-experts" title="Lorem ipsum" subtitle="Nunc non accumsan" expanded="always"} +{panel type="extra-for-experts" subtitle="true" expanded="always"} + +# Lorem ipsum + +## Nunc non accumsan Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non accumsan libero, et suscipit velit. Phasellus quis lorem eget lacus rutrum lobortis. Integer tincidunt convallis arcu a porttitor. Ut urna sapien, egestas mollis lectus a, suscipit placerat ante. Vestibulum id congue tellus. Nullam dapibus felis eu ligula mattis, vel consectetur nibh aliquet. Maecenas nec elit orci. Curabitur ut massa maximus, ultrices diam at, porttitor erat. Praesent eu purus vitae ligula elementum iaculis in non eros. Quisque eu aliquet dolor, ut pharetra lacus. -{panel type="extra-for-experts" title="Lorem ipsum" subtitle="Nunc non accumsan"} +{panel type="extra-for-experts" subtitle="true"} + +# Lorem ipsum + +## Nunc non accumsan Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non accumsan libero, et suscipit velit. Phasellus quis lorem eget lacus rutrum lobortis. Integer tincidunt convallis arcu a porttitor. Ut urna sapien, egestas mollis lectus a, suscipit placerat ante. Vestibulum id congue tellus. Nullam dapibus felis eu ligula mattis, vel consectetur nibh aliquet. Maecenas nec elit orci. Curabitur ut massa maximus, ultrices diam at, porttitor erat. Praesent eu purus vitae ligula elementum iaculis in non eros. Quisque eu aliquet dolor, ut pharetra lacus. diff --git a/verto/tests/assets/panel/contains_inner_panel_missing_subtitle.md b/verto/tests/assets/panel/contains_inner_panel_missing_subtitle.md new file mode 100644 index 00000000..038e783c --- /dev/null +++ b/verto/tests/assets/panel/contains_inner_panel_missing_subtitle.md @@ -0,0 +1,19 @@ +{panel type="extra-for-experts" subtitle="true" expanded="always"} + +# Lorem ipsum + +## Nunc non accumsan + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non accumsan libero, et suscipit velit. Phasellus quis lorem eget lacus rutrum lobortis. Integer tincidunt convallis arcu a porttitor. Ut urna sapien, egestas mollis lectus a, suscipit placerat ante. Vestibulum id congue tellus. Nullam dapibus felis eu ligula mattis, vel consectetur nibh aliquet. Maecenas nec elit orci. Curabitur ut massa maximus, ultrices diam at, porttitor erat. Praesent eu purus vitae ligula elementum iaculis in non eros. Quisque eu aliquet dolor, ut pharetra lacus. + +{panel type="extra-for-experts" subtitle="true"} + +# Lorem ipsum + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non accumsan libero, et suscipit velit. Phasellus quis lorem eget lacus rutrum lobortis. Integer tincidunt convallis arcu a porttitor. Ut urna sapien, egestas mollis lectus a, suscipit placerat ante. Vestibulum id congue tellus. Nullam dapibus felis eu ligula mattis, vel consectetur nibh aliquet. Maecenas nec elit orci. Curabitur ut massa maximus, ultrices diam at, porttitor erat. Praesent eu purus vitae ligula elementum iaculis in non eros. Quisque eu aliquet dolor, ut pharetra lacus. + +{panel end} + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non accumsan libero, et suscipit velit. Phasellus quis lorem eget lacus rutrum lobortis. Integer tincidunt convallis arcu a porttitor. Ut urna sapien, egestas mollis lectus a, suscipit placerat ante. Vestibulum id congue tellus. Nullam dapibus felis eu ligula mattis, vel consectetur nibh aliquet. Maecenas nec elit orci. Curabitur ut massa maximus, ultrices diam at, porttitor erat. Praesent eu purus vitae ligula elementum iaculis in non eros. Quisque eu aliquet dolor, ut pharetra lacus. + +{panel end} diff --git a/verto/tests/assets/panel/contains_multiple_panels.md b/verto/tests/assets/panel/contains_multiple_panels.md index 4c94085e..9e432297 100644 --- a/verto/tests/assets/panel/contains_multiple_panels.md +++ b/verto/tests/assets/panel/contains_multiple_panels.md @@ -1,4 +1,6 @@ -{panel type="extra-for-experts" title="Algorithm complexity"} +{panel type="extra-for-experts"} + +# Algorithm complexity The formal term for working out the cost of an algorithm is [algorithm analysis](https://en.wikipedia.org/wiki/Analysis_of_algorithms), and we often refer to the cost as the algorithm's *complexity*. The most common complexity is the "time complexity" (a rough idea of how long it takes to run), but often the "space complexity" is of interest - how much memory or disk space will the algorithm use up when it's running? @@ -6,13 +8,21 @@ There's more about how the cost of an algorithm is described in industry, using {panel end} -{panel type="extra-for-experts" title="Lorem ipsum" subtitle="Nunc non accumsan" expanded="always"} +{panel type="extra-for-experts" subtitle="true" expanded="always"} + +# Lorem ipsum + +## Nunc non accumsan Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non accumsan libero, et suscipit velit. Phasellus quis lorem eget lacus rutrum lobortis. Integer tincidunt convallis arcu a porttitor. Ut urna sapien, egestas mollis lectus a, suscipit placerat ante. Vestibulum id congue tellus. Nullam dapibus felis eu ligula mattis, vel consectetur nibh aliquet. Maecenas nec elit orci. Curabitur ut massa maximus, ultrices diam at, porttitor erat. Praesent eu purus vitae ligula elementum iaculis in non eros. Quisque eu aliquet dolor, ut pharetra lacus. {panel end} -{panel type="extra-for-experts" title="Lorem ipsum" subtitle="Nunc non accumsan"} +{panel type="extra-for-experts" subtitle="true"} + +# Lorem ipsum + +## Nunc non accumsan Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non accumsan libero, et suscipit velit. Phasellus quis lorem eget lacus rutrum lobortis. Integer tincidunt convallis arcu a porttitor. Ut urna sapien, egestas mollis lectus a, suscipit placerat ante. Vestibulum id congue tellus. Nullam dapibus felis eu ligula mattis, vel consectetur nibh aliquet. Maecenas nec elit orci. Curabitur ut massa maximus, ultrices diam at, porttitor erat. Praesent eu purus vitae ligula elementum iaculis in non eros. Quisque eu aliquet dolor, ut pharetra lacus. diff --git a/verto/tests/assets/panel/doc_example_basic_usage.md b/verto/tests/assets/panel/doc_example_basic_usage.md index f2687976..999c7bfd 100644 --- a/verto/tests/assets/panel/doc_example_basic_usage.md +++ b/verto/tests/assets/panel/doc_example_basic_usage.md @@ -1,4 +1,8 @@ -{panel type="teacher-note" title="Teacher Note" subtitle="Curriculum guides for Algorithms"} +{panel type="teacher-note" subtitle="true"} + +# Teacher Note + +## Curriculum guides for Algorithms This text is the panel's contents. diff --git a/verto/tests/assets/panel/doc_example_override_html.md b/verto/tests/assets/panel/doc_example_override_html.md index 27df553d..7d41598b 100644 --- a/verto/tests/assets/panel/doc_example_override_html.md +++ b/verto/tests/assets/panel/doc_example_override_html.md @@ -1,4 +1,6 @@ -{panel type="note" title="Note" expanded="true"} +{panel type="note" expanded="true"} + +# Note This panel uses Bootstrap 4 card structure. diff --git a/verto/tests/assets/panel/heading_incorrect_subtitle.md b/verto/tests/assets/panel/heading_incorrect_subtitle.md new file mode 100644 index 00000000..ed9ea3f8 --- /dev/null +++ b/verto/tests/assets/panel/heading_incorrect_subtitle.md @@ -0,0 +1,9 @@ +{panel type="note" subtitle="true"} + +# Heading + +# Subtitle + +This panel does have a subtitle! + +{panel end} diff --git a/verto/tests/assets/panel/heading_invalid_subtitle_argument.md b/verto/tests/assets/panel/heading_invalid_subtitle_argument.md new file mode 100644 index 00000000..e8bd6511 --- /dev/null +++ b/verto/tests/assets/panel/heading_invalid_subtitle_argument.md @@ -0,0 +1,9 @@ +{panel type="note" subtitle="cats"} + +# Heading + +## Subtitle + +This panel does have a subtitle! + +{panel end} diff --git a/verto/tests/assets/panel/heading_missing_subtitle.md b/verto/tests/assets/panel/heading_missing_subtitle.md new file mode 100644 index 00000000..ff701368 --- /dev/null +++ b/verto/tests/assets/panel/heading_missing_subtitle.md @@ -0,0 +1,7 @@ +{panel type="note" subtitle="true"} + +# Heading + +This panel is missing it's subtitle :( + +{panel end} diff --git a/verto/tests/assets/panel/heading_no_subtitle.md b/verto/tests/assets/panel/heading_no_subtitle.md new file mode 100644 index 00000000..2c281ee3 --- /dev/null +++ b/verto/tests/assets/panel/heading_no_subtitle.md @@ -0,0 +1,7 @@ +{panel type="note"} + +# Heading + +This panel does not have a subtitle + +{panel end} diff --git a/verto/tests/assets/panel/heading_no_subtitle_expected.html b/verto/tests/assets/panel/heading_no_subtitle_expected.html new file mode 100644 index 00000000..fa59321c --- /dev/null +++ b/verto/tests/assets/panel/heading_no_subtitle_expected.html @@ -0,0 +1,8 @@ +
+
+Heading +
+
+

This panel does not have a subtitle

+
+
diff --git a/verto/tests/assets/panel/heading_subtitle_false.md b/verto/tests/assets/panel/heading_subtitle_false.md new file mode 100644 index 00000000..be6c53b6 --- /dev/null +++ b/verto/tests/assets/panel/heading_subtitle_false.md @@ -0,0 +1,7 @@ +{panel type="note" subtitle="false"} + +# Heading + +This panel does not have a subtitle + +{panel end} diff --git a/verto/tests/assets/panel/heading_subtitle_false_expected.html b/verto/tests/assets/panel/heading_subtitle_false_expected.html new file mode 100644 index 00000000..fa59321c --- /dev/null +++ b/verto/tests/assets/panel/heading_subtitle_false_expected.html @@ -0,0 +1,8 @@ +
+
+Heading +
+
+

This panel does not have a subtitle

+
+
diff --git a/verto/tests/assets/panel/heading_subtitle_false_h2_heading_in_panel.md b/verto/tests/assets/panel/heading_subtitle_false_h2_heading_in_panel.md new file mode 100644 index 00000000..b8d21b7f --- /dev/null +++ b/verto/tests/assets/panel/heading_subtitle_false_h2_heading_in_panel.md @@ -0,0 +1,9 @@ +{panel type="note" subtitle="false"} + +# Heading + +## This is an h2 heading + +This panel does not have a subtitle + +{panel end} diff --git a/verto/tests/assets/panel/heading_subtitle_false_h2_heading_in_panel_expected.html b/verto/tests/assets/panel/heading_subtitle_false_h2_heading_in_panel_expected.html new file mode 100644 index 00000000..7fa349ba --- /dev/null +++ b/verto/tests/assets/panel/heading_subtitle_false_h2_heading_in_panel_expected.html @@ -0,0 +1,9 @@ +
+
+Heading +
+
+

This is an h2 heading

+

This panel does not have a subtitle

+
+
diff --git a/verto/tests/assets/panel/heading_with_subtitle.md b/verto/tests/assets/panel/heading_with_subtitle.md new file mode 100644 index 00000000..68119833 --- /dev/null +++ b/verto/tests/assets/panel/heading_with_subtitle.md @@ -0,0 +1,9 @@ +{panel type="note" subtitle="true"} + +# Heading + +## Subtitle + +This panel does have a subtitle! + +{panel end} diff --git a/verto/tests/assets/panel/heading_with_subtitle_expected.html b/verto/tests/assets/panel/heading_with_subtitle_expected.html new file mode 100644 index 00000000..92b98a7b --- /dev/null +++ b/verto/tests/assets/panel/heading_with_subtitle_expected.html @@ -0,0 +1,8 @@ +
+
+Heading: Subtitle +
+
+

This panel does have a subtitle!

+
+
diff --git a/verto/tests/assets/panel/heading_with_subtitle_h2_heading_in_panel.md b/verto/tests/assets/panel/heading_with_subtitle_h2_heading_in_panel.md new file mode 100644 index 00000000..9ecf96a9 --- /dev/null +++ b/verto/tests/assets/panel/heading_with_subtitle_h2_heading_in_panel.md @@ -0,0 +1,11 @@ +{panel type="note" subtitle="true"} + +# Heading + +## This is a subtitle + +## This is an h2 heading + +This panel does have a subtitle, as well as a level 2 heading + +{panel end} diff --git a/verto/tests/assets/panel/heading_with_subtitle_h2_heading_in_panel_expected.html b/verto/tests/assets/panel/heading_with_subtitle_h2_heading_in_panel_expected.html new file mode 100644 index 00000000..45f9df54 --- /dev/null +++ b/verto/tests/assets/panel/heading_with_subtitle_h2_heading_in_panel_expected.html @@ -0,0 +1,9 @@ +
+
+Heading: This is a subtitle +
+
+

This is an h2 heading

+

This panel does have a subtitle, as well as a level 2 heading

+
+
diff --git a/verto/tests/assets/panel/incorrect_heading_incorrect_subtitle.md b/verto/tests/assets/panel/incorrect_heading_incorrect_subtitle.md new file mode 100644 index 00000000..d94597e2 --- /dev/null +++ b/verto/tests/assets/panel/incorrect_heading_incorrect_subtitle.md @@ -0,0 +1,9 @@ +{panel type="note" subtitle="true"} + +#Heading + +##Subtitle + +This panel does have a subtitle...but both headings are incorrect + +{panel end} diff --git a/verto/tests/assets/panel/incorrect_heading_no_subtitle.md b/verto/tests/assets/panel/incorrect_heading_no_subtitle.md new file mode 100644 index 00000000..abd9b8f9 --- /dev/null +++ b/verto/tests/assets/panel/incorrect_heading_no_subtitle.md @@ -0,0 +1,7 @@ +{panel type="note"} + +## Heading + +This panel doesn't have a subtitle + +{panel end} diff --git a/verto/tests/assets/panel/incorrect_heading_with_subtitle.md b/verto/tests/assets/panel/incorrect_heading_with_subtitle.md new file mode 100644 index 00000000..665b5e70 --- /dev/null +++ b/verto/tests/assets/panel/incorrect_heading_with_subtitle.md @@ -0,0 +1,9 @@ +{panel type="note" subtitle="true"} + +## Subtitle + +# Heading + +This panel does have a subtitle! + +{panel end} diff --git a/verto/tests/assets/panel/missing_end_tag.md b/verto/tests/assets/panel/missing_end_tag.md index 710a7c47..aecf088c 100644 --- a/verto/tests/assets/panel/missing_end_tag.md +++ b/verto/tests/assets/panel/missing_end_tag.md @@ -1,7 +1,11 @@ -{panel type="curiosity" title="Curiosity" summary="How is Bozo search different from Linear search?"} +{panel type="curiosity" summary="How is Bozo search different from Linear search?"} + +# Curiosity If you watched the video at the beginning of the chapter you might be thinking that what you did in the present searching game sounds more like Bozo Search than Linear Search, but actually Bozo Search is even sillier than this! If you were doing a Bozo Search then after unwrapping a present and finding a monster inside, you would wrap the present back up and try another one at random! This means you might end up checking the same present again and again and again and you might never find the pet, even with a small number of presents! {panel end} -{panel type="extra-for-experts" title="Extra For Experts" summary="Algorithm complexity"} +{panel type="extra-for-experts" summary="Algorithm complexity"} + +# Extra For Experts diff --git a/verto/tests/assets/panel/missing_heading_missing_subtitle.md b/verto/tests/assets/panel/missing_heading_missing_subtitle.md new file mode 100644 index 00000000..11452bce --- /dev/null +++ b/verto/tests/assets/panel/missing_heading_missing_subtitle.md @@ -0,0 +1,5 @@ +{panel type="note" subtitle="true"} + +This panel is missing all the things. What a mess :'( + +{panel end} diff --git a/verto/tests/assets/panel/missing_heading_with_subtitle.md b/verto/tests/assets/panel/missing_heading_with_subtitle.md new file mode 100644 index 00000000..fa6f7abb --- /dev/null +++ b/verto/tests/assets/panel/missing_heading_with_subtitle.md @@ -0,0 +1,7 @@ +{panel type="note" subtitle="true"} + +## Subtitle + +This panel does has a subtitle but is missing it's heading! + +{panel end} diff --git a/verto/tests/assets/panel/missing_start_tag.md b/verto/tests/assets/panel/missing_start_tag.md index 9a0c998b..7b8e3442 100644 --- a/verto/tests/assets/panel/missing_start_tag.md +++ b/verto/tests/assets/panel/missing_start_tag.md @@ -1,4 +1,6 @@ -{panel type="curiosity" title="Curiosity" summary="How is Bozo search different from Linear search?"} +{panel type="curiosity" summary="How is Bozo search different from Linear search?"} + +# Curiosity If you watched the video at the beginning of the chapter you might be thinking that what you did in the present searching game sounds more like Bozo Search than Linear Search, but actually Bozo Search is even sillier than this! If you were doing a Bozo Search then after unwrapping a present and finding a monster inside, you would wrap the present back up and try another one at random! This means you might end up checking the same present again and again and again and you might never find the pet, even with a small number of presents! diff --git a/verto/tests/assets/panel/missing_tag_inner.md b/verto/tests/assets/panel/missing_tag_inner.md index f78cce40..b5d98019 100644 --- a/verto/tests/assets/panel/missing_tag_inner.md +++ b/verto/tests/assets/panel/missing_tag_inner.md @@ -1,7 +1,13 @@ -{panel type="extra-for-experts" title="Extra For Experts" subtitle="Something About Love"} +{panel type="extra-for-experts" subtitle="true"} + +# Extra For Experts + +## Something About Love {panel type="curiosity" title="Curiosity" summary="How is Bozo search different from Linear search?"} +# Curiosity + If you watched the video at the beginning of the chapter you might be thinking that what you did in the present searching game sounds more like Bozo Search than Linear Search, but actually Bozo Search is even sillier than this! If you were doing a Bozo Search then after unwrapping a present and finding a monster inside, you would wrap the present back up and try another one at random! This means you might end up checking the same present again and again and again and you might never find the pet, even with a small number of presents! {panel end} diff --git a/verto/tests/assets/panel/panel_in_numbered_list.md b/verto/tests/assets/panel/panel_in_numbered_list.md index 0047a351..94a1cb5e 100644 --- a/verto/tests/assets/panel/panel_in_numbered_list.md +++ b/verto/tests/assets/panel/panel_in_numbered_list.md @@ -6,7 +6,11 @@ 2. Lorem - {panel type="teacher-note" title="Teacher Note" subtitle="Curriculum guides for Algorithms"} + {panel type="teacher-note" subtitle="true"} + + # Teacher Note + + ## Curriculum guides for Algorithms This text is the panel's contents. diff --git a/verto/tests/assets/panel/panel_only_in_numbered_list.md b/verto/tests/assets/panel/panel_only_in_numbered_list.md index e5c954f1..aad72a45 100644 --- a/verto/tests/assets/panel/panel_only_in_numbered_list.md +++ b/verto/tests/assets/panel/panel_only_in_numbered_list.md @@ -4,7 +4,11 @@ * Ni * San -2. {panel type="teacher-note" title="Teacher Note" subtitle="Curriculum guides for Algorithms"} +2. {panel type="teacher-note" subtitle="true"} + + # Teacher Note + + ## Curriculum guides for Algorithms This text is the panel's contents. diff --git a/verto/tests/assets/panel/parses_always_expanded_panel.md b/verto/tests/assets/panel/parses_always_expanded_panel.md index 5de9f78c..6f56d7e9 100644 --- a/verto/tests/assets/panel/parses_always_expanded_panel.md +++ b/verto/tests/assets/panel/parses_always_expanded_panel.md @@ -1,4 +1,8 @@ -{panel type="extra-for-experts" title="Lorem ipsum" subtitle="Nunc non accumsan" expanded="always"} +{panel type="extra-for-experts" subtitle="true" expanded="always"} + +# Lorem ipsum + +## Nunc non accumsan Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non accumsan libero, et suscipit velit. Phasellus quis lorem eget lacus rutrum lobortis. Integer tincidunt convallis arcu a porttitor. Ut urna sapien, egestas mollis lectus a, suscipit placerat ante. Vestibulum id congue tellus. Nullam dapibus felis eu ligula mattis, vel consectetur nibh aliquet. Maecenas nec elit orci. Curabitur ut massa maximus, ultrices diam at, porttitor erat. Praesent eu purus vitae ligula elementum iaculis in non eros. Quisque eu aliquet dolor, ut pharetra lacus. diff --git a/verto/tests/assets/panel/parses_blank.md b/verto/tests/assets/panel/parses_blank.md index 27f10ee8..cfae88e2 100644 --- a/verto/tests/assets/panel/parses_blank.md +++ b/verto/tests/assets/panel/parses_blank.md @@ -1,3 +1,7 @@ -{panel type="extra-for-experts" title="Extra For Experts" subtitle="Something About Love"} +{panel type="extra-for-experts" subtitle="true"} + +# Extra For Experts + +## Something About Love {panel end} diff --git a/verto/tests/assets/panel/parses_blank_lines_multiple_paragraphs.md b/verto/tests/assets/panel/parses_blank_lines_multiple_paragraphs.md index 9fa7479a..b068ac0c 100644 --- a/verto/tests/assets/panel/parses_blank_lines_multiple_paragraphs.md +++ b/verto/tests/assets/panel/parses_blank_lines_multiple_paragraphs.md @@ -1,4 +1,8 @@ -{panel type="extra-for-experts" title="Lorem ipsum" subtitle="Nunc non accumsan"} +{panel type="extra-for-experts" subtitle="true"} + +# Lorem ipsum + +## Nunc non accumsan Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean blandit, eros a tristique laoreet, massa enim vehicula sapien, ut convallis eros leo consectetur nunc. Praesent eu arcu nec elit maximus gravida. Proin volutpat blandit ipsum, ac ullamcorper est hendrerit a. Sed quis commodo enim, quis ornare nunc. Donec convallis nibh in tellus tempor, vitae molestie nisl commodo. Phasellus in odio ac ligula dapibus rhoncus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla pretium tellus vitae leo pretium, id sollicitudin sem laoreet. Duis egestas cursus dui et volutpat. Suspendisse malesuada sed nisl a eleifend. Donec mattis metus erat, volutpat luctus purus maximus ut. Donec porttitor nibh viverra dui scelerisque lobortis. Cras at tincidunt lorem. Duis imperdiet rutrum mi, non molestie velit. Nunc eget lobortis libero, at vulputate risus. Maecenas posuere ante mi, eu interdum libero vestibulum vel. diff --git a/verto/tests/assets/panel/parses_expanded_panel.md b/verto/tests/assets/panel/parses_expanded_panel.md index 8febb77f..c1fd9aa6 100644 --- a/verto/tests/assets/panel/parses_expanded_panel.md +++ b/verto/tests/assets/panel/parses_expanded_panel.md @@ -1,4 +1,8 @@ -{panel type="extra-for-experts" title="Lorem ipsum" subtitle="Nunc non accumsan" expanded="true"} +{panel type="extra-for-experts" subtitle="true" expanded="true"} + +# Lorem ipsum + +## Nunc non accumsan Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non accumsan libero, et suscipit velit. Phasellus quis lorem eget lacus rutrum lobortis. Integer tincidunt convallis arcu a porttitor. Ut urna sapien, egestas mollis lectus a, suscipit placerat ante. Vestibulum id congue tellus. Nullam dapibus felis eu ligula mattis, vel consectetur nibh aliquet. Maecenas nec elit orci. Curabitur ut massa maximus, ultrices diam at, porttitor erat. Praesent eu purus vitae ligula elementum iaculis in non eros. Quisque eu aliquet dolor, ut pharetra lacus. diff --git a/verto/tests/assets/panel/parses_no_blank_lines_single_paragraph.md b/verto/tests/assets/panel/parses_no_blank_lines_single_paragraph.md index 26b13a23..8de2700a 100644 --- a/verto/tests/assets/panel/parses_no_blank_lines_single_paragraph.md +++ b/verto/tests/assets/panel/parses_no_blank_lines_single_paragraph.md @@ -1,4 +1,8 @@ -{panel type="extra-for-experts" title="Lorem ipsum" subtitle="Nunc non accumsan"} +{panel type="extra-for-experts" subtitle="true"} + +# Lorem ipsum + +## Nunc non accumsan Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc non accumsan libero, et suscipit velit. Phasellus quis lorem eget lacus rutrum lobortis. Integer tincidunt convallis arcu a porttitor. Ut urna sapien, egestas mollis lectus a, suscipit placerat ante. Vestibulum id congue tellus. Nullam dapibus felis eu ligula mattis, vel consectetur nibh aliquet. Maecenas nec elit orci. Curabitur ut massa maximus, ultrices diam at, porttitor erat. Praesent eu purus vitae ligula elementum iaculis in non eros. Quisque eu aliquet dolor, ut pharetra lacus. diff --git a/verto/tests/assets/relative-link/doc_example_override_html_template.html b/verto/tests/assets/relative-link/doc_example_override_html_template.html index 91c06331..91c660f4 100644 --- a/verto/tests/assets/relative-link/doc_example_override_html_template.html +++ b/verto/tests/assets/relative-link/doc_example_override_html_template.html @@ -1 +1 @@ -http://www.example.com/{{ link_path }} +http://www.example.com/{{ link_path }}{{ link_query }} diff --git a/verto/tests/assets/relative-link/multiple_query_parameters.md b/verto/tests/assets/relative-link/multiple_query_parameters.md new file mode 100644 index 00000000..48af409a --- /dev/null +++ b/verto/tests/assets/relative-link/multiple_query_parameters.md @@ -0,0 +1 @@ +Check out this [resource](resource/134?key1=value1&key2=value2). diff --git a/verto/tests/assets/relative-link/multiple_query_parameters_expected.html b/verto/tests/assets/relative-link/multiple_query_parameters_expected.html new file mode 100644 index 00000000..9cdc27fc --- /dev/null +++ b/verto/tests/assets/relative-link/multiple_query_parameters_expected.html @@ -0,0 +1 @@ +

Check out this resource.

diff --git a/verto/tests/assets/relative-link/query_parameter.md b/verto/tests/assets/relative-link/query_parameter.md new file mode 100644 index 00000000..bce0aa68 --- /dev/null +++ b/verto/tests/assets/relative-link/query_parameter.md @@ -0,0 +1 @@ +Check out this [resource](resource/134?key=value). diff --git a/verto/tests/assets/relative-link/query_parameter_expected.html b/verto/tests/assets/relative-link/query_parameter_expected.html new file mode 100644 index 00000000..6ae60241 --- /dev/null +++ b/verto/tests/assets/relative-link/query_parameter_expected.html @@ -0,0 +1 @@ +

Check out this resource.

diff --git a/verto/tests/assets/relative-link/trailing_question_mark.md b/verto/tests/assets/relative-link/trailing_question_mark.md new file mode 100644 index 00000000..daa1404e --- /dev/null +++ b/verto/tests/assets/relative-link/trailing_question_mark.md @@ -0,0 +1 @@ +Check out this [resource](resource/134?). diff --git a/verto/tests/assets/relative-link/trailing_question_mark_expected.html b/verto/tests/assets/relative-link/trailing_question_mark_expected.html new file mode 100644 index 00000000..cf08d753 --- /dev/null +++ b/verto/tests/assets/relative-link/trailing_question_mark_expected.html @@ -0,0 +1 @@ +

Check out this resource.

diff --git a/verto/tests/assets/smoke/algorithms.md b/verto/tests/assets/smoke/algorithms.md index 9a773991..a7fd564e 100644 --- a/verto/tests/assets/smoke/algorithms.md +++ b/verto/tests/assets/smoke/algorithms.md @@ -110,7 +110,9 @@ Not all algorithms take double the time for double the input; some take a lot mo That's worth knowing in advance because we usually need our programs to scale up well; in the case of the high scores, if you're running a game that suddenly becomes popular, you want to know in advance that the high score algorithm will be fast enough if you get more scores to check. -{panel type="extra-for-experts" title="Extra For Experts"} +{panel type="extra-for-experts"} + +# Extra For Experts The formal term for working out the cost of an algorithm is [algorithm analysis](https://en.wikipedia.org/wiki/Analysis_of_algorithms), and we often refer to the cost as the algorithm's *complexity*. @@ -137,7 +139,9 @@ They also happen to be great for illustrating some of the key concepts that aris ## Searching -{panel type="teacher-note" title="Teacher Note" summary="Presenting searching in the classroom"} +{panel type="teacher-note" summary="Presenting searching in the classroom"} + +# Teacher Note The present searching game in this section is split into two parts, the first corresponds to the Linear Search algorithm (also known as Sequential Search) and the second corresponds to {glossary-link term="Binary Search"}Binary Search{glossary-link end}. We recommend you play through the levels yourself for a while, or after reading this description. It is based on the [CS Unplugged Battleships game](http://csunplugged.com/searching-algorithms) which can be used as a classroom activity to enforce the lessons in this chapter (the hashing activity is not used for the present searching game). The @@ -172,7 +176,9 @@ Since the boxes in the first game were in a random order there really wasn't any If you used this algorithm you might get lucky and find what you are looking for on your first go, but if you were really unlucky you might have to look through everything in your list before you found the right object! For a list of 10 items this means on average you would only have to look at 5 items to find what you were looking for, but for a list of 10000 you would have to look through on average 5000. -{panel type="curiosity" title="Curiosity" summary="How is Bozo search different from Linear search?"} +{panel type="curiosity" summary="How is Bozo search different from Linear search?"} + +# Curiosity If you watched the video at the beginning of the chapter you might be thinking that what you did in the present searching game sounds more like Bozo Search than Linear Search, but actually Bozo Search is even sillier than this! If you were doing a Bozo Search then after unwrapping a present and finding a monster inside, you would wrap the present back up and try another one at random! This means you might end up checking the same present again and again and again and you might never find the pet, even with a small number of presents! @@ -184,7 +190,9 @@ If you watched the video at the beginning of the chapter you might be thinking t A much better algorithm to use is called Binary Search. In the second part of the present searching game the boxes were in order, which meant you were able to be more clever when you were searching for the pet, and you might have been using a Binary Search without realising! -{panel type="teacher-note" title="Teacher Note" summary="Teaching binary search with a phone book"} +{panel type="teacher-note" summary="Teaching binary search with a phone book"} + +# Teacher Note The binary search algorithm can be demonstrated with a phone book or dictionary: choose a name, then open it at the *middle* page of the book (students might point out that you could guess how far through to open it, but insist on starting in the middle). If you can spare the book, rip it in half at the chosen page, and ask the class which of the two halves contains the name (the ones before the middle, or the ones after). @@ -204,7 +212,9 @@ If you used a Binary Search on each of the levels then you would have always had Binary Search is a very powerful algorithm. If you had 1000 presents to search through it would take you at most 10 checks for Binary search to find something and Linear search would take at most 1000 checks, but if you doubled the number of presents to search through how would this change the number of checks made by Binary Search and Linear search? -{panel type="spoiler" title="Spoiler" summary="How does doubling the number of boxes affect the number of checks required?"} +{panel type="spoiler" summary="How does doubling the number of boxes affect the number of checks required?"} + +# Spoiler The answer to the above question is that the maximum number of checks for Linear Search would double, but the maximum number for Binary Search would only increase by one. @@ -213,7 +223,9 @@ The answer to the above question is that the maximum number of checks for Linear It is important to remember that you can only perform a Binary Search if the items you are searching through are sorted into order. This makes the sorting algorithms we will look at next even more important because without sorting algorithms we wouldn't be able to use Binary Search to quickly look through data! -{panel type="project" title="Project" summary="Code to run linear and binary search for yourself"} +{panel type="project" summary="Code to run linear and binary search for yourself"} + +# Project The following files will run linear and binary search in various languages; you can use them to generate random lists of values and measure how long they take to find a given value. Your project is to measure the amount of time taken as the number of items (*n*) increases; try drawing a graph showing this. @@ -227,7 +239,9 @@ Your project is to measure the amount of time taken as the number of items (*n*) ## Sorting -{panel type="teacher-note" title="Teacher Note" summary="Why are we also covering sorting?"} +{panel type="teacher-note" summary="Why are we also covering sorting?"} + +# Teacher Note Our main points have already been made --- what an algorithm is, how to estimate its cost, and that the cost isn't always proportional to the amount of data. However, it's good to reinforce this with some different algorithms. @@ -265,7 +279,9 @@ Tip: Start by moving all the boxes to the right of the screen and then once you If you record how many comparisons you had to make each time to find the next lightest box you might notice a pattern (hint: finding the lightest should take 7 comparisons, and then finding the second lightest should take 6 comparisons…). If you can see the pattern then how many comparisons do you think it would take to then sort 9 boxes into order? What about 20? If you knew how many comparisons it would take to sort 1000 boxes, then how many more comparisons would it take to sort 1001 instead? -{panel type="teacher-note" title="Teacher Note" summary="Answer for box analysis"} +{panel type="teacher-note" summary="Answer for box analysis"} + +# Teacher Note For a list of 8 objects (like in the interactive) it should take 7 comparisons to find the lightest, 6 to find the next lightest, 5 to find the next, then 4, then 3, then 2, and then 1 to sort the final two boxes. In total this is 7+6+5+4+3+2+1 = 28 comparisons. If there had been 9 boxes it would have taken 8+7+6+5+4+3+2+1 = 36 comparisons. 20 boxes will take 190. Going from 1000 boxes up to 1001 will require 1000 extra comparisons, even though only 1 box has been added. Selection sort will always take $(n\times(n-1))/2$ comparisons to sort *n* items into order. @@ -301,7 +317,9 @@ You can swap the word 'smallest' for 'largest' and the algorithm will still work ### Insertion Sort -{panel type="teacher-note" title="Teacher Note" summary="This section could be skipped"} +{panel type="teacher-note" summary="This section could be skipped"} + +# Teacher Note This algorithm is useful and commonly taught, although for the purpose of teaching the principles of algorithms, it's doesn't add a lot to what we've just covered with selection sort, so could be skipped. However, if you have time, it's worth looking at for extra examples. @@ -347,7 +365,9 @@ Quicksort can be described in the following way: - Place all the items that are greater than it into one subgroup and all the items that are smaller into another subgroup. Place the pivot item in between these two subgroups. - Choose a subgroup and repeat this process. Eventually each subgroup will contain only one item and at this stage the items will be in sorted order. -{panel type="project" title="Project" summary="Code to run selection sort and quicksort for yourself"} +{panel type="project" summary="Code to run selection sort and quicksort for yourself"} + +# Project The following files will run selection sort and quicksort in various languages; you can use them to generate random lists of values and measure how long they take to be sorted. Note how long these take for various amounts of input (*n*), and show it in a table or graph. @@ -372,7 +392,9 @@ In this chapter we have only talked about the number of comparisons an algorithm $n^2$ -{panel type="extra-for-experts" title="Extra For Experts" summary="Examples of Big O notation"} +{panel type="extra-for-experts" summary="Examples of Big O notation"} + +# Extra For Experts Here are some Big O examples: diff --git a/verto/tests/assets/smoke/introduction.md b/verto/tests/assets/smoke/introduction.md index 64da4193..c2678def 100644 --- a/verto/tests/assets/smoke/introduction.md +++ b/verto/tests/assets/smoke/introduction.md @@ -1,6 +1,8 @@ # Introduction -{panel type="teacher-note" title="teacher-note" summary="Introduction for teachers"} +{panel type="teacher-note" summary="Introduction for teachers"} + +# Teacher Note This guide is an online interactive textbook to support teaching computer science in high schools. It was initially developed to support the new achievement standards in Computer Science that are being rolled out in New Zealand from 2011 to 2013, diff --git a/verto/tests/start_tests.py b/verto/tests/start_tests.py index c24a04f8..eacb1c89 100644 --- a/verto/tests/start_tests.py +++ b/verto/tests/start_tests.py @@ -1,6 +1,4 @@ import sys, unittest, optparse -from collections import defaultdict - from verto.tests.ConfigurationTest import ConfigurationTest from verto.tests.SmokeTests import SmokeFileTest, SmokeDocsTest @@ -12,7 +10,8 @@ from verto.tests.GlossaryLinkTest import GlossaryLinkTest from verto.tests.HeadingTest import HeadingTest from verto.tests.ImageInlineTest import ImageInlineTest -from verto.tests.ImageTest import ImageTest +from verto.tests.ImageTagTest import ImageTagTest +from verto.tests.ImageContainerTest import ImageContainerTest from verto.tests.JinjaTest import JinjaTest from verto.tests.InteractiveTest import InteractiveTest from verto.tests.PanelTest import PanelTest @@ -29,6 +28,7 @@ from verto.tests.HtmlParserTest import HtmlParserTest from verto.tests.MarkdownOverrideTest import MarkdownOverrideTest + def parse_args(): '''Parses the arguments for running the test suite, these are useful for developing when parts of verto are known to fail. @@ -47,6 +47,7 @@ def parse_args(): return options, arguments + def smoke_suite(): '''Builds the smoke tests. ''' @@ -55,6 +56,7 @@ def smoke_suite(): unittest.makeSuite(SmokeFileTest), )) + def system_suite(): '''Builds specific system tests. ''' @@ -62,6 +64,7 @@ def system_suite(): unittest.makeSuite(ConfigurationTest) )) + def unit_suite(): '''Builds unittests. (Not really unittests). ''' @@ -74,7 +77,8 @@ def unit_suite(): unittest.makeSuite(GlossaryLinkTest), unittest.makeSuite(HeadingTest), unittest.makeSuite(ImageInlineTest), - unittest.makeSuite(ImageTest), + unittest.makeSuite(ImageTagTest), + unittest.makeSuite(ImageContainerTest), unittest.makeSuite(InteractiveTest), unittest.makeSuite(JinjaTest), unittest.makeSuite(PanelTest), @@ -92,6 +96,7 @@ def unit_suite(): unittest.makeSuite(MarkdownOverrideTest), )) + if __name__ == '__main__': options, arguments = parse_args() diff --git a/verto/utils/UniqueSlugify.py b/verto/utils/UniqueSlugify.py index c6423466..12179a0a 100644 --- a/verto/utils/UniqueSlugify.py +++ b/verto/utils/UniqueSlugify.py @@ -47,9 +47,8 @@ def __call__(self, text): while new_slug in self.uids: count += 1 end_index = len(slug) - if self.max_length and (len(slug) - + len(self.occurance_separator) - + floor(log10(count))) >= self.max_length: + if self.max_length and (len(slug) + + len(self.occurance_separator) + floor(log10(count))) >= self.max_length: end_index = self.max_length - floor(log10(count)) - len(self.occurance_separator) - 1 new_slug = '{0}{1}{2}'.format(slug[:end_index], self.occurance_separator, count) self.uids.add(new_slug) diff --git a/verto/utils/image_file_name_components.py b/verto/utils/image_file_name_components.py new file mode 100644 index 00000000..a8ab5c80 --- /dev/null +++ b/verto/utils/image_file_name_components.py @@ -0,0 +1,26 @@ +"""Splits components of image file path.""" + +import re +from os.path import splitext + + +def image_file_name_components(full_file_path): + """Splits components of image file path. + + Args: + full_file_path (str): The complete image file path. + + Returns: + Dictionary of strings for components of file path. + """ + components = dict() + file_path_without_ext, file_extension = splitext(full_file_path) + pattern = re.compile(r'(?P[^@]+)(@(?P\d+)(?P.*))?') + match = pattern.match(file_path_without_ext) + components['file_path'] = match.group('file_path') + file_width_value = match.group('file_width_value') + if file_width_value: + components['file_width_value'] = int(file_width_value) + components['file_width_unit'] = match.group('file_width_unit') + components['file_extension'] = file_extension + return components diff --git a/verto/utils/overrides.py b/verto/utils/overrides.py index 0a228faa..b07e771a 100644 --- a/verto/utils/overrides.py +++ b/verto/utils/overrides.py @@ -134,8 +134,7 @@ def get_items(self, blocks): match = self.RE.match(block) if match is not None: relevant_block_groups.append([]) - elif not (block.startswith(' ' * self.tab_length) - or block.strip() == ''): + elif not (block.startswith(' ' * self.tab_length) or block.strip() == ''): blocks.insert(0, block) break relevant_block_groups[-1].append(block) @@ -154,8 +153,7 @@ def get_items(self, blocks): INTEGER_RE = re.compile('(\d+)') self.STARTSWITH = INTEGER_RE.match(match.group(1)).group() item_groups.append([match.group(3)]) - elif (self.INDENT_RE.match(line) - and not self.INDENT_CONT_RE.match(item_groups[-1][-1])): + elif (self.INDENT_RE.match(line) and not self.INDENT_CONT_RE.match(item_groups[-1][-1])): item_groups[-1].append(self.looseDetab(line)) elif self.INDENT_RE.match(line): item_groups[-1][-1] = '{}\n{}'.format(item_groups[-1][-1], self.looseDetab(line))