Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Gracefully handle case with no title #81

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/specimen.rst
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,8 @@ Right Alignment
:alt: Right Image, 60% scale
:scale: 60%
:align: right


Links
-----
This is a link to a page with no title: :ref:`No Title`.
3 changes: 2 additions & 1 deletion sphinx_material/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Sphinx Material theme."""

import hashlib
import html
import inspect
import os
import re
Expand Down Expand Up @@ -301,4 +302,4 @@ def __new__(cls, *args, **kwargs):


def get_html_context():
return {"table_fix": TableFix, "derender_toc": DerenderToc}
return {"table_fix": TableFix, "derender_toc": DerenderToc, "unescape": html.unescape}
9 changes: 8 additions & 1 deletion sphinx_material/sphinx_material/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@
{% if theme_touch_icon %}
<link rel="apple-touch-icon" href="{{ pathto('_static/' ~ theme_touch_icon, 1) }}"/>
{% endif %}
{{ super() }}
<title>
{% if "no title" in title or not title.strip() %}
{% set ts = unescape(titlesuffix).strip()[1:].strip() %}
{{ ts|e }}
{% else %}
{{ title|striptags|e }}{{ titlesuffix }}
{% endif %}
</title>
{%- endblock %}

{%- block extrahead %}
Expand Down