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
I am trying to reproduce a mkdocs site with Jupyter Book, and one thing I am stuck on is linking to the glossary within code outputs. The site includes many tables and text sections that are generated with Python functions and converted to Markdown.
I initially had trouble making code-generated Markdown tables render correctly, but I got around that with the following:
from IPython.display import display, HTML
from markdown import markdown
# table is a pandas DataFrame
display(HTML(markdown(table.to_markdown(), extensions=['tables'])))
The table looks good, but terms within the table end up being converted to HTML.
For example, {term}`Manufacturer (metadata)` becomes:
I got around this by writing a function that replaces the <code> tag with backticks in the HTML string, before it's displayed.
Now, I get the literal string, rather than the linked glossary term:
TLDR: Is there any way to include terms that will link to the glossary in code outputs (especially Markdown strings and tables)? Is there a more straightforward solution that I am missing?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to reproduce a
mkdocs
site with Jupyter Book, and one thing I am stuck on is linking to the glossary within code outputs. The site includes many tables and text sections that are generated with Python functions and converted to Markdown.I initially had trouble making code-generated Markdown tables render correctly, but I got around that with the following:
The table looks good, but terms within the table end up being converted to HTML.
For example,

{term}`Manufacturer (metadata)`
becomes:I got around this by writing a function that replaces the
<code>
tag with backticks in the HTML string, before it's displayed.Now, I get the literal string, rather than the linked glossary term:
The repository I am working on is
bids-standard/bids-specification-ignore
.TLDR: Is there any way to include terms that will link to the glossary in code outputs (especially Markdown strings and tables)? Is there a more straightforward solution that I am missing?
Beta Was this translation helpful? Give feedback.
All reactions