-
In Markdown, inline However, when building an editor using Micromark, I only want to re-parse a single block at a time. I can't find a way to recognize This is a [label].
^^^^^^^^^^^^^^^^^^only re-parse this while typing
[label]: www.example.com What I'm looking for is something like this, is there any workaround? const chunks = micromark.preprocess()("This is a [label]", undefined, true)
const parseContext = micromark.parse({
definitions:[
"label", // To parse `[label]` correctly.
...
],
});
const events = micromark.postprocess(
parseContext
.document()
.write(chunks))
// → content "This is a [label]" (0..17)
// → paragraph "This is a [label]" (0..17)
// → data "This is a " (0..10)
// ← data "This is a " (0..10)
// → link "[label]" (10..17) <-----. I want to get these events
// → label "[label]" (10..17) |
// → labelMarker "[" (10..11) |
// ← labelMarker "[" (10..11) |
// → labelText "label" (11..16) |
// → data "label" (11..16) |
// ← data "label" (11..16) |
// ← labelText "label" (11..16) |
// → labelMarker "]" (16..17) |
// ← labelMarker "]" (16..17) |
// ← label "[label]" (10..17) |
// ← link "[label]" (10..17) <-----'
// ← paragraph "This is a [label]" (0..17)
// ← content "This is a [label]" (0..17) Thanks for the great works! |
Beta Was this translation helpful? Give feedback.
Answered by
kkshinkai
Sep 19, 2023
Replies: 1 comment 1 reply
-
I figured it out myself ... I misunderstood const parseContext = micromark.parse();
parseContext.defined = ["LABEL"]
// ^^^^^^^ use normalized string "LABEL" instead of "label"
const tokenizeConetext = parseContext.document();
const events = micromark.postprocess(tokenizeConetext.write(chunks)) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
kkshinkai
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I figured it out myself ... I misunderstood
normalizeIdentifier
, it works now: