mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-23 09:20:03 +02:00
Added <a href> and callback functionality to gantt diagrams
This commit is contained in:
@@ -7,23 +7,38 @@
|
||||
|
||||
%options case-insensitive
|
||||
|
||||
%{
|
||||
// Pre-lexer code can go here
|
||||
%}
|
||||
|
||||
/* string is used to detect blocks that are surrounded by double quotes. */
|
||||
/* copied from /src/diagrams/flowchart/parser/flow.jison */
|
||||
%x string
|
||||
/* a valid callback looks like this: callback(example_callback_arg) */
|
||||
/* callback prefix: callback( */
|
||||
/* callback suffix: ) */
|
||||
%x callback
|
||||
%x callbackname
|
||||
%%
|
||||
|
||||
[\n]+ return 'NL';
|
||||
\s+ /* skip whitespace */
|
||||
\#[^\n]* /* skip comments */
|
||||
\%%[^\n]* /* skip comments */
|
||||
/* Strings are used to detect tooltips */
|
||||
["] this.begin("string");
|
||||
<string>["] this.popState();
|
||||
<string>[^"]* return 'STR';
|
||||
"call"\s this.begin("callbackname");
|
||||
<callbackname>\( this.popState(); this.begin("callback");
|
||||
<callbackname>[^(]+ return 'callbackname';
|
||||
<callback>[)] this.popState();
|
||||
<callback>[^)]* return 'callbackarguments';
|
||||
|
||||
"click" return 'click';
|
||||
"gantt" return 'gantt';
|
||||
"dateFormat"\s[^#\n;]+ return 'dateFormat';
|
||||
"axisFormat"\s[^#\n;]+ return 'axisFormat';
|
||||
\d\d\d\d"-"\d\d"-"\d\d return 'date';
|
||||
"title"\s[^#\n;]+ return 'title';
|
||||
"section"\s[^#:\n;]+ return 'section';
|
||||
[^#:\n;]+ return 'taskTxt';
|
||||
[^#:()\n;]+ return 'taskTxt';
|
||||
":"[^#\n;]+ return 'taskData';
|
||||
":" return ':';
|
||||
<<EOF>> return 'EOF';
|
||||
@@ -58,7 +73,13 @@ statement
|
||||
| 'axisFormat' {yy.setAxisFormat($1.substr(11));$$=$1.substr(11);}
|
||||
| title {yy.setTitle($1.substr(6));$$=$1.substr(6);}
|
||||
| section {yy.addSection($1.substr(8));$$=$1.substr(8);}
|
||||
| clickStatement
|
||||
| taskTxt taskData {yy.addTask($1,$2);$$='task';}
|
||||
;
|
||||
|
||||
clickStatement
|
||||
: click callbackname callbackarguments {$$ = $1;yy.setClickEvent($2, $3);}
|
||||
| click STR callbackname callbackarguments {$$ = $1;yy.setLink($2);yy.setClickEvent($3, $4);}
|
||||
| click STR {$$ = $1;yy.setLink($2);}
|
||||
;
|
||||
%%
|
||||
|
Reference in New Issue
Block a user