mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Closes #3160: Use <kbd> tag for :kbd: role in html writers
This commit is contained in:
parent
215be8e5bd
commit
831f89a687
1
CHANGES
1
CHANGES
@ -73,6 +73,7 @@ Features removed
|
||||
Bugs fixed
|
||||
----------
|
||||
|
||||
* #3160: Why doesn't Sphinx translate :kbd: roles to HTML's <kbd> tags?
|
||||
* #3882: Update the order of files for HTMLHelp and QTHelp
|
||||
* #3962: sphinx-apidoc does not recognize implicit namespace packages correctly
|
||||
|
||||
|
@ -491,14 +491,21 @@ class HTMLTranslator(BaseTranslator):
|
||||
# overwritten
|
||||
def visit_literal(self, node):
|
||||
# type: (nodes.Node) -> None
|
||||
self.body.append(self.starttag(node, 'code', '',
|
||||
CLASS='docutils literal'))
|
||||
self.protect_literal_text += 1
|
||||
if 'kbd' in node['classes']:
|
||||
self.body.append(self.starttag(node, 'kbd', '',
|
||||
CLASS='docutils literal'))
|
||||
else:
|
||||
self.body.append(self.starttag(node, 'code', '',
|
||||
CLASS='docutils literal'))
|
||||
self.protect_literal_text += 1
|
||||
|
||||
def depart_literal(self, node):
|
||||
# type: (nodes.Node) -> None
|
||||
self.protect_literal_text -= 1
|
||||
self.body.append('</code>')
|
||||
if 'kbd' in node['classes']:
|
||||
self.body.append('</kbd>')
|
||||
else:
|
||||
self.protect_literal_text -= 1
|
||||
self.body.append('</code>')
|
||||
|
||||
def visit_productionlist(self, node):
|
||||
# type: (nodes.Node) -> None
|
||||
|
@ -437,14 +437,21 @@ class HTML5Translator(BaseTranslator):
|
||||
# overwritten
|
||||
def visit_literal(self, node):
|
||||
# type: (nodes.Node) -> None
|
||||
self.body.append(self.starttag(node, 'code', '',
|
||||
CLASS='docutils literal'))
|
||||
self.protect_literal_text += 1
|
||||
if 'kbd' in node['classes']:
|
||||
self.body.append(self.starttag(node, 'kbd', '',
|
||||
CLASS='docutils literal'))
|
||||
else:
|
||||
self.body.append(self.starttag(node, 'code', '',
|
||||
CLASS='docutils literal'))
|
||||
self.protect_literal_text += 1
|
||||
|
||||
def depart_literal(self, node):
|
||||
# type: (nodes.Node) -> None
|
||||
self.protect_literal_text -= 1
|
||||
self.body.append('</code>')
|
||||
if 'kbd' in node['classes']:
|
||||
self.body.append('</kbd>')
|
||||
else:
|
||||
self.protect_literal_text -= 1
|
||||
self.body.append('</code>')
|
||||
|
||||
def visit_productionlist(self, node):
|
||||
# type: (nodes.Node) -> None
|
||||
|
@ -238,7 +238,7 @@ def test_static_output(app):
|
||||
(".//li/strong", r'^command\\n$'),
|
||||
(".//li/strong", r'^program\\n$'),
|
||||
(".//li/em", r'^dfn\\n$'),
|
||||
(".//li/code/span[@class='pre']", r'^kbd\\n$'),
|
||||
(".//li/kbd", r'^kbd\\n$'),
|
||||
(".//li/span", u'File \N{TRIANGULAR BULLET} Close'),
|
||||
(".//li/code/span[@class='pre']", '^a/$'),
|
||||
(".//li/code/em/span[@class='pre']", '^varpart$'),
|
||||
|
@ -119,7 +119,7 @@ def cached_etree_parse():
|
||||
(".//li/p/strong", r'^command\\n$'),
|
||||
(".//li/p/strong", r'^program\\n$'),
|
||||
(".//li/p/em", r'^dfn\\n$'),
|
||||
(".//li/p/code/span[@class='pre']", r'^kbd\\n$'),
|
||||
(".//li/p/kbd", r'^kbd\\n$'),
|
||||
(".//li/p/span", u'File \N{TRIANGULAR BULLET} Close'),
|
||||
(".//li/p/code/span[@class='pre']", '^a/$'),
|
||||
(".//li/p/code/em/span[@class='pre']", '^varpart$'),
|
||||
|
Loading…
Reference in New Issue
Block a user