-
Notifications
You must be signed in to change notification settings - Fork 21
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
Optionally use KaTeX for math in HTML #7
base: master
Are you sure you want to change the base?
Conversation
An installed copy of stex might have all write permission bits removed, even for the owner of the installed files: this is the case with the Guix package of stex, for example. If such an installation is used to initialize the gifs or math directories (e.g. for an out-of-source build), tar likewise creates them without write permissions, preventing subdirectories from being created later. Set the user write bit explicitly to avoid this problem. Furthermore, tar by default would copy symbolic links in the installed copy as links, causing chmod to fail or, if permitted, writes to an improper location. Avoid this using the --dereference option, which is portable to at least GNU and FreeBSD tar (but only in long form: GNU has -h, but FreeBSD has -L). Mf-stex Related to racket/racket#4203 Closes dybvig#6
Emit the – and — entites, which are now well supported. Emit <td style="white-space:nowrap;"> instead of the deprecated <td nowrap>. src/html-prep.ss
KaTeX renders LaTeX math ahead-of-time to MathML and/or HTML. Its output is accessible to screen readers and other tools (instead of appearing as "<graphic>"), and it also looks less pixelated than math rendered to GIFs. Depends on dybvig/stex#7
KaTeX renders LaTeX math ahead-of-time to MathML and/or HTML. Its output is accessible to screen readers and other tools (instead of appearing as "<graphic>"), and it also does not suffer from the pixelation of math rendered to GIFs. Depends on dybvig/stex#7
Good catch! I will push a revised series with that fix, though probably not today. For context, the KaTeX documentation says that its output generally requires |
- Adjust \schemedisplay{} to preserve the existing layout with the switch to <!DOCTYPE html>. inputs/scheme.hsty, doc/stex.css
5d73fbf
to
188d0ea
Compare
I've pushed a revised series with the fix for |
KaTeX renders LaTeX math ahead-of-time to MathML and/or HTML. Its output is accessible to screen readers and other tools (instead of appearing as "<graphic>"), and it also does not suffer from the pixelation of math rendered to GIFs. Also, use scheme.sty and scheme.hsty from stex instead of stale copies with ad-hoc changes. Depends on dybvig/stex#7
- Detect when KaTeX is available and use it. Add the variables KATEX, KATEX_FLAGS, and KATEX_CSS for configuration. Add KaTeX definitions for macros needed for compatibility. Mf-stex, math/Makefile, math/katexmacros - Add --use-katex, --katex-css-link-file, and --katex-finished to html-prep. Use <!DOCTYPE html>. Emit a link to katex.css when applicable. Adjust emit-math and punt-to-latex for KaTeX backend. Report lack of support for \epsfbox{} and the eqnarray* environment when using KaTeX. Add special handling for the "ghost" \Rightarrow so that it will match the selected backend's \Rightarrow. src/html-prep.ss, inputs/scheme.hsty - Adjust \schemedisplay{} to preserve the existing layout with the switch to <!DOCTYPE html>. inputs/scheme.hsty, doc/stex.css - Support the macros \LaTeX and \KaTeX. inputs/scheme.sty, inputs/scheme.hsty - Update documentation and build with KaTeX. Add .gitignore to avoid committing generated intermediate files. Makefile.template, doc/Makefile, doc/stex.stex, doc/stex.pdf, doc/stex.html, doc/stex.katex-css-link, doc/.gitignore - Increment version to 1.3. src/VERSION
188d0ea
to
27cddfb
Compare
I've pushed a slight change that uses: .schemedisplay { line-height: 1.0625; }
.schemedisplay .katex { font-size: 1em; } to prevent math inside I don't know of anything else that needs to be done before this can be merged, though more review is always welcome! |
KaTeX renders LaTeX math ahead-of-time to MathML and/or HTML. Its output is accessible to screen readers and other tools (instead of appearing as "<graphic>"), and it also does not suffer from the pixelation of math rendered to GIFs. Also, use scheme.sty and scheme.hsty from stex instead of stale copies with ad-hoc changes. Depends on dybvig/stex#7
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.
Thanks for updating this. I finally got back to looking at it and had just a couple suggestions. I'd like to get these changed merged.
I'm still wading through the changes over in the Chez Scheme repository. Not sure what prompted the increase in \hfuzz
over in csug.stex, for example.
(input-error "environment eqnarray* not supported by KaTeX")) | ||
;; Might be viable to translate to \begin{align*} ... \end{align*} syntax, | ||
;; which KaTeX does support, or to add support for align* and encourage | ||
;; users to port there documents. See discussion in: |
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.
"there" => "their"
(fprintf op "<!-- DO NOT EDIT THIS FILE-->~%") | ||
(fprintf op "<!-- Edit the .tex version instead-->~%~%") | ||
(fprintf op "<!-- Edit the .stex version instead-->~%~%") | ||
(fprintf op "<html>~%") | ||
(fprintf op "<head>~%<title>~a</title>~%" title) |
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.
This patch series adds optional support for using KaTeX, which generates MathML and/or HTML from LaTeX math, as an alternative to rendering math to GIFs. The most important benefit of using KaTeX is that its output is accessible to screenreaders and other assistive technologies, rather than appearing as
<graphic>
. The output also integrates with CSS, can be copied and pasted as text, can reflow across line breaks as needed, and doesn't suffer from pixelation.The support added to stex is sufficient to handle all uses math mode in
stex.stex
and the latest versions of the Chez Scheme User's Guide and release notes without requiring any changes to the stex documents themselves. (Chez Scheme does need a few minor changes to the makefiles related to installation and cross-references to The Scheme Programming Language.) The only other public stex document I know of, Nanopass'suser-guide.stex
, does not render to HTML at all (it uses\documentclass{book}
, but there is nobook.hcls
).As an example, here is a comparison of the rendering of part of the documentation for
collect
:This series also subsumes my earlier #6, as I encountered related issues while working on these patches.