mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Don't add attributes to node.
This commit is contained in:
@@ -19,6 +19,7 @@ class WebSupportTranslator(HTMLTranslator):
|
||||
|
||||
def __init__(self, builder, *args, **kwargs):
|
||||
HTMLTranslator.__init__(self, builder, *args, **kwargs)
|
||||
self.comment_class = 'spxcmt'
|
||||
self.init_support()
|
||||
|
||||
def init_support(self):
|
||||
@@ -38,23 +39,21 @@ class WebSupportTranslator(HTMLTranslator):
|
||||
def handle_visit_commentable(self, node):
|
||||
# If this node is nested inside another commentable node this
|
||||
# node will not be commented.
|
||||
if self.in_commentable:
|
||||
node.commented = False
|
||||
else:
|
||||
node.commented = self.in_commentable = True
|
||||
node.id = self.create_id(node)
|
||||
if not self.in_commentable:
|
||||
self.in_commentable = True
|
||||
id = self.create_id(node)
|
||||
# We will place the node in the HTML id attribute. If the node
|
||||
# already has another id (for indexing purposes) put an empty
|
||||
# span with the existing id directly before this node's HTML.
|
||||
if node.attributes['ids']:
|
||||
self.body.append('<span id="%s"></span>'
|
||||
% node.attributes['ids'][0])
|
||||
node.attributes['ids'] = [node.id]
|
||||
node.attributes['classes'].append('spxcmt')
|
||||
node.attributes['ids'] = [id]
|
||||
node.attributes['classes'].append(self.comment_class)
|
||||
|
||||
def handle_depart_commentable(self, node):
|
||||
assert(self.in_commentable)
|
||||
if node.commented:
|
||||
if self.comment_class in node.attributes['classes']:
|
||||
self.in_commentable = False
|
||||
|
||||
def create_id(self, node):
|
||||
|
||||
Reference in New Issue
Block a user