-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
700 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[run] | ||
branch = True | ||
source = | ||
verto | ||
omit = | ||
# Omit test files | ||
*/tests/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# flake8: noqa | ||
from .Verto import Verto | ||
|
||
__version__ = '0.8.0' | ||
__version__ = '0.9.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from verto.errors.Error import Error | ||
|
||
|
||
class BlockquoteMissingFooterError(Error): | ||
'''Exception raised when a blockquote is missing a footer when argument is given. | ||
Attributes: | ||
tag: tag which was not matched | ||
block: block where tag was not matched | ||
argument: the argument that was not found | ||
''' | ||
|
||
def __init__(self, tag, argument): | ||
self.tag = tag | ||
self.argument = argument | ||
self.message = '\'footer\' is \'true\' but not supplied.' | ||
super().__init__(self.message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<blockquote class="blockquote{% if alignment == 'left' %} text-left{% elif alignment =='center' %} text-center{% elif alignment =='right' %} text-right{% endif %}" | ||
{%- if source %} cite="{{ source }}"{% endif %}> | ||
{% autoescape false -%} | ||
{{ content }} | ||
{%- endautoescape -%} | ||
{% if footer %} | ||
<footer class="blockquote-footer"> | ||
{{ footer }} | ||
</footer> | ||
{% endif %} | ||
</blockquote> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
Oops, something went wrong.