Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix the smartquotes API change on entry.title
  • Loading branch information
fluffy-critter committed Dec 31, 2019
1 parent 0e14b53 commit 004fb47
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions publ/entry.py
Expand Up @@ -249,11 +249,12 @@ def title(self) -> typing.Callable[..., str]:
always_show -- always show the title even if the current user is not
authorized to see the entry
"""
def _title(markup=True, no_smartquotes=False, markdown_extensions=None,
always_show=False) -> str:
def _title(markup=True, markdown_extensions=None,
always_show=False, **kwargs) -> str:
if not always_show and not self.authorized:
return ''
return markdown.render_title(self._record.title, markup, no_smartquotes,
smartquotes = kwargs.get('smartquotes', not kwargs.get('no_smartquotes', False))
return markdown.render_title(self._record.title, markup, smartquotes,
markdown_extensions)
return CallableProxy(_title)

Expand Down
4 changes: 2 additions & 2 deletions publ/markdown.py
Expand Up @@ -284,7 +284,7 @@ def header(content, level):
return content


def render_title(text, markup=True, no_smartquotes=False, markdown_extensions=None):
def render_title(text, markup=True, smartquotes=True, markdown_extensions=None):
""" Convert a Markdown title to HTML """

# If the title starts with something that looks like a list, save it for
Expand All @@ -298,7 +298,7 @@ def render_title(text, markup=True, no_smartquotes=False, markdown_extensions=No
if not markup:
text = html_entry.strip_html(text)

if not no_smartquotes:
if smartquotes:
text = misaka.smartypants(text)

return flask.Markup(text)
2 changes: 1 addition & 1 deletion tests/templates/entity-titles/index.html
Expand Up @@ -2,5 +2,5 @@

{% block entry %}
{{super()}}
{{image('button.png').get_img_tag(title=entry.title(markup=False),alt_text=entry.title,width=16,link=entry.link)}}
{{image('button.png').get_img_tag(title=entry.title(markup=False),alt_text=entry.title|forceescape,width=16,link=entry.link)}}
{% endblock %}

0 comments on commit 004fb47

Please sign in to comment.