Closed bowman2001 closed 5 months ago
I am in favor of adding the ability to write superscripts and subscripts. This has been requested on a handful of occasions, and the workarounds aren't pretty:
markup.goldmark.renderer.unsafe = true
)strings.ReplaceRE
on .Content
using the same markdown syntax shown aboveI have not seen any requests for the ability to do inserts (<ins>insert</ins>
), but I don't see any harm in it either.
On the Hugo side I guess the default config would look like:
[markup.goldmark.extensions]
insert = false
subscript = false
superscript = false
Note that the markdown would be compatible with Asciidoc, Pandoc, and Typora (perhaps others), but the markdown will not be compatible with GitHub Flavored Markdown or GitLab Flavored Markdown. However, I don't see that as a reason to decline this proposal.
https://discourse.gohugo.io/t/extensions-for-super-and-subscripts/48150/2?u=jmooring
@bep I am in favor of implementing this, with all extensions disabled by default. I've tested the associated PR with Hugo integration and it works great. These are (to me) lightweight and simple (they each do one and only one thing), and seem to have little impact on performance when enabled.
The workarounds for inserting subscripts and superscripts are ugly.
This would also be a reason to bump the minor release version sooner rather than later.
@bep I know that you have a lot on your plate and appreciate your work on other parts of Hugo. But could you take a look at this, please. Hopefully, there is no further work involved for you, and I believe it’s a valuable add-on.
Yea, this is a good idea.
These 3 extensions look very similar (at least from an implementation point of view, I suspect it's also more effective to have one extension for all of them), so I suggest we just pick one package name and put them in there, and make them configurable with a struct ala what @jmooring suggests for Hugo:
insert = false
subscript = false
superscript = false
We might as well just pick one of them for the package name (better suggestions welcome) and the extension could be created like this:
ext := subscript.New(
subscript.Config{
Subscript: true,
Superscript: true,
Insert: true,
}
)
Extension name... what about "extras"?
[markup.goldmark.extensions.extras]
insert = false
subscript = false
superscript = false
Extension name... what about "extras"?
That works
Good, I’m gonna close the current pull request for now and come up with a new one next week. Thanks!
I would like to add these inline extensions as additional options to Hugo’s Goldmark instances.
We have been discussing the first two ones in the Forum.
These extensions follow the same syntax as the ones for markdown-it:
1^st^
→1<sup>st</sup>
(see npm repo)H~2~O
→H<sub>2</sub>O
(see npm repo++insert++
→<ins>insert</ins>
(see npm repoTheir default configuration switch should be set to false, because every new extension adds more load to the parser and the demand is not very high.
My fork of this repo already contains the code for these extensions, including many test cases. I tried to follow the structure of the first extension
passthrough
and took your advice in #8 into consideration.I already build a local Hugo version including these extensions and would know how to integrate them.