New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Add inline syntax highlighting using docutils :code: role #6916
Conversation
Codecov Report
@@ Coverage Diff @@
## master #6916 +/- ##
==========================================
- Coverage 84.59% 84.58% -0.02%
==========================================
Files 266 266
Lines 41250 41263 +13
Branches 5963 5967 +4
==========================================
+ Hits 34897 34903 +6
- Misses 5034 5038 +4
- Partials 1319 1322 +3
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this implementation. Let's go with this! I'm waiting for update :-)
I'll also check this. It would be nice if both are same.
AFAIK, there are no way to disable it for code-blocks. So I feel it is not needed. |
You are correct that there is no option to disable it per |
What I meant is that we also don't have such option for code-blocks document-wide. I consider it is not requested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inline syntax highlighting extension actually does use the Pygments bridge, and then applies a regex to remove the unnecessary <div>
that Pygments wraps it in.
Is that any better than using the lexed code from docutils?
Oh, I don't know that extension. It seems better to me in HTML case. It seems HtmlFormatter has "nowrap" option not to generate div and pre tag. It would be nice for this case. But, on the other hand, there are no such option for LaTeXFormatter... So it is hard to use this implementation to sphinx-core. |
I posted a PR for adding |
Thanks @tk0miya, I will change the implementation to use PygmentsBridge |
Fixes sphinx-doc#5157 This is factored out of the sphinx-immaterial theme: https://github.com/jbms/sphinx-immaterial/blob/1ef121a612d4f5afc2a9ca9c4e3f20fca89065e8/sphinx_immaterial/inlinesyntaxhighlight.py#L1 See also: sphinx-doc#6916
Fixes sphinx-doc#5157 This is factored out of the sphinx-immaterial theme: https://github.com/jbms/sphinx-immaterial/blob/1ef121a612d4f5afc2a9ca9c4e3f20fca89065e8/sphinx_immaterial/inlinesyntaxhighlight.py#L1 See also: sphinx-doc#6916
Fixes sphinx-doc#5157 This is factored out of the sphinx-immaterial theme: https://github.com/jbms/sphinx-immaterial/blob/1ef121a612d4f5afc2a9ca9c4e3f20fca89065e8/sphinx_immaterial/inlinesyntaxhighlight.py#L1 See also: sphinx-doc#6916
Fixes sphinx-doc#5157 This is factored out of the sphinx-immaterial theme: https://github.com/jbms/sphinx-immaterial/blob/1ef121a612d4f5afc2a9ca9c4e3f20fca89065e8/sphinx_immaterial/inlinesyntaxhighlight.py#L1 See also: sphinx-doc#6916
Fixes sphinx-doc#5157 This is factored out of the sphinx-immaterial theme: https://github.com/jbms/sphinx-immaterial/blob/1ef121a612d4f5afc2a9ca9c4e3f20fca89065e8/sphinx_immaterial/inlinesyntaxhighlight.py#L1 See also: sphinx-doc#6916
I adopted #10251 now instead of this. Thank you for your work. |
Subject: support inline syntax highlighting in HTML and LaTeX without extensions
Feature or Bugfix
Purpose
This PR adds the ability to do syntax highlighting of inline text using the docutils :code: role.
Changes:
\PYG
for inline codeThings this PR does not do (yet):
Relates