Skip to content
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

Add extras extension package for insert, mark, subscript, and superscript #12

Closed
bowman2001 opened this issue Feb 20, 2024 · 7 comments · Fixed by #18
Closed

Add extras extension package for insert, mark, subscript, and superscript #12

bowman2001 opened this issue Feb 20, 2024 · 7 comments · Fixed by #18
Labels
enhancement New feature or request

Comments

@bowman2001
Copy link
Contributor

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~OH<sub>2</sub>O (see npm repo
  • ++insert++<ins>insert</ins> (see npm repo

Their 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.

@jmooring
Copy link
Member

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:

  • Shortcodes
  • Raw HTML (requires markup.goldmark.renderer.unsafe = true)
  • strings.ReplaceRE on .Content using the same markdown syntax shown above

I 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

@jmooring
Copy link
Member

jmooring commented Mar 4, 2024

@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.

@bowman2001
Copy link
Contributor Author

@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.

@bep bep added the enhancement New feature or request label Mar 15, 2024
@bep
Copy link
Member

bep commented Mar 15, 2024

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,
   }
)

@jmooring
Copy link
Member

Extension name... what about "extras"?

  [markup.goldmark.extensions.extras]
    insert = false
    subscript = false
    superscript = false

@bep
Copy link
Member

bep commented Mar 15, 2024

Extension name... what about "extras"?

That works

@bep bep changed the title feat request: Add extensions for superscript, subscript, and insert Add extras extension package for superscript, subscript, and insert Mar 15, 2024
@bowman2001
Copy link
Contributor Author

Good, I’m gonna close the current pull request for now and come up with a new one next week. Thanks!

@jmooring jmooring changed the title Add extras extension package for superscript, subscript, and insert Add extras extension package for insert, mark, subscript, and superscript May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants