diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..b60f8793 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,7 @@ +[run] +branch = True +source = + verto +omit = + # Omit test files + */tests/* diff --git a/.travis.yml b/.travis.yml index aefbe3ff..4b46ec43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,11 @@ install: script: - flake8 - python -m verto.tests.start_tests --travis + - coverage run --rcfile=.coveragerc -m verto.tests.start_tests --travis +after_success: + - coverage xml -i + - coverage report -m --skip-covered + - bash <(curl -s https://codecov.io/bash) # Stop email notifications but post to organisation Slack channel notifications: diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 9d3c693f..ee9df8d4 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -1,6 +1,16 @@ Changelog ####################################### +0.9.0 +======================================= + +- Add :doc:`processors/blockquote` processor for customising block quote style. +- Added CodeCov to repo +- Dependency updates: + + - Update ``python-slugify`` to 1.2.6 + - Update ``sphinx`` to 1.8.0 + 0.8.0 ======================================= diff --git a/docs/source/processors/blockquote.rst b/docs/source/processors/blockquote.rst new file mode 100644 index 00000000..1fa79934 --- /dev/null +++ b/docs/source/processors/blockquote.rst @@ -0,0 +1,62 @@ +Blockquote +####################################### + +**Processor name:** ``blockquote`` + +You can include an blockquote using the following text tag: + +.. literalinclude:: ../../../verto/tests/assets/blockquote/doc_example_basic_usage.md + :language: none + +Optional Tag Parameters +*************************************** + +- ``footer`` - Boolean flag to indicate whether the blockquote contains a footer. + + - If given as ``true``, then the last line should start with ``- `` to show it's the footer. + +- ``source`` - Sets the ``cite`` parameter of the ``blockquote`` element. + +- ``alignment`` - Valid values are 'left', 'center', or 'right'. Providing one of these values Will add CSS classes to the image for alignment. + +The default HTML for a panel is: + +.. literalinclude:: ../../../verto/html-templates/blockquote.html + :language: css+jinja + +Using the following example tag: + +.. literalinclude:: ../../../verto/tests/assets/blockquote/doc_example_basic_usage.md + :language: none + +The resulting HTML would be: + +.. literalinclude:: ../../../verto/tests/assets/blockquote/doc_example_basic_usage_expected.html + :language: html + +Overriding HTML for Blockquote +*************************************** + +When overriding the HTML for blockquotes, the following Jinja2 placeholders are available: + +- ``{{ content }}`` - The text enclosed by the blockquote tags. +- ``{{ footer }}`` - The provided footer text. +- ``{{ alignment }}`` - The location to add extra CSS classes for alignment. +- ``{{ source }}`` - The URL for the source. + +**Example** + +For example, providing the following HTML: + +.. literalinclude:: ../../../verto/tests/assets/blockquote/doc_example_override_html_template.html + :language: css+jinja + +with the following tag: + +.. literalinclude:: ../../../verto/tests/assets/blockquote/doc_example_override_html.md + :language: none + +would result in: + +.. literalinclude:: ../../../verto/tests/assets/blockquote/doc_example_override_html_expected.html + :language: html diff --git a/docs/source/processors/image-inline.rst b/docs/source/processors/image-inline.rst index b54ba2cc..aa75678b 100644 --- a/docs/source/processors/image-inline.rst +++ b/docs/source/processors/image-inline.rst @@ -1,7 +1,7 @@ Inline Image ####################################### -**Processor name:** ``image-inline`` +**Processor name:** ``image-inline`` (see also :doc:`image`) .. note:: diff --git a/docs/source/processors/image.rst b/docs/source/processors/image.rst index f1b55d3e..ef7d41b0 100644 --- a/docs/source/processors/image.rst +++ b/docs/source/processors/image.rst @@ -1,7 +1,7 @@ Image ####################################### -**Processor name:** ``image-tag`` and ``image-container`` +**Processor name:** ``image-tag`` and ``image-container`` (see also :doc:`image-inline`) You can include an image using the following text tag: @@ -42,7 +42,7 @@ Optional Tag Parameters - ``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. +- ``source`` - 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. @@ -73,8 +73,8 @@ When overriding the HTML for images, the following Jinja2 placeholders are avail - ``{{ 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 . +- ``{{ 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 ``{{ file_relative }}`` is ``True``, the following placeholders are also available to allow finer control of output of relative images (see *Example 2* below): diff --git a/docs/source/processors/index.rst b/docs/source/processors/index.rst index 30f286df..87d30205 100644 --- a/docs/source/processors/index.rst +++ b/docs/source/processors/index.rst @@ -13,6 +13,7 @@ The following pages covers how to use the available processors within Markdown t .. toctree:: :maxdepth: 1 + blockquote boxed-text button-link comment diff --git a/docs/source/processors/panel.rst b/docs/source/processors/panel.rst index ac9c5649..72920d4f 100644 --- a/docs/source/processors/panel.rst +++ b/docs/source/processors/panel.rst @@ -49,7 +49,7 @@ The resulting HTML would be: Overriding HTML for Panels *************************************** -When overriding the HTML for images, the following Jinja2 placeholders are available: +When overriding the HTML for panels, the following Jinja2 placeholders are available: - ``{{ type }}`` - The type of panel to be created. - ``{{ expanded }}`` - Text either set to 'true' or 'always' to state if the panel should be expanded. See parameter description above. diff --git a/docs/source/usage.rst b/docs/source/usage.rst index c215f36b..0f1e3c2f 100644 --- a/docs/source/usage.rst +++ b/docs/source/usage.rst @@ -53,13 +53,33 @@ Once the module is imported, you can create a Verto converter creating an Verto - ``custom_argument_rules`` - A dictionary to modify the default argument rules for each tag. The default rules can found by reading the documentation for each tag. - - *For example:* By default, the ``image-inline`` tag requires alt text to be given, to change this, the following custom argument rules file would be used: + - *For example:* By default, the ``image-inline`` tag requires alt text to be given, to change this, the following custom argument rules would be used: .. code-block:: python { "image-inline": { - "alt": false + "alt": False + } + } + + .. warning:: + + Some tags have multiple processors behind them (for example, the ``image-inline``, ``image-container`` and ``image-tag`` processors are all used for images). + This means that if you would like to change the default rules of one or more of their arguments, this will need to be done for each of the processors + individually. For example, to set the ``alt`` argument as ``False`` for all images, the custom argument rules would look as follows: + + .. code-block:: python + + { + "image-inline": { + "alt": False + }, + "image-tag": { + "alt": False + }, + "image-container": { + "alt": False } } diff --git a/requirements.txt b/requirements.txt index 9888d27a..151184e2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,12 @@ # Required dependencies for Verto (installed automatically in setup.py) markdown==2.6.11 Jinja2==2.10 -python-slugify==1.2.5 +python-slugify==1.2.6 setuptools==40.2.0 # Required dependencies for building documentation -sphinx==1.7.7 +sphinx==1.8.0 sphinx_rtd_theme==0.4.1 + +# Coverage Tools +coverage==4.5.1 diff --git a/verto/Verto.py b/verto/Verto.py index 43c9f051..6c4de91e 100644 --- a/verto/Verto.py +++ b/verto/Verto.py @@ -2,6 +2,7 @@ from verto.VertoExtension import VertoExtension DEFAULT_PROCESSORS = frozenset({ + 'blockquote', 'boxed-text', 'button-link', 'comment', diff --git a/verto/VertoExtension.py b/verto/VertoExtension.py index 815cd61e..a9c07615 100644 --- a/verto/VertoExtension.py +++ b/verto/VertoExtension.py @@ -2,6 +2,7 @@ import markdown.util as utils from verto.processors.CommentPreprocessor import CommentPreprocessor +from verto.processors.BlockquoteBlockProcessor import BlockquoteBlockProcessor from verto.processors.VideoBlockProcessor import VideoBlockProcessor from verto.processors.ImageInlinePattern import ImageInlinePattern from verto.processors.ImageTagBlockProcessor import ImageTagBlockProcessor @@ -185,6 +186,7 @@ def buildProcessors(self, md, md_globals): ['video', VideoBlockProcessor(self, md.parser), ' +{% autoescape false -%} +{{ content }} +{%- endautoescape -%} +{% if footer %} +
+{{ footer }} +
+{% endif %} + diff --git a/verto/processor-info.json b/verto/processor-info.json index bf35e8a7..7251cad1 100644 --- a/verto/processor-info.json +++ b/verto/processor-info.json @@ -1,4 +1,36 @@ { + "blockquote": { + "class": "custom", + "arguments": { + "alignment": { + "required": false, + "dependencies": [], + "values": ["left", "center", "right"] + }, + "source": { + "required": false, + "dependencies": [] + }, + "footer": { + "required": false, + "values": ["true", "false"] + } + }, + "template_parameters": { + "content": { + "argument": "content" + }, + "footer": { + "argument": "footer" + }, + "alignment": { + "argument": "alignment" + }, + "source": { + "argument": "source" + } + } + }, "boxed-text": { "class": "generic_container", "arguments": { diff --git a/verto/processors/BlockquoteBlockProcessor.py b/verto/processors/BlockquoteBlockProcessor.py new file mode 100644 index 00000000..a1924168 --- /dev/null +++ b/verto/processors/BlockquoteBlockProcessor.py @@ -0,0 +1,45 @@ +from verto.processors.GenericContainerBlockProcessor import GenericContainerBlockProcessor +from verto.errors.BlockquoteMissingFooterError import BlockquoteMissingFooterError + +BLOCKQUOTE_FOOTER_PREFIX = "- " + + +class BlockquoteBlockProcessor(GenericContainerBlockProcessor): + def __init__(self, *args, **kwargs): + ''' + Args: + ext: An instance of the Verto Extension. + ''' + self.processor = 'blockquote' + super().__init__(self.processor, *args, **kwargs) + + def custom_parsing(self, content_blocks, argument_values): + ''' + Extracts the footer of a blockquote if provided. + + Args: + content_blocks (list): Strings to either be parsed or inserted + as content in template. + argument_values (dict): 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. + ''' + extra_args = {} + blocks = content_blocks + + argument = 'footer' + if argument_values.get(argument) == 'true': + footer_index = -2 + if content_blocks[footer_index].startswith(BLOCKQUOTE_FOOTER_PREFIX): + footer = content_blocks[footer_index] + footer = footer[len(BLOCKQUOTE_FOOTER_PREFIX):] + extra_args[argument] = footer + blocks = content_blocks[:footer_index] + else: + raise BlockquoteMissingFooterError(self.processor, argument) + elif argument_values.get(argument) == 'false': + # delete from argument dict so as to not be included in template + del argument_values[argument] + + return (blocks, extra_args) diff --git a/verto/tests/BlockquoteTest.py b/verto/tests/BlockquoteTest.py new file mode 100644 index 00000000..01d23a48 --- /dev/null +++ b/verto/tests/BlockquoteTest.py @@ -0,0 +1,291 @@ +import markdown +from unittest.mock import Mock + +from verto.VertoExtension import VertoExtension +from verto.processors.BlockquoteBlockProcessor import BlockquoteBlockProcessor +from verto.errors.TagNotMatchedError import TagNotMatchedError +from verto.errors.ArgumentMissingError import ArgumentMissingError +from verto.errors.ArgumentValueError import ArgumentValueError +from verto.errors.BlockquoteMissingFooterError import BlockquoteMissingFooterError +from verto.errors.StyleError import StyleError +from verto.tests.ProcessorTest import ProcessorTest + + +class BlockquoteTest(ProcessorTest): + '''The blockquote processor inherits from the generic container. + The tests contained here test that arguments and the output + (html-template) work as expected. + ''' + + def __init__(self, *args, **kwargs): + '''Sets up a generic container to test that the matches are + occuring appropriately and configure the asset directory. + ''' + ProcessorTest.__init__(self, *args, **kwargs) + self.processor_name = 'blockquote' + 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 = BlockquoteBlockProcessor(self.ext, Mock()) + + def test_no_footer(self): + '''Tests that a blockquote without a footer renders correctly. + ''' + test_string = self.read_test_file(self.processor_name, 'no_footer.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)) + + converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'no_footer_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + def test_footer(self): + '''Tests that a blockquote with a footer renders correctly. + ''' + test_string = self.read_test_file(self.processor_name, 'footer.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, 'footer_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + def test_footer_false(self): + '''Tests that a blockquote with footer argument set to false renders correctly. + ''' + test_string = self.read_test_file(self.processor_name, 'footer_false.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)) + + converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'footer_false_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + def test_footer_no_content(self): + '''Tests that a blockquote with a footer but no content raises an error renders correctly. + ''' + test_string = self.read_test_file(self.processor_name, 'footer_no_content.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(ArgumentValueError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) + + def test_footer_with_markdown_formatting(self): + '''Tests that a blockquote with a footer with Markdown formatting (bold and italics) renders correctly. + ''' + test_string = self.read_test_file(self.processor_name, 'footer_with_markdown_formatting.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, 'footer_with_markdown_formatting_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + def test_footer_with_link(self): + '''Tests that a blockquote with a footer with Markdown link renders correctly. + ''' + test_string = self.read_test_file(self.processor_name, 'footer_with_link.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, 'footer_with_link_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + def test_footer_with_multiple_dash_prefix(self): + '''Tests that a blockquote with a footer with multiple dashes prefix renders correctly. + ''' + test_string = self.read_test_file(self.processor_name, 'footer_with_multiple_dash_prefix.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, 'footer_with_multiple_dash_prefix_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + def test_footer_missing_content(self): + '''Tests that correct error raised when footer is missing renders correctly. + ''' + test_string = self.read_test_file(self.processor_name, 'footer_missing_content.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(BlockquoteMissingFooterError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) + + def test_footer_invalid_prefix(self): + '''Tests that correct error raised when footer prefix is invalid renders correctly. + ''' + test_string = self.read_test_file(self.processor_name, 'footer_invalid_prefix.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(BlockquoteMissingFooterError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) + + def test_parses_blank(self): + '''Tests that a blank blockquotes is processed with empty content. + ''' + 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.assertRaises(ArgumentValueError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) + + + def test_multiple_blockquotes(self): + '''Tests that multiple blockquotes are processed correctly. + ''' + test_string = self.read_test_file(self.processor_name, 'multiple_blockquotes.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, True, True, False, True, 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, 'multiple_blockquotes_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + def test_missing_start_tag(self): + '''Tests that a TagNotMatchedError is thrown when a start tag is missing. + ''' + test_string = self.read_test_file(self.processor_name, 'missing_start_tag.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([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_missing_end_tag(self): + '''Tests that a TagNotMatchedError is thrown when an end tag is missing. + ''' + test_string = self.read_test_file(self.processor_name, 'missing_end_tag.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, 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) + + def test_custom_arguments_source_true(self): + '''Tests to ensure that blockquote tag is rendered correctly when source argument is required. + ''' + custom_argument_rules = { + "blockquote": { + "source": True + } + } + verto_extension_custom_rules = VertoExtension( + processors=[self.processor_name], + custom_argument_rules=custom_argument_rules + ) + + test_string = self.read_test_file(self.processor_name, 'source_true.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)) + + converted_test_string = markdown.markdown(test_string, extensions=[verto_extension_custom_rules]) + expected_string = self.read_test_file(self.processor_name, 'source_true_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + def test_custom_arguments_source_true_missing_argument(self): + '''Tests to ensure that blockquote tag raises errors when source argument is required and not given. + ''' + custom_argument_rules = { + "blockquote": { + "source": True + } + } + verto_extension_custom_rules = VertoExtension( + processors=[self.processor_name], + custom_argument_rules=custom_argument_rules + ) + + test_string = self.read_test_file(self.processor_name, 'source_true_missing_argument.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(ArgumentMissingError, lambda x: markdown.markdown(x, extensions=[verto_extension_custom_rules]), test_string) + + def test_custom_arguments_alignment_true(self): + '''Tests to ensure that blockquote tag is rendered correctly when alignment argument is required. + ''' + custom_argument_rules = { + "blockquote": { + "alignment": True + } + } + verto_extension_custom_rules = VertoExtension( + processors=[self.processor_name], + custom_argument_rules=custom_argument_rules + ) + + test_string = self.read_test_file(self.processor_name, 'alignment_true.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)) + + converted_test_string = markdown.markdown(test_string, extensions=[verto_extension_custom_rules]) + expected_string = self.read_test_file(self.processor_name, 'alignment_true_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + def test_custom_arguments_alignment_true_missing_argument(self): + '''Tests to ensure that blockquote tag raises errors when alignment argument is required and not given. + ''' + custom_argument_rules = { + "blockquote": { + "alignment": True + } + } + verto_extension_custom_rules = VertoExtension( + processors=[self.processor_name], + custom_argument_rules=custom_argument_rules + ) + + test_string = self.read_test_file(self.processor_name, 'alignment_true_missing_argument.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(ArgumentMissingError, lambda x: markdown.markdown(x, extensions=[verto_extension_custom_rules]), test_string) + + # ~ + # Doc Tests + # ~ + + def test_doc_example_basic(self): + '''Example of the common usecase. + ''' + test_string = self.read_test_file(self.processor_name, 'doc_example_basic_usage.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, 'doc_example_basic_usage_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + def test_doc_example_override_html(self): + '''Example of overriding 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], [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}) + + 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) diff --git a/verto/tests/assets/blockquote/alignment_true.md b/verto/tests/assets/blockquote/alignment_true.md new file mode 100644 index 00000000..8ff32377 --- /dev/null +++ b/verto/tests/assets/blockquote/alignment_true.md @@ -0,0 +1,5 @@ +{blockquote alignment="right"} + +Blockquote contents. + +{blockquote end} diff --git a/verto/tests/assets/blockquote/alignment_true_expected.html b/verto/tests/assets/blockquote/alignment_true_expected.html new file mode 100644 index 00000000..bd3f0ff0 --- /dev/null +++ b/verto/tests/assets/blockquote/alignment_true_expected.html @@ -0,0 +1,3 @@ +
+

Blockquote contents.

+
diff --git a/verto/tests/assets/blockquote/alignment_true_missing_argument.md b/verto/tests/assets/blockquote/alignment_true_missing_argument.md new file mode 100644 index 00000000..947fe9ff --- /dev/null +++ b/verto/tests/assets/blockquote/alignment_true_missing_argument.md @@ -0,0 +1,5 @@ +{blockquote} + +Blockquote contents. + +{blockquote end} diff --git a/verto/tests/assets/blockquote/doc_example_basic_usage.md b/verto/tests/assets/blockquote/doc_example_basic_usage.md new file mode 100644 index 00000000..9d3d7c4f --- /dev/null +++ b/verto/tests/assets/blockquote/doc_example_basic_usage.md @@ -0,0 +1,7 @@ +{blockquote} + +This text is the blockquote's contents. + +This is the second line. + +{blockquote end} diff --git a/verto/tests/assets/blockquote/doc_example_basic_usage_expected.html b/verto/tests/assets/blockquote/doc_example_basic_usage_expected.html new file mode 100644 index 00000000..1661e6cc --- /dev/null +++ b/verto/tests/assets/blockquote/doc_example_basic_usage_expected.html @@ -0,0 +1,4 @@ +
+

This text is the blockquote's contents.

+

This is the second line.

+
diff --git a/verto/tests/assets/blockquote/doc_example_override_html.md b/verto/tests/assets/blockquote/doc_example_override_html.md new file mode 100644 index 00000000..8ff32377 --- /dev/null +++ b/verto/tests/assets/blockquote/doc_example_override_html.md @@ -0,0 +1,5 @@ +{blockquote alignment="right"} + +Blockquote contents. + +{blockquote end} diff --git a/verto/tests/assets/blockquote/doc_example_override_html_expected.html b/verto/tests/assets/blockquote/doc_example_override_html_expected.html new file mode 100644 index 00000000..5e200b2c --- /dev/null +++ b/verto/tests/assets/blockquote/doc_example_override_html_expected.html @@ -0,0 +1,3 @@ +
+

Blockquote contents.

+
diff --git a/verto/tests/assets/blockquote/doc_example_override_html_template.html b/verto/tests/assets/blockquote/doc_example_override_html_template.html new file mode 100644 index 00000000..5191866c --- /dev/null +++ b/verto/tests/assets/blockquote/doc_example_override_html_template.html @@ -0,0 +1,11 @@ +
+{% autoescape false -%} +{{ content }} +{%- endautoescape -%} +{% if footer %} +
+{{ footer }} +
+{% endif %} +
diff --git a/verto/tests/assets/blockquote/footer.md b/verto/tests/assets/blockquote/footer.md new file mode 100644 index 00000000..5977ec08 --- /dev/null +++ b/verto/tests/assets/blockquote/footer.md @@ -0,0 +1,7 @@ +{blockquote footer="true"} + +Blockquote contents. + +- This is the footer + +{blockquote end} diff --git a/verto/tests/assets/blockquote/footer_expected.html b/verto/tests/assets/blockquote/footer_expected.html new file mode 100644 index 00000000..953124e1 --- /dev/null +++ b/verto/tests/assets/blockquote/footer_expected.html @@ -0,0 +1,6 @@ +
+

Blockquote contents.

+
+This is the footer +
+
diff --git a/verto/tests/assets/blockquote/footer_false.md b/verto/tests/assets/blockquote/footer_false.md new file mode 100644 index 00000000..b0ecd0f4 --- /dev/null +++ b/verto/tests/assets/blockquote/footer_false.md @@ -0,0 +1,5 @@ +{blockquote footer="false"} + +Blockquote contents. + +{blockquote end} diff --git a/verto/tests/assets/blockquote/footer_false_expected.html b/verto/tests/assets/blockquote/footer_false_expected.html new file mode 100644 index 00000000..bb872925 --- /dev/null +++ b/verto/tests/assets/blockquote/footer_false_expected.html @@ -0,0 +1,3 @@ +
+

Blockquote contents.

+
diff --git a/verto/tests/assets/blockquote/footer_invalid_prefix.md b/verto/tests/assets/blockquote/footer_invalid_prefix.md new file mode 100644 index 00000000..6288c4b6 --- /dev/null +++ b/verto/tests/assets/blockquote/footer_invalid_prefix.md @@ -0,0 +1,7 @@ +{blockquote footer="true"} + +Blockquote contents. + +-- This is the footer + +{blockquote end} diff --git a/verto/tests/assets/blockquote/footer_missing_content.md b/verto/tests/assets/blockquote/footer_missing_content.md new file mode 100644 index 00000000..6c4b5bec --- /dev/null +++ b/verto/tests/assets/blockquote/footer_missing_content.md @@ -0,0 +1,5 @@ +{blockquote footer="true"} + +Blockquote contents. + +{blockquote end} diff --git a/verto/tests/assets/blockquote/footer_no_content.md b/verto/tests/assets/blockquote/footer_no_content.md new file mode 100644 index 00000000..9f56c70a --- /dev/null +++ b/verto/tests/assets/blockquote/footer_no_content.md @@ -0,0 +1,5 @@ +{blockquote footer="true"} + +- This is the footer + +{blockquote end} diff --git a/verto/tests/assets/blockquote/footer_with_link.md b/verto/tests/assets/blockquote/footer_with_link.md new file mode 100644 index 00000000..7440b2f9 --- /dev/null +++ b/verto/tests/assets/blockquote/footer_with_link.md @@ -0,0 +1,7 @@ +{blockquote footer="true"} + +Blockquote contents. + +- This is the [footer](https://www.example.com) + +{blockquote end} diff --git a/verto/tests/assets/blockquote/footer_with_link_expected.html b/verto/tests/assets/blockquote/footer_with_link_expected.html new file mode 100644 index 00000000..3f4444c4 --- /dev/null +++ b/verto/tests/assets/blockquote/footer_with_link_expected.html @@ -0,0 +1,6 @@ +
+

Blockquote contents.

+ +
diff --git a/verto/tests/assets/blockquote/footer_with_markdown_formatting.md b/verto/tests/assets/blockquote/footer_with_markdown_formatting.md new file mode 100644 index 00000000..e4714128 --- /dev/null +++ b/verto/tests/assets/blockquote/footer_with_markdown_formatting.md @@ -0,0 +1,7 @@ +{blockquote footer="true"} + +Blockquote contents. + +- This *is* the **footer** + +{blockquote end} diff --git a/verto/tests/assets/blockquote/footer_with_markdown_formatting_expected.html b/verto/tests/assets/blockquote/footer_with_markdown_formatting_expected.html new file mode 100644 index 00000000..d0cd351c --- /dev/null +++ b/verto/tests/assets/blockquote/footer_with_markdown_formatting_expected.html @@ -0,0 +1,6 @@ +
+

Blockquote contents.

+
+This is the footer +
+
diff --git a/verto/tests/assets/blockquote/footer_with_multiple_dash_prefix.md b/verto/tests/assets/blockquote/footer_with_multiple_dash_prefix.md new file mode 100644 index 00000000..aadcf17b --- /dev/null +++ b/verto/tests/assets/blockquote/footer_with_multiple_dash_prefix.md @@ -0,0 +1,7 @@ +{blockquote footer="true"} + +Blockquote contents. + +- - - This is the footer + +{blockquote end} diff --git a/verto/tests/assets/blockquote/footer_with_multiple_dash_prefix_expected.html b/verto/tests/assets/blockquote/footer_with_multiple_dash_prefix_expected.html new file mode 100644 index 00000000..fb309156 --- /dev/null +++ b/verto/tests/assets/blockquote/footer_with_multiple_dash_prefix_expected.html @@ -0,0 +1,6 @@ +
+

Blockquote contents.

+
+- - This is the footer +
+
diff --git a/verto/tests/assets/blockquote/missing_end_tag.md b/verto/tests/assets/blockquote/missing_end_tag.md new file mode 100644 index 00000000..7a8189ef --- /dev/null +++ b/verto/tests/assets/blockquote/missing_end_tag.md @@ -0,0 +1,5 @@ +{blockquote} + +This text is the blockquote's contents. + +This is the second line. diff --git a/verto/tests/assets/blockquote/missing_start_tag.md b/verto/tests/assets/blockquote/missing_start_tag.md new file mode 100644 index 00000000..1a2f9845 --- /dev/null +++ b/verto/tests/assets/blockquote/missing_start_tag.md @@ -0,0 +1,5 @@ +This text is the blockquote's contents. + +This is the second line. + +{blockquote end} diff --git a/verto/tests/assets/blockquote/multiple_blockquotes.md b/verto/tests/assets/blockquote/multiple_blockquotes.md new file mode 100644 index 00000000..27a8ac9d --- /dev/null +++ b/verto/tests/assets/blockquote/multiple_blockquotes.md @@ -0,0 +1,17 @@ +{blockquote} + +Blockquote 1 contents. + +{blockquote end} + +{blockquote} + +Blockquote 2 contents. + +{blockquote end} + +{blockquote} + +Blockquote 3 contents. + +{blockquote end} diff --git a/verto/tests/assets/blockquote/multiple_blockquotes_expected.html b/verto/tests/assets/blockquote/multiple_blockquotes_expected.html new file mode 100644 index 00000000..b65f7db6 --- /dev/null +++ b/verto/tests/assets/blockquote/multiple_blockquotes_expected.html @@ -0,0 +1,9 @@ +
+

Blockquote 1 contents.

+
+
+

Blockquote 2 contents.

+
+
+

Blockquote 3 contents.

+
diff --git a/verto/tests/assets/blockquote/no_footer.md b/verto/tests/assets/blockquote/no_footer.md new file mode 100644 index 00000000..947fe9ff --- /dev/null +++ b/verto/tests/assets/blockquote/no_footer.md @@ -0,0 +1,5 @@ +{blockquote} + +Blockquote contents. + +{blockquote end} diff --git a/verto/tests/assets/blockquote/no_footer_expected.html b/verto/tests/assets/blockquote/no_footer_expected.html new file mode 100644 index 00000000..bb872925 --- /dev/null +++ b/verto/tests/assets/blockquote/no_footer_expected.html @@ -0,0 +1,3 @@ +
+

Blockquote contents.

+
diff --git a/verto/tests/assets/blockquote/parses_blank.md b/verto/tests/assets/blockquote/parses_blank.md new file mode 100644 index 00000000..0648cf30 --- /dev/null +++ b/verto/tests/assets/blockquote/parses_blank.md @@ -0,0 +1,3 @@ +{blockquote} + +{blockquote end} diff --git a/verto/tests/assets/blockquote/source_true.md b/verto/tests/assets/blockquote/source_true.md new file mode 100644 index 00000000..6cf1328c --- /dev/null +++ b/verto/tests/assets/blockquote/source_true.md @@ -0,0 +1,5 @@ +{blockquote source="https://www.example.com"} + +Blockquote contents. + +{blockquote end} diff --git a/verto/tests/assets/blockquote/source_true_expected.html b/verto/tests/assets/blockquote/source_true_expected.html new file mode 100644 index 00000000..cb9c5ddf --- /dev/null +++ b/verto/tests/assets/blockquote/source_true_expected.html @@ -0,0 +1,3 @@ +
+

Blockquote contents.

+
diff --git a/verto/tests/assets/blockquote/source_true_missing_argument.md b/verto/tests/assets/blockquote/source_true_missing_argument.md new file mode 100644 index 00000000..947fe9ff --- /dev/null +++ b/verto/tests/assets/blockquote/source_true_missing_argument.md @@ -0,0 +1,5 @@ +{blockquote} + +Blockquote contents. + +{blockquote end} diff --git a/verto/tests/start_tests.py b/verto/tests/start_tests.py index 40645002..9f8374e0 100644 --- a/verto/tests/start_tests.py +++ b/verto/tests/start_tests.py @@ -3,6 +3,7 @@ import optparse from verto.tests.ConfigurationTest import ConfigurationTest from verto.tests.SmokeTests import SmokeFileTest, SmokeDocsTest +from verto.tests.BlockquoteTest import BlockquoteTest from verto.tests.BoxedTextTest import BoxedTextTest from verto.tests.ButtonLinkTest import ButtonLinkTest from verto.tests.CommentTest import CommentTest @@ -86,6 +87,7 @@ def unit_suite(): '''Builds unittests. (Not really unittests). ''' return unittest.TestSuite(( + unittest.makeSuite(BlockquoteTest), unittest.makeSuite(BoxedTextTest), unittest.makeSuite(ButtonLinkTest), unittest.makeSuite(CommentTest),