Merge pull request #5335 from FutzMonitor/4175Issue-allowSemicolons

Allow Semicolons in Timeline Titles, Sections, Periods, and Events
This commit is contained in:
Sidharth Vinod
2024-08-20 09:07:17 +00:00
committed by GitHub
2 changed files with 37 additions and 15 deletions

View File

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

View File

@@ -1,7 +1,7 @@
import { setLogLevel } from '../../diagram-api/diagramAPI.js';
import * as commonDb from '../common/commonDb.js';
import { parser as timeline } from './parser/timeline.jison';
import * as timelineDB from './timelineDb.js';
import * as commonDb from '../common/commonDb.js';
import { setLogLevel } from '../../diagram-api/diagramAPI.js';
describe('when parsing a timeline ', function () {
beforeEach(function () {
@@ -10,7 +10,7 @@ describe('when parsing a timeline ', function () {
setLogLevel('trace');
});
describe('Timeline', function () {
it('TL-1 should handle a simple section definition abc-123', function () {
it('should handle a simple section definition abc-123', function () {
let str = `timeline
section abc-123`;
@@ -18,7 +18,7 @@ describe('when parsing a timeline ', function () {
expect(timelineDB.getSections()).to.deep.equal(['abc-123']);
});
it('TL-2 should handle a simple section and only two tasks', function () {
it('should handle a simple section and only two tasks', function () {
let str = `timeline
section abc-123
task1
@@ -30,7 +30,7 @@ describe('when parsing a timeline ', function () {
});
});
it('TL-3 should handle a two section and two coressponding tasks', function () {
it('should handle a two section and two coressponding tasks', function () {
let str = `timeline
section abc-123
task1
@@ -51,7 +51,7 @@ describe('when parsing a timeline ', function () {
});
});
it('TL-4 should handle a section, and task and its events', function () {
it('should handle a section, and task and its events', function () {
let str = `timeline
section abc-123
task1: event1
@@ -75,7 +75,7 @@ describe('when parsing a timeline ', function () {
});
});
it('TL-5 should handle a section, and task and its multi line events', function () {
it('should handle a section, and task and its multi line events', function () {
let str = `timeline
section abc-123
task1: event1
@@ -100,7 +100,25 @@ describe('when parsing a timeline ', function () {
});
});
it('TL-6 should handle a title, section, task, and events with hashtags', function () {
it('should handle a title, section, task, and events with semicolons', function () {
let str = `timeline
title ;my;title;
section ;a;bc-123;
;ta;sk1;: ;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].events).toMatchInlineSnapshot(`
[
";ev;ent1; ",
";ev;ent2; ",
";ev;ent3;",
]
`);
});
it('should handle a title, section, task, and events with hashtags', function () {
let str = `timeline
title #my#title#
section #a#bc-123#
@@ -110,9 +128,13 @@ describe('when parsing a timeline ', function () {
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#');
expect(timelineDB.getTasks()[0].events).toMatchInlineSnapshot(`
[
"#ev#ent1# ",
"#ev#ent2# ",
"#ev#ent3#",
]
`);
});
});
});