Skip to content

Add HTML extension#2082

Merged
k4b7 merged 12 commits intomasterfrom
html-extension
Dec 1, 2019
Merged

Add HTML extension#2082
k4b7 merged 12 commits intomasterfrom
html-extension

Conversation

@ylemkimon
Copy link
Member

@ylemkimon ylemkimon commented Aug 20, 2019

This PR adds four new commands that give access to some HTML features: \htmlClass, \htmlId, \htmlStyle, and \htmlData.

Fixes #90.
Fixes #2029.

if (parser.settings.strict) {
parser.settings.reportNonstrict("htmlExtension",
"HTML extension is disabled on strict mode");
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure they are necessary, as the trust setting controls them.

@k4b7
Copy link
Member

k4b7 commented Aug 21, 2019

@ylemkimon this is great!

@vd-man
Copy link

vd-man commented Sep 8, 2019

Does not work with fraction, eg:

\htmlId{id1}{a}+\frac{1}{\htmlId{id2}{b}}-c

id1 woks, but id2 does not.

@ylemkimon
Copy link
Member Author

@vd-man Both id1 and id2 seem to work here. Could you give more detail? Thank you.

@ylemkimon ylemkimon marked this pull request as ready for review October 3, 2019 09:50
@ylemkimon
Copy link
Member Author

This is ready for review!

@codecov-io
Copy link

codecov-io commented Oct 3, 2019

Codecov Report

Merging #2082 into master will decrease coverage by 0.05%.
The diff coverage is 85.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2082      +/-   ##
==========================================
- Coverage   94.86%   94.81%   -0.06%     
==========================================
  Files          81       82       +1     
  Lines        5262     5302      +40     
  Branches      921      927       +6     
==========================================
+ Hits         4992     5027      +35     
- Misses        247      252       +5     
  Partials       23       23
Flag Coverage Δ
#screenshotter 89.42% <61.53%> (-0.33%) ⬇️
#test 88.53% <85.36%> (-0.01%) ⬇️
Impacted Files Coverage Δ
src/functions.js 100% <ø> (ø) ⬆️
src/parseNode.js 80% <ø> (ø) ⬆️
src/Settings.js 79.06% <ø> (ø) ⬆️
contrib/render-a11y-string/render-a11y-string.js 89.53% <0%> (-0.7%) ⬇️
src/buildHTML.js 95.74% <100%> (ø) ⬆️
src/functions/html.js 89.47% <89.47%> (ø)
src/Parser.js 96.83% <0%> (+0.28%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9d8195c...6bedaad. Read the comment docs.

@phlegmaticprogrammer
Copy link

Would it be possible to add some docs for what \htmlId, \htmlStyle, \htmlClass and in particular \htmlData actually do? How can I preview the docs? If I click on "Deploy preview ready!" I get to a preview which has no updated HTML section in the docs.

@k4b7
Copy link
Member

k4b7 commented Oct 19, 2019

@phlegmaticprogrammer
Copy link

Now it works for me! This is great progress, although some CSS properties seem to be still under full KaTeX control, for example in

A*\htmlStyle{color: red; font-family: Arial, Helvetica, sans-serif; font-style: normal; font-size:50px;}{A}

the color and font-size are applied, but the font-family and style are not. So a general \html would still be necessary I guess.

@k4b7
Copy link
Member

k4b7 commented Nov 1, 2019

@phlegmaticprogrammer there's a ticket for adding \html, see #1596.

Copy link
Member

@k4b7 k4b7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding all of these HTML related commands. The implementation looks good. Requesting a few minor changes:

  • call buildString in render-a11y-string.js if possible
  • throw an error if parsing args to \htmlData fails
  • make the docs in support_table.md a bit clearer
  • screenshot tests (it's hard to see that spacing isn't affected by these commands)

Comment on lines +25 to +26
- Equivalents of MathJax `\class`, `\cssId`, and `\style` are `\htmlClass`,
`\htmlId`, and `\htmlStyle`, respectively, to avoid ambiguity.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this. If people want to use the MathJax variants they can set up some macros.

@ylemkimon ylemkimon requested a review from k4b7 November 6, 2019 11:48
Copy link
Member

@k4b7 k4b7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for adding these commands. I'm sure this will make a lot of people very happy.

@mariusGundersen
Copy link

This seems to be merged, but not released yet. What is the timeline for having this in a version available for use? I would really like to use this feature soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for \style{} Support for non-standard macros \class and \cssId

6 participants