You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def setup(app):
"""Setup."""
# Hook the events.
print("app_connect")
app.connect('html-page-context', hpc)
def tt2nav(toctree, klass=None, appendix=None, divider=False):
"""
Injects ``has-dropdown`` and ``dropdown`` classes to HTML
generated by the :func:`toctree` function.
:param str toctree:
HTML generated by the :func:`toctree` function.
"""
tt = toctree
divider = '<li class="divider"></li>' if divider else ''
# Append anything just before the closing </ul>.
if appendix:
tt = re.sub(r'(</ul>$)', r'{}\1'.format(appendix), tt)
# Add class attribute to all <ul> elements.
tt = re.sub(r'<ul>', r'<ul class="">', tt)
# Add class to first <ul> tag.
if klass:
tt = re.sub(r'(^<ul[\s\w-]+class=")', r'\1{} '.format(klass), tt)
# Add class "active" to all <li> tags with "current" class.
# tt = re.sub(r'(<li[\s\w-]+class="[^"]*current)([^"]*")', r'\1 active\2', tt)
# Match each <li> that contains <ul>.
pattern = r'(<li[\s\w-]+class=")([^>]*>[^<]*<a[^>]*>[^<]*</a>[^<]*<ul[\s\w]+class=")'
# Inject the classes.
replace = r'{}\1has-dropdown \2dropdown '.format(divider)
# Do the replace and return.
return re.sub(pattern, replace, tt)
def hpc(app, pagename, templatename, context, doctree):
# Add the tt2nav() callable to Jinja2 template context.
context['tt2nav'] = tt2nav
I would appreciate it if you could give me some advice.
Dear Developers,
I wonder someone has succeeded in realizing this.
I have been trying to modifying dropdown lists (in navbar.html in _templates directory), but not succeeded yet.
in navbar.html
in conf.py
I would appreciate it if you could give me some advice.
Best regards.
Originally posted by @kousuke-nakano in #106 (comment)
The text was updated successfully, but these errors were encountered: