Hello,
I wrote a simple extension to include a html tag for a role I wanted.
Could you please tell me how I can customize this role for latex build vs
html build?
# Tufte style side note for Sphinx
from docutils import nodes
import string
def sideNote_html(tagName,message):
return '<label for="sn-{0}" class="margin-toggle
sidenote-number"></label><\
/span><input type="checkbox" id="sn-{0}" class="margin-toggle"/><span
class="si\
denote">{1}</span>'.format(tagName, message)
def sidenote_role(typ, rawtext, text, lineno, inliner, options={},
content=[]):
"""
Role to include Tufte style side note
"""
text = text.decode('utf-8').encode('utf-8')
# Handle sidenotes of the form "<tagName> SideNoteMessage"
if '<' in text and '>' in text:
tagName, sideNoteMessage = text.split('>')
tagName = tagName.split('<')[1]
else:
tagName=''
sideNoteMessage=''
sideNoteHTML = sideNote_html(tagName, sideNoteMessage)
node = nodes.raw('', sideNoteHTML, format='html')
return [node], []
def setup(app):
app.add_role('sidenote', sidenote_role)
ganesh
--
You received this message because you are subscribed to the Google Groups
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/d/optout.