-
-
Notifications
You must be signed in to change notification settings - Fork 180
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
Support marked custom extensions #387
Comments
I was just looking for this option (for mention people) if possible, and google brought me here, kind of stumped that it is not possible, looking forward to seeing this implemented. |
Hi, I am also want to create some custom extensions for my project. Any updates on this? |
@mike-pisman Hi, after no response to my issue, I implemented my own very lightweight component and service. As for questions asked in the issue
|
Thank you I will try to do the same |
The update to marked v9 has been completed as part of the ngx-markdown v17.0.0 release and includes the support for marked extensions. Please make sure to read the release notes as there are breaking changes. |
I would like to propose a new feature that would support
marked
custom extensions. See marked docs.Custom extensions can be used to define own rules (and renderer and tokenizer) for compiling markdown to html. Its useful for example for supporting tagging (like
@
here on Github).I tried to implement it in my local fork because I need it for something I'm wokin on, so I think I should be able to provide a PR.
However, there are some issues with my implementation, that I would like to discuss first.
we need to extend
MarkedOptions
class byextensions
attribute. The problem here is thatmarked
does not export theMarkedExtension
so we have to either useany
, provide own type, or create an issue inmarked
repo to export this interface.We need to make some changes in
MarkdownService
because of the implementation ofmarked
. In constructor and setter ofoptions
we need to pass the extensions to marked, like thismarked.use({extensions: this.options.extensions})
. In order to work correctly though we need to change thecompile
method inMarkdownService
. Callingmarked
with options, as its done now, breaks the extensions. I debugged the marked code and found out, that after callinguse
, the extensions are processed by marked and its structure is changed a bit (renderer
andtokenizer
attributes are replace withrenderers
andtokenizers
). Passing options directly tocompile
overrides the internal structure and extension renderers and tokenizers are not picked up by marked. I think, it would be better to callmarked.setOptions
(andmarked.use
if extensions are provided) inoptions
setter and constructor and incompile
method, just callmarked
without options.As I said, this feature is important to me and I already made it work for my own use case, so I will gladly put a PR for it. @jfcere Whats your idea on the issues mentioned in points 1 and 2? Thanks
The text was updated successfully, but these errors were encountered: