Skip to content

Commit

Permalink
fix EntityRE issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dhowe committed Nov 13, 2023
1 parent 8e8848e commit 7666d03
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/riscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class RiScript {
this.RawAssignRE = new RegExp(`^[${anysym}][A-Za-z_0-9][A-Za-z_0-9]*\\s*=`);
this.ChoiceWrapRE = new RegExp('^' + open + '[^' + open + close + ']*' + close + '$');

this.EntityRE = tokens.modes.normal.filter(t => t.name === 'Entity')[0].PATTERN;
this.SpecialRE = new RegExp(`[${this.Escaped.SPECIAL.replace('&', '')}]`);
this.ContinueRE = new RegExp(this.Escaped.CONTINUATION + '\\r?\\n', 'g');
this.WhitespaceRE = /[\u00a0\u2000-\u200b\u2028-\u2029\u3000]+/g;
Expand Down
3 changes: 2 additions & 1 deletion src/tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function getTokens(v2Compatible) {
const Escaped = {};
Object.entries(Symbols).forEach(([k, v]) => { Escaped[k] = escapeRegex(v) });

const ENTITY_PATTERN = /&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-fA-F]{1,6});/i;
const PENDING_GATE_PATTERN = new RegExp(`${Escaped.PENDING_GATE}([0-9]{9,11})`)

Escaped.SPECIAL = Object.values(Escaped).join('').replace(/[<>]/g, ''); // allow <>& for html
Expand Down Expand Up @@ -74,7 +75,7 @@ function getTokens(v2Compatible) {
const CS = createToken({ name: "CS", pattern: new RegExp(`\\s*${Escaped.CLOSE_SILENT}`) });
const SYM = createToken({ name: "SYM", pattern: new RegExp(`[${Escaped.DYNAMIC}${Escaped.STATIC}][A-Za-z_0-9]*`) });

const Entity = createToken({ name: "Entity", pattern: /&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-fA-F]{1,6});/i });
const Entity = createToken({ name: "Entity", pattern: ENTITY_PATTERN });
const Weight = createToken({ name: "Weight", pattern: new RegExp(`\\s*${Escaped.OPEN_WEIGHT}.+${Escaped.CLOSE_WEIGHT}\\s*`) });
const Raw = createToken({ name: "Raw", pattern: new RegExp(`[^${Escaped.SPECIAL}]+`) });

Expand Down

0 comments on commit 7666d03

Please sign in to comment.