Skip to content

Commit

Permalink
Mark improperly terminated bold and italics markers with error nodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
drgrice1 committed Oct 14, 2024
1 parent f568951 commit 957da02
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/pgml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,10 @@ const pgmlFormat = (block: Item, offset: number): Element<Type>[] => {
return [elt(Type.Option, block.from + offset, block.to + offset, children)];
} else if (block.type === 'bold' || block.type === 'italic') {
children.unshift(elt(Type.EmphasisMark, block.from + offset, block.from + 1 + offset));
children.push(elt(Type.EmphasisMark, block.to - 1 + offset, block.to + offset));
const lastChild = block.stack?.at(-1);
if (lastChild instanceof Item && block.to === lastChild.to)
children.push(elt(Type.PGMLError, block.to + offset, block.to + offset));
else children.push(elt(Type.EmphasisMark, block.to - 1 + offset, block.to + offset));
return [
elt(
block.type === 'bold' ? Type.StrongEmphasis : Type.Emphasis,
Expand Down

0 comments on commit 957da02

Please sign in to comment.