Comments (5)
env
is per render, but for different things - transfer data between stages. In theory, it's possible to add flags there, but not sure that it's a good idea to do it now.
If you have limited combination of settings - create as many instances as can be, and select appropriate, based on you state (admin permissions in your case). Cache can be done with lodash _.memioze
for example.
from markdown-it.
https://markdown-it.github.io/markdown-it/#MarkdownIt.set set
can help with options, but can affect speed (see note). If you don't need highest performance - use it.
from markdown-it.
There are three objects that affect parsing behavior:
state
(inline, block) - those properties are bound with a string which parser is currently processingenv
- those properties are bound with a current execution of the parseroptions
(or that parser class instance) - those properties are for the entire parser, and they stays the same for multiple executions
So each time you call .render()
, one env
object gets created, and multiple state
objects, but parser class (and options) stay the same across executions.
Now, if you want to enable html
in one cases, but not in others, I would probably create two separate parser instances, and use one or the other. But yes, you can use just one parser and make an env
flag for this which you would set each time .render()
is called.
from markdown-it.
ok having multiple parsers is okay. i just don't know wtf env
is. docs are so dense man! haha
from markdown-it.
When text is parsed, the main data are tokens. Those are passed between stages in arrays. But there are some kinds of metadata, not fitting in this concept. For example - descriptions of references, abbreviations, footnotes. Those are passed via env
.
In real world you will never use env
directly, if you are not plugin writer. Consider it as strange shit, reserved for the future :)
from markdown-it.
Related Issues (20)
- Quadratic output size explosion with tables extension HOT 1
- Convenient way to use markdown-it via cdn? HOT 1
- “Propuesta de Integración de Funcionalidad de Comentarios en la Plataforma de Blog XYZ”
- Improve code in `state_inline.mjs` HOT 1
- Table parsing does not work HOT 3
- Is it possible to get col number and row number of each token? HOT 1
- isString is not a function HOT 1
- bold render error HOT 1
- crash when input has brackets without parentheses HOT 1
- inline html transform error HOT 3
- Bold can not be rendered with punctuation marks HOT 1
- Disabling the "code" rule doesn't disable code parsing, just code rendering
- Nested numbering not working as expected HOT 1
- How can I custom renderer tag?
- Error parsing numbered bullet in Markdown HOT 1
- Is this a markdown-it thing or a commonmark thing? HOT 3
- Certain tables under bullet points are not rendered HOT 7
- When a math fence immediately follows text, the resulting tokens are multiplied HOT 4
- Regression with v14.1.0 regarding ~~strikethrough text~~ HOT 1
- Inserting a link in markdown with underscore HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from markdown-it.