Skip to content

Commit

Permalink
fix: Special-case string content during node->mark conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
idreyn committed Jan 25, 2022
1 parent b7cc6fe commit d410c29
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/transform/fromPandoc/fromPandoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,17 @@ const fromPandocInner = (
const accepted = elements[ptr];
const marks = asArray(rule.transformer(accepted, context));
if ("content" in accepted) {
const innerTransformed = fromPandocInner(
// This cast works around the fact that some Pandoc nodes have nested arrays
// as their content property (e.g. OrderedList has Block[][]). This shouldn't
// be a problem in practice unless you're trying to do something very stupid
// like turn an OrderedList node into an em mark.
accepted.content as Block[] | Inline[],
context
).asArray();
const innerTransformed =
typeof accepted.content === "string"
? [{ type: "text", text: accepted.content }]
: fromPandocInner(
// This cast works around the fact that some Pandoc nodes have nested arrays
// as their content property (e.g. OrderedList has Block[][]). This shouldn't
// be a problem in practice unless you're trying to do something very stupid
// like turn an OrderedList node into an em mark.
accepted.content as Block[] | Inline[],
context
).asArray();
for (const node of innerTransformed) {
localMarksMap.set(node, marks);
}
Expand Down

0 comments on commit d410c29

Please sign in to comment.