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

feat: marked extensions #230

Closed
wants to merge 3 commits into from
Closed

feat: marked extensions #230

wants to merge 3 commits into from

Conversation

nobkd
Copy link
Collaborator

@nobkd nobkd commented Mar 14, 2024

WIP/POC implementation for marked extension loading.

Description

The default file to load from is marked.config.js but this can be changed using the marked_config key in site.yaml.
The provided file path currently has to be relative to the root folder of the project / the root passed to nue command

The config js file has to be of format:

// e.g. imports

export default [ // has to be an array
  // initialize marked extensions with functions / own objects here
]

If no file is found, the import() function silently returns an empty object which, on unpacking, results in an empty list for marked_extensions variable

TODO

  • exclude marked config file from output folder
  • add tests

Notes

Maybe allow additional renderers with the following?

marked.use({
 extensions: [
   //...
 ]
})

@tipiirai
Copy link
Contributor

Seems legit. This should only cover extensions that are not possible to implement as Nuemark extensions/tags. Footnote is probably the only one. Anything else?

@nobkd
Copy link
Collaborator Author

nobkd commented Mar 24, 2024

Well, you can also add all the other marked extensions.
It is sometimes easier to just use an existing package instead of re-building stuff yourself.

e.g.

  • extended tables syntax
  • footnotes, smartypants (lite) (as it was removed from the base package)
  • katex could also be interesting for some use cases
  • etc.

https://marked.js.org/using_advanced#extensions


Still WIP, as I have to do the todos, and want to use joinRootPath (or changed name) to import the file.


BTW, I think, this config isn't needed, as the options are deprecated (smartypants, headerIds, mangle) or nonexistent (smartLists at least it's not in this table):
https://github.com/nuejs/nue/pull/230/files#diff-9aaf075b4e5c776d59c27ef6c62e9c1079673f706482643126f348d7c6550cdfR9-R14

@nobkd

This comment was marked as outdated.

@nobkd

This comment was marked as outdated.

@nobkd nobkd marked this pull request as ready for review April 3, 2024 00:35
@nobkd

This comment was marked as outdated.

@nobkd nobkd requested a review from tipiirai April 7, 2024 23:53
@tipiirai

This comment was marked as outdated.

@nobkd

This comment was marked as outdated.

@nobkd

This comment was marked as outdated.

@nobkd

This comment was marked as outdated.

@nobkd

This comment was marked as outdated.

@nobkd

This comment was marked as resolved.

@nobkd

This comment was marked as resolved.

@nobkd

This comment was marked as resolved.

@nobkd nobkd marked this pull request as ready for review July 21, 2024 18:47
@nobkd nobkd changed the base branch from master to dev August 11, 2024 21:13
@nobkd

This comment was marked as resolved.

@nobkd nobkd marked this pull request as draft August 11, 2024 21:36
@nobkd
Copy link
Collaborator Author

nobkd commented Aug 11, 2024

Note

I'm not sure, if the config file might be better to be implemented with name nue.config.js (or changeable in site.yaml) with option marked (or similar), so that other js-required options can be implemented, e.g. some lightningcss configs (see #220) 🤷.

@nobkd nobkd marked this pull request as ready for review August 11, 2024 22:08
@tipiirai
Copy link
Contributor

I've been hesitant to merge this, even when completed, due to increasing dependency to Marked, which is not my favorite parser.

@nobkd nobkd changed the base branch from dev to master August 19, 2024 05:11
@nobkd nobkd added nuemark Related to nuemark package needs discussion Needs a discussion or decision labels Sep 1, 2024
@nobkd
Copy link
Collaborator Author

nobkd commented Oct 6, 2024

Closing because of upcoming nuemark version, that doesn't depend on marked anymore

@nobkd nobkd closed this Oct 6, 2024
@nobkd nobkd deleted the feat/marked-ext branch October 6, 2024 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs discussion Needs a discussion or decision nuemark Related to nuemark package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow adding Marked Extensions in NueJS
2 participants