nue icon indicating copy to clipboard operation
nue copied to clipboard

Allow adding Marked Extensions in NueJS

Open nobkd opened this issue 1 year ago • 5 comments

Hey I noticed nuemark uses marked as the underlying library. Is there an easy way to add marked extensions for things like footnotes?

Originally posted by @indifferentghost in https://github.com/nuejs/nue/discussions/159#discussioncomment-8126684

I think this deserves its own issue for tracking.

nobkd avatar Jan 28 '24 23:01 nobkd

According to the docs there does seem to be some add-ons. Also shouldn't this be in #170?

Darth-Ness avatar Jan 28 '24 23:01 Darth-Ness

Yes. It is a valid notice, that this is connected to that issue, but I wouldn't say that it's completely the same. We'll see.

As for the add-ons list: Yes, Marked supports these extensions, but there currently is no proper system in place to pass the extensions through Nue to the marked instance. :)


I've already looked into dynamically importing a (js-)file with the user added extensions (provided as relative file path in the site.yaml), but you need to have the base project directory path, as well as the extension file path available from inside of Nuemark (not nuekit). (As of the current project structure) This can be achieved okay-ish. But I'll look around some more for a better way. But maybe someone else has a better implementation in mind.

nobkd avatar Jan 29 '24 03:01 nobkd

Ah okay. What I was thinking for this was a use library-x directly in the markup, and then on building it fetches all of the necessary add-ons.

Darth-Ness avatar Jan 29 '24 18:01 Darth-Ness

Quite the interesting idea 👀, but not sure how good that would work, as you sometimes want to change configuration options for the (Marked) extensions. Sometimes even with JS, which is the reason, that I wouldn't include the config directly in the site.yaml

nobkd avatar Jan 29 '24 19:01 nobkd

Ah, didn't realize that you could configure the addons as well. Hmm, then yeah it probably makes since to have it in a config file.

Darth-Ness avatar Jan 29 '24 19:01 Darth-Ness

See: https://github.com/nuejs/nue/pull/230#issuecomment-2395513869

nobkd avatar Oct 06 '24 17:10 nobkd