Closed genericFJS closed 2 years ago
Added a test and documentation.
This looks great! Thanks a lot! I just left a couple of questions
While testing a bit more I found a huge problem with my approach: by using marked.use
I manipulate the global options. Marked therefore keeps the options (between tests). That means that I can not pass an extension in one test and have a following test where I expect the custom token not to be replaced.
I think we should close this pull request, since marked.use
has a lot of side effects and implementing it side effect free seems too big a hassle.
Since marked.use
transformes the extensions to another structure into the global marked.defaults
options, it's easier if SvelteMarkdown does not support extensions directly, but the user may generate his own extension-enriched options and pass it as options to the SvelteMarkdown component:
<script>
// [… as in first comment]
// let marked save extension information to global options:
marked.use({ extensions: [latexTokenizerExtension] });
// use global marked options as parameter for SvelteMarkdown-component
const options = marked.defaults;
</script>
<!-- works without this PR -->
<SvelteMarkdown {source} {options} {renderers} />
Closing in favor of manually doing it by passing the appropriate options.
Quick and dirty: Add "use" parameter which allows extensions (see #17 ).
Example usage (replaces token
[[latex…]]
with a coloredspan
): FileApp.svelte
Imported file
LatexMarkdown.svelte