-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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: add Marked instance #2831
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
docs/USING_ADVANCED.md
Outdated
|
||
```js | ||
import { Marked } from 'marked'; | ||
const marked = new Marked([...useArgs]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to be an array? The tests make it seems like its an object, not array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constructor can take any number of options objects just like the use function. The square brackets mean it is optional. I know it is a weird way of writing that but that is how we indicate optional arguments in other parts of the docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated it to be more informative
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve after @styfle 's points get addressed.
Co-authored-by: Steven <steven@ceriously.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks! 🎉
Perhaps we can move toward a future were we deprecate and remove the old marked
that mutates global state in favor of this new class instance 👍
when is it expected to get 5.1.0 version of @types/marked to use instance-based marked in typescript? |
Based on a new addition to marked, this commits replaces the imported marked namespaces with a Marked class, that doesn't change when `marked.use` introduces new options or extensions. Also changes the naming slighty to use `markdown` as module, so it sounds more generic. Reference: markedjs/marked#2831 Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
Based on a new addition to marked, this commits replaces the imported marked namespaces with a Marked class, that doesn't change when `marked.use` introduces new options or extensions. Also changes the naming slighty to use `markdown` as module, so it sounds more generic. Reference: markedjs/marked#2831 Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
Based on a new addition to marked, this commits replaces the imported marked namespaces with a Marked class, that doesn't change when `marked.use` introduces new options or extensions. Also changes the naming slighty to use `markdown` as module, so it sounds more generic. Reference: markedjs/marked#2831 Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
Description
Add
import { Marked } from 'marked'
to get an instance of marked that will not change global options when options are changed or extensions are added.This initial parameters are passed to
use
so you can add options or extensions.import { marked } from 'marked'
still works the way it always has by updating global options.Contributor
Committer
In most cases, this should be a different person than the contributor.