diff options
| author | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2017-02-03 14:44:16 +0000 |
|---|---|---|
| committer | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2017-02-03 14:44:16 +0000 |
| commit | 3c6e08975a52ff1930cd87efc092b0a20e1ec61a (patch) | |
| tree | f616e186f5f3de9c167fc9b002d5db750a702232 /docutils | |
| parent | 68318b639012561b2fac99f5325d3a5055013b1a (diff) | |
| download | docutils-3c6e08975a52ff1930cd87efc092b0a20e1ec61a.tar.gz | |
Provide default title in metadata.
In HTML5, <title> is a required child of the <head> element
and it must not be empty (found with https://validator.w3.org/check)
If there is no given title, we use the source file name as default and
fall back to "docutils document without title" if there is no source file.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8021 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils')
| -rw-r--r-- | docutils/HISTORY.txt | 10 | ||||
| -rw-r--r-- | docutils/docutils/writers/_html_base.py | 5 |
2 files changed, 10 insertions, 5 deletions
diff --git a/docutils/HISTORY.txt b/docutils/HISTORY.txt index c93345207..8d6ef3198 100644 --- a/docutils/HISTORY.txt +++ b/docutils/HISTORY.txt @@ -38,13 +38,17 @@ Changes Since 0.13.1 - Added ``split_escaped_whitespace`` function, support for escaped whitespace in URI contexts. -* docutils/utils/smartquotes.py: +* docutils/utils/smartquotes.py: - Update quote definitions for languages et, fi, ro, sv, tr, uk. - New quote definitions for hr, hsb, hu, lv, sl. - + +* docutils/writers/_html_base.py + + - Provide default title in metadata (required by HTML5). + * tools/rst2html4.py: New front-end. - + * tools/dev/generate_punctuation_chars.py: New skript to test and update utils.punctuation_chars. diff --git a/docutils/docutils/writers/_html_base.py b/docutils/docutils/writers/_html_base.py index 18a8fc04e..ac5a07458 100644 --- a/docutils/docutils/writers/_html_base.py +++ b/docutils/docutils/writers/_html_base.py @@ -691,8 +691,9 @@ class HTMLTranslator(nodes.NodeVisitor): self.body.append('\n</pre>\n') def visit_document(self, node): - self.head.append('<title>%s</title>\n' - % self.encode(node.get('title', ''))) + title = (node.get('title', '') or os.path.basename(node['source']) + or 'docutils document without title') + self.head.append('<title>%s</title>\n' % self.encode(title)) def depart_document(self, node): self.head_prefix.extend([self.doctype, |
