Gathering detailed insights and metrics for remark-slate-transformer
Gathering detailed insights and metrics for remark-slate-transformer
Gathering detailed insights and metrics for remark-slate-transformer
Gathering detailed insights and metrics for remark-slate-transformer
npm install remark-slate-transformer
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
109 Stars
471 Commits
22 Forks
2 Watching
9 Branches
6 Contributors
Updated on 20 Nov 2024
Minified
Minified + Gzipped
TypeScript (96.44%)
JavaScript (3.56%)
Cumulative downloads
Total Downloads
Last day
-37.8%
4,439
Compared to previous day
Last week
14.8%
30,970
Compared to previous week
Last month
70.9%
128,295
Compared to previous month
Last year
116.2%
846,500
Compared to previous year
3
1
33
remark plugin to transform remark syntax tree (mdast) to Slate document tree, and vice versa. Made for WYSIWYG markdown editor.
remark is popular markdown parser/serializer which data structure can be converted to what used in rehype, retext and so on. Slate is fully customizable rich text editor built on React. Connect both 2 worlds should be great...
This plugin supports slate 0.50+. The data structure is described here. slate ~0.47.9 was supported until 0.8.1.
All nodes in mdast syntax tree are supported, including nodes created with...
math
and inlineMath
from remark-math.And also have experimental support for custom AST.
https://inokawa.github.io/remark-slate-transformer/
1npm install remark-slate-transformer
remark-slate-transformer | unified |
---|---|
>=0.9.0 | >=11.0.0 |
>=0.7.0 <0.9.0 | >=10.1.0 <11.0.0 |
>=0.5.0 <0.7.0 | >=10.0.0 |
<0.5.0 | <10.0.0 |
1import { unified } from "unified"; 2import markdown from "remark-parse"; 3import { remarkToSlate } from "remark-slate-transformer"; 4 5const processor = unified().use(markdown).use(remarkToSlate); 6 7const text = "# hello world"; 8 9const value = processor.processSync(text).result; 10console.log(value);
1import { unified } from "unified"; 2import stringify from "remark-stringify"; 3import { slateToRemark } from "remark-slate-transformer"; 4 5const processor = unified().use(stringify); 6 7const value = ...; // value passed to slate editor 8 9const ast = processor.runSync(slateToRemark(value)); 10const text = processor.stringify(ast); 11console.log(text);
1import { unified } from "unified"; 2import markdown from "remark-parse"; 3import stringify from "remark-stringify"; 4import { remarkToSlate, slateToRemark } from "remark-slate-transformer"; 5 6const text = "# hello world"; 7const r2s = unified() 8 .use(markdown) 9 .use(remarkToSlate, { 10 // If you use TypeScript, install `@types/mdast` for autocomplete. 11 overrides: { 12 // This overrides `type: "heading"` builder of remarkToSlate 13 heading: (node, next) => ({ 14 type: "head", 15 dep: node.depth, 16 // You have to call next if the node have children 17 children: next(node.children), 18 }), 19 // Unknown type from community plugins can be handled 20 foo: (node, next) => ({ type: "foo", value: node.bar }), 21 }, 22 }); 23const value = r2s.processSync(text).result; 24console.log(value); 25 26const s2r = unified().use(stringify); 27const ast = s2r.runSync( 28 slateToRemark(value, { 29 overrides: { 30 head: (node, next) => ({ 31 type: "heading", 32 depth: node.dep, 33 children: next(node.children), 34 }), 35 foo: (node, next) => ({ type: "foo", bar: node.value }), 36 }, 37 }) 38); 39const text = s2r.stringify(ast); 40console.log(text);
Transformer utilities mdastToSlate
and slateToMdast
are also exported for more fine-tuned control.
All contributions are welcome. If you find a problem, feel free to create an issue or a PR.
npm install
.No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 5
Details
Reason
5 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 4
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
Found 0/24 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
10 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More