Skip to content

Commit

Permalink
Merge branch 'release-0.5.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenjackson01 committed May 6, 2017
2 parents 6ac4003 + 29b643d commit b87e414
Show file tree
Hide file tree
Showing 193 changed files with 1,222 additions and 2,465 deletions.
10 changes: 10 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changelog
#######################################

0.5.3
=======================================

In this hotfix Verto result data for unique identifiers and required files is now only cleared when explicitly told. Result data that is per document such as title and heading tree are cleared per conversion.

Fixes:

- Remove implicit Beautify processor, fixing white-spacing issues.
- All terms are added to glossary correctly now.

0.5.2
=======================================

Expand Down
31 changes: 0 additions & 31 deletions docs/source/processors/beautify.rst

This file was deleted.

1 change: 0 additions & 1 deletion docs/source/processors/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ The following pages cover processors that do not require explicit use when autho
.. toctree::
:maxdepth: 1

beautify
jinja
orderedlist
remove
Expand Down
19 changes: 18 additions & 1 deletion docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ The following attributes are available:
[]
}
(Optional) Step 5: Clearing Saved Data
=======================================

Lastly there is some data that is saved between conversions such as ``required_files`` and unique ids used in the ``glossary`` and for ``headings``. This can be cleared by using the following method:

.. code-block:: python
converter.clear_saved_data()
Configuring Verto converter after creation
===============================================

Expand Down Expand Up @@ -155,7 +164,7 @@ Full list of package methods
=======================================

.. autoclass:: verto.Verto()
:members: __init__, convert, update_processors, processor_defaults, update_templates, clear_templates
:members: __init__, convert, update_processors, processor_defaults, update_templates, clear_templates, clear_saved_data

.. autoclass:: verto.Verto.VertoResult()

Expand All @@ -170,3 +179,11 @@ Full list of package methods
.. attribute:: required_files

