Steps for custom role in Jupyter Book? #101
-
I have a custom role, in fact called It works fine in a tiny sphinx project, producing the rendered paragraph text. However, when I use it in some Markdown in JupyterBook, the role does not get parsed, so the input text remains unaltered in the rendered source:
Standard Sphinx roles such as I am importing the role in
in the same form as I'm using in a standalone
Am I doing this correctly? Any ideas how I could debug why it is not being correctly parsed / rendered? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 6 replies
-
Heya, so is there then a warning shown that the |
Beta Was this translation helpful? Give feedback.
-
There's nothing in the stdout / stderr from |
Beta Was this translation helpful? Give feedback.
-
can you provide a minimum book repo that recreates the problem? It's weird that the setup function is called but the role code isn't being called! |
Beta Was this translation helpful? Give feedback.
-
So, I think this might be a myst parser thing as opposed to a jupyter book thing. In your mini Sphinx site, if I activate {math}`a = b + c`
{data8page}`some text`
{blah}`foo` then I see this output: The rST, this: :math:`a = b + c`
:data8page:`some text`
:blah:`foo` yields this: Note that none of this is jupyter book, just raw sphinx, and note that the |
Beta Was this translation helpful? Give feedback.
-
Interesting. I see that, in this repo, if I put at |
Beta Was this translation helpful? Give feedback.
-
further sleuthing that I suspect @chrisjsewell has figured out as well (see below) if I do: def setup(app):
# Add runrole roles
app.add_role('datapage', data8pagerole)
app.add_role('data8page', data8pagerole) and add this to a page {data8page}`some text`
{datapage}`some text` then the I further suspect this because I see @chrisjsewell just opened up executablebooks/markdown-it-py#34 which adds numbers to the regex in the role search :-) |
Beta Was this translation helpful? Give feedback.
-
"How to use roles and directives" executablebooks/MyST-NB#239
|
Beta Was this translation helpful? Give feedback.
further sleuthing that I suspect @chrisjsewell has figured out as well (see below)
if I do:
and add this to a page
then the
datapage
one shows up as expected and thedata8page
does not. So I suspect that this is something about there being a number in your role name.I further suspect this because I see @chrisjsewell just opened up executablebooks/markdown-it-py#34 which adds numbers to the regex in the role search :-)