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 the delimiter to the context into the render-passthrough #12803

Open
KopiasCsaba opened this issue Aug 28, 2024 · 2 comments
Open

Add the delimiter to the context into the render-passthrough #12803

KopiasCsaba opened this issue Aug 28, 2024 · 2 comments

Comments

@KopiasCsaba
Copy link

Hi There,

Thank you for making hugo, it is awesome, just as you are guys.

I'd like to request a feature, to include the delimiter as well upon rendering the passthrough template.

I think it could be useful to know from where we are called, is it a :foo: or a +bar+ or even a [foobar].

Thank you!

@bep
Copy link
Member

bep commented Aug 28, 2024

I think it could be useful to know from where we are called, is it a :foo: or a +bar+ or even a [foobar].

Do you have a specific example of one such useful use case?

This has been discussed, and to me

  • The delimiter is a configuration things, e.g. dependent on the content, and not something you can use in the templates (except in the simplest of setups)
  • We will probably want to add support for multiple passthrough configurations, so you would get math, inline and block and somethingelse ...

Not sure, but I think we need to wait on this particular issue until someone comes up with a real and convincing use case.

@KopiasCsaba
Copy link
Author

KopiasCsaba commented Aug 28, 2024

Thank you for your insight!

My usecase is that i want to support emojis, but on my own way with emojicss, to make sure all emojis look the same no matter which browser, etc.

I also want to keep the :foo: format, not using a shortcode that has a bit more cumbersome format.

So for now until i only do this, I'm good, but I was wondering, if i'd want to create something else, similarly, then it isn't seem to be possible.

Lets say i want the math things and the emoji things, then I can't put in an if to see which delimiter was matched.

I've checked hugo's source and it would seem quite trivial to do this:
image

Just include delim in the context and we are good to go (i think, without deep knowledge of things in there, yet).

On the other hand I like your idea as well, if i could say, something like:

markup:
  goldmark:
    extensions:
      passthrough:
        enable: true
        renderers:
          math:
            inline: false
            delimiters: ['[',']','+','+']
          emojis:
            math:
              inline: true
              delimiters: [ ':',':' ]

That could be a nicer solution indeed. Although, there might still be a passthrough renderer that want to know which delimiter triggered it. E.g. The math thing might use a different notation or what ever based on [foo] or +foo+.

Cheers!

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

No branches or pull requests

3 participants