A dictionary of files encountered in a Verto conversion. The dictionary has a string for the file type as the key (for example: ``image``) and a set of all file paths encountered as the value (for example: ``{'image/face.png', 'image/logo.png`}``).

.. attribute:: heading_tree

A tuple of namedtuples which describes the tree of headings, as generated by our heading processor. Each namedtuple contains a title (string), title_slug (string), level (integer) and children (tuple of nodes).

.. attribute:: required_glossary_terms

A dictionary of terms to a list of tuples containing reference text and link IDs.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
markdown==2.6.8
beautifulsoup4==4.5.3
Jinja2==2.9.6
python-slugify==1.2.3
python-slugify==1.2.4
setuptools==35.0.2

# Required dependencies for building documentation
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
include_package_data=True,
install_requires=[
'markdown>=2.6.8',
'beautifulsoup4==4.5.3',
'beautifulsoup4>=4.5.3',
'Jinja2>=2.9.6',
'python-slugify>=1.2.2'
'python-slugify>=1.2.4'
]
)
8 changes: 7 additions & 1 deletion verto/Verto.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def convert(self, text):
Returns:
A VertoResult object.
'''
self.verto_extension.clear_saved_data()
self.verto_extension.clear_document_data()
html_string = self.converter.convert(text)
result = VertoResult(
html_string=html_string,
Expand All @@ -77,6 +77,12 @@ def convert(self, text):
)
return result

def clear_saved_data(self):
'''Clears data that is saved between documents. This should be
called between conversions on unrelated documents.
'''
self.verto_extension.clear_saved_data()

def update_templates(self, html_templates):
'''Update the template dictionary with the given dictionary
of templates, while leaving all other HTML templates (including
Expand Down
20 changes: 11 additions & 9 deletions verto/VertoExtension.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from verto.processors.RemoveTitlePreprocessor import RemoveTitlePreprocessor
from verto.processors.SaveTitlePreprocessor import SaveTitlePreprocessor
from verto.processors.GlossaryLinkPattern import GlossaryLinkPattern
from verto.processors.BeautifyPostprocessor import BeautifyPostprocessor
from verto.processors.ConditionalProcessor import ConditionalProcessor
from verto.processors.StylePreprocessor import StylePreprocessor
from verto.processors.RemovePostprocessor import RemovePostprocessor
Expand Down Expand Up @@ -57,15 +56,14 @@ def __init__(self, processors=[], html_templates={}, extensions=[], *args, **kwa
extensions: A list of extra extensions for compatibility.
'''
super().__init__(*args, **kwargs)
self.required_files = defaultdict(set)
self.title = None
self.jinja_templates = self.loadJinjaTemplates(html_templates)
self.processor_info = self.loadProcessorInfo()
self.processors = processors
self.title = None
self.heading_tree = None
self.custom_slugify = UniqueSlugify()
self.glossary_terms = defaultdict(list)
self.heading_tree = None

self.required_files = defaultdict(set)
self.compatibility = []
for extension in extensions:
if isinstance(extension, utils.string_type):
Expand Down Expand Up @@ -98,7 +96,6 @@ def update_processors(processors, markdown_processors):

md.preprocessors.add('style', StylePreprocessor(self, md), '_begin')
md.postprocessors.add('remove', RemovePostprocessor(md), '_end')
md.postprocessors.add('beautify', BeautifyPostprocessor(md), '_end')
md.postprocessors.add('jinja', JinjaPostprocessor(md), '_end')

# Compatibility modules
Expand All @@ -116,13 +113,18 @@ def update_processors(processors, markdown_processors):
processor = ScratchCompatibilityPreprocessor(self, md)
md.preprocessors.add('scratch-compatibility', processor, '<fenced_code_block')

def clear_document_data(self):
'''Clears information stored for a specific document.
'''
self.title = None
self.heading_tree = None

def clear_saved_data(self):
'''Clears stored information from processors, should be called
between runs.
between runs on unrelated documents.
'''
self.title = None
self.custom_slugify.clear()
self.heading_tree = None
self.glossary_terms.clear()
for key in self.required_files.keys():
self.required_files[key].clear()

Expand Down
2 changes: 1 addition & 1 deletion verto/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# flake8: noqa
from .Verto import Verto

__version__ = '0.5.2'
__version__ = '0.5.3'
2 changes: 1 addition & 1 deletion verto/html-templates/boxed-text.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class='boxed-text{% if indented %} boxed-text-indented{% endif %}'>
{% autoescape false -%}
{{ text }}
{%- endautoescape %}
{% endautoescape -%}
</div>
4 changes: 1 addition & 3 deletions verto/html-templates/glossary-link.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<a class="glossary-term"
data-glossary-term="{{ term }}"
{% if id %} id="{{ id }}" {% endif %}>
{{ text }}
</a>
{% if id %} id="{{ id }}" {% endif %}>{{ text }}</a>
44 changes: 22 additions & 22 deletions verto/html-templates/heading.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<{{ heading_type }} id="{{ title_slug }}">
<span class="section_number">
{% if heading_level >= 1 -%}
{{ "{{ chapter.number }}" }}
{%- endif -%}
{%- if heading_level >= 2 -%}
.{{ level_2 }}
{%- endif -%}
{%- if heading_level >= 3 -%}
.{{ level_3 }}
{%- endif -%}
{%- if heading_level >= 4 -%}
.{{ level_4 }}
{%- endif -%}
{%- if heading_level >= 5 -%}
.{{ level_5 }}
{%- endif -%}
{%- if heading_level >= 6 -%}
.{{ level_6 }}
{%- endif -%}
.
</span>
{{ title }}
<span class="section_number">
{% if heading_level >= 1 -%}
{{ "{{ chapter.number }}" }}
{%- endif -%}
{%- if heading_level >= 2 -%}
.{{ level_2 }}
{%- endif -%}
{%- if heading_level >= 3 -%}
.{{ level_3 }}
{%- endif -%}
{%- if heading_level >= 4 -%}
.{{ level_4 }}
{%- endif -%}
{%- if heading_level >= 5 -%}
.{{ level_5 }}
{%- endif -%}
{%- if heading_level >= 6 -%}
.{{ level_6 }}
{%- endif -%}
.
</span>
{{ title }}
</{{ heading_type }}>
4 changes: 1 addition & 3 deletions verto/html-templates/iframe.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<iframe src="{{ link }}">
<p>
Your browser does not support iframes.
</p>
<p>Your browser does not support iframes.</p>
</iframe>
24 changes: 12 additions & 12 deletions verto/html-templates/image.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<div>
<img src="{{ file_path }}"
{% 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 -%}
<p><a href="{{ caption_link }}">{{ caption }}</a></p>
{%- elif caption -%}
<p>{{ caption }}</p>
{%- endif -%}
{%- if source_link -%}
<p><a href="{{ source_link }}">Source</a></p>
{%- endif -%}
<img src="{{ file_path }}"
{% 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 -%}
<p><a href="{{ caption_link }}">{{ caption }}</a></p>
{%- elif caption -%}
<p>{{ caption }}</p>
{%- endif -%}
{%- if source_link -%}
<p><a href="{{ source_link }}">Source</a></p>
{%- endif -%}
</div>
36 changes: 18 additions & 18 deletions verto/html-templates/interactive.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{%- if type == 'in-page' -%}
<remove>
{{ "{% include 'interactive/" }}{{ name }}{{ "/index.html' %}" }}
</remove>
<remove>
{{ "{% include 'interactive/" }}{{ name }}{{ "/index.html' %}" }}
</remove>
{% elif type == 'iframe' -%}
<iframe src="{{ "{% url 'interactive' name='" }}{{ name }}{{ "' %}" }}{% if parameters %}?{{ parameters }}{% endif %}">
<p>Your browser does not support iframes.</p>
</iframe>
<iframe src="{{ "{% url 'interactive' name='" }}{{ name }}{{ "' %}" }}{% if parameters %}?{{ parameters }}{% endif %}">
<p>Your browser does not support iframes.</p>
</iframe>
{% elif type == 'whole-page' -%}
<a
href="{{ "{% url 'interactive' name='" }}{{ name }}{{ "' %}" }}{% if parameters %}?{{ parameters }}{% endif %}"
class="btn btn-interactive-link">
<img class="btn-interactive-link-image" src="{{ file_path }}"/>
<div class="btn-interactive-whole-page-text">
{% if text -%}
{{ text }}
{% else -%}
Click to load {{ name }}
{% endif -%}
</div>
</a>
<a
href="{{ "{% url 'interactive' name='" }}{{ name }}{{ "' %}" }}{% if parameters %}?{{ parameters }}{% endif %}"
class="btn btn-interactive-link">
<img class="btn-interactive-link-image" src="{{ file_path }}"/>
<div class="btn-interactive-whole-page-text">
{% if text -%}
{{ text }}
{% else -%}
Click to load {{ name }}
{% endif -%}
</div>
</a>
{%- endif -%}
16 changes: 8 additions & 8 deletions verto/html-templates/panel.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<div class='panel panel-{{ type }}{% if expanded == 'always'%} panel-expanded-always{% elif expanded == 'true' %} panel-expanded{% endif %}'>
<div class='panel-header'>
<strong>{{ title }}{% if subtitle %}:</strong> {{ subtitle }}{% else %}</strong>{% endif %}
</div>
<div class='panel-body'>
{% autoescape false -%}
{{ content }}
{%- endautoescape %}
</div>
<div class='panel-header'>
<strong>{{ title }}{% if subtitle %}:</strong> {{ subtitle }}{% else %}</strong>{% endif %}
</div>
<div class='panel-body'>
{% autoescape false -%}
{{ content }}
{% endautoescape -%}
</div>
</div>
4 changes: 1 addition & 3 deletions verto/html-templates/relative-link.html
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
<a href='{{ "{{ base_path }}" }}{{ link_path }}'>
{{ text }}
</a>
<a href='{{ "{{ base_path }}" }}{{ link_path }}'>{{ text }}</a>
8 changes: 4 additions & 4 deletions verto/html-templates/scratch.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="scratch-inline-images">
{% for hash in images -%}
<object type="image/svg+xml" data="{% autoescape false -%}{{ "{% static '" }}scratch-blocks-{{ hash }}.svg{{ "' %}" }}{%- endautoescape %}">
</object>
{% endfor -%}
{% for hash in images -%}
<object type="image/svg+xml" data="{% autoescape false -%}{{ "{% static '" }}scratch-blocks-{{ hash }}.svg{{ "' %}" }}{%- endautoescape %}">
</object>
{% endfor -%}
</div>
2 changes: 1 addition & 1 deletion verto/html-templates/table-of-contents.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<remove>
{{ "{{ table_of_contents }}" }}
{{ "{{ table_of_contents }}" }}
</remove>
2 changes: 1 addition & 1 deletion verto/html-templates/video.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div>
<iframe allowfullscreen='allowfullscreen' frameborder='0' src='{{ video_url }}'></iframe>
<iframe allowfullscreen='allowfullscreen' frameborder='0' src='{{ video_url }}'></iframe>
</div>
Loading

0 comments on commit b87e414

Please sign in to comment.