Skip to content

Commit

Permalink
Fix the case when an emphasis start and end token are not of the same…
Browse files Browse the repository at this point in the history
… length.
  • Loading branch information
drgrice1 committed Nov 23, 2024
1 parent 454d370 commit 2c35af2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openwebwork/codemirror-lang-pg",
"version": "0.0.1-beta.16",
"version": "0.0.1-beta.17",
"description": "PG language support for CodeMirror",
"author": "The WeBWorK Project",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions src/pgml-parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,14 +379,14 @@ export class PGMLParse {
const type = BlockDefs[token.substring(0, 1)]?.type;
let block = this.block;
if (block && block.type === type) {
block.to += block.token?.length ?? 1;
block.to += token.length;
this.Terminate();
return;
}
while (block?.type !== 'root') {
if (block && block.prev?.type === type) {
this.End(`end of ${type ?? ''}`, block);
block.to += block.token?.length ?? 1;
block.to += token.length;
this.Terminate();
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/pgml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ const pgmlFormat = (block: Item, offset: number): Element<Type>[] => {
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 - (block.token?.length ?? 1) + offset, block.to + offset));
else children.push(elt(Type.EmphasisMark, children.slice(-1)[0].to, block.to + offset));
return [
elt(
block.type === 'bold' ? Type.StrongEmphasis : Type.Emphasis,
Expand Down

0 comments on commit 2c35af2

Please sign in to comment.