Changes to timeline.jison

1. Updated the regex for title, section, and event elements to allow hashtags.
2. Period elements remain unchanged.
Changes to timeline.spec.js
1. Added test coverage to ensure that the title, section, and event elements allow hashtags without error.
This commit is contained in:
futzmonitor
2024-03-20 14:32:03 -04:00
parent 10fb85663f
commit 6d69c26c8d
2 changed files with 19 additions and 3 deletions

View File

@@ -18,7 +18,7 @@
\#[^\n]* /* skip comments */ \#[^\n]* /* skip comments */
"timeline" return 'timeline'; "timeline" return 'timeline';
"title"\s[^#\n;]+ return 'title'; "title"\s[^\n;]+ return 'title';
accTitle\s*":"\s* { this.begin("acc_title");return 'acc_title'; } accTitle\s*":"\s* { this.begin("acc_title");return 'acc_title'; }
<acc_title>(?!\n|;|#)*[^\n]* { this.popState(); return "acc_title_value"; } <acc_title>(?!\n|;|#)*[^\n]* { this.popState(); return "acc_title_value"; }
accDescr\s*":"\s* { this.begin("acc_descr");return 'acc_descr'; } accDescr\s*":"\s* { this.begin("acc_descr");return 'acc_descr'; }
@@ -26,10 +26,10 @@ accDescr\s*":"\s* { this.begin("ac
accDescr\s*"{"\s* { this.begin("acc_descr_multiline");} accDescr\s*"{"\s* { this.begin("acc_descr_multiline");}
<acc_descr_multiline>[\}] { this.popState(); } <acc_descr_multiline>[\}] { this.popState(); }
<acc_descr_multiline>[^\}]* return "acc_descr_multiline_value"; <acc_descr_multiline>[^\}]* return "acc_descr_multiline_value";
"section"\s[^#:\n;]+ return 'section'; "section"\s[^:\n;]+ return 'section';
// event starting with "==>" keyword // event starting with "==>" keyword
":"\s[^#:\n;]+ return 'event'; ":"\s[^:\n;]+ return 'event';
[^#:\n;]+ return 'period'; [^#:\n;]+ return 'period';

View File

@@ -1,5 +1,6 @@
import { parser as timeline } from './parser/timeline.jison'; import { parser as timeline } from './parser/timeline.jison';
import * as timelineDB from './timelineDb.js'; import * as timelineDB from './timelineDb.js';
import * as commonDb from '../common/commonDb.js';
import { setLogLevel } from '../../diagram-api/diagramAPI.js'; import { setLogLevel } from '../../diagram-api/diagramAPI.js';
describe('when parsing a timeline ', function () { describe('when parsing a timeline ', function () {
@@ -98,5 +99,20 @@ describe('when parsing a timeline ', function () {
} }
}); });
}); });
it('TL-6 should handle a title, section, task, and events with hashtags', function () {
let str = `timeline
title #my#title#
section #a#bc-123#
task1: #ev#ent1# : #ev#ent2# : #ev#ent3#
`;
timeline.parse(str);
expect(commonDb.getDiagramTitle()).equal('#my#title#');
expect(timelineDB.getSections()).to.deep.equal(['#a#bc-123#']);
expect(timelineDB.getTasks()[0].task).equal('task1');
expect(timelineDB.getTasks()[0].events[0]).equal('#ev#ent1# ');
expect(timelineDB.getTasks()[0].events[1]).equal('#ev#ent2# ');
expect(timelineDB.getTasks()[0].events[2]).equal('#ev#ent3#');
});
}); });
}); });