mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-14 09:44:51 +01:00
Merge pull request #1229 from mermaid-js/bug/1217_fix_for_keyword_as_in_stateDiagram
#1217 Better matching of words beginning with as as matching token
This commit is contained in:
@@ -275,11 +275,12 @@ mermaidAPI.initialize({
|
|||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
- `id` the id of the element to be rendered
|
- `id` the id of the element to be rendered
|
||||||
- `txt` the graph definition
|
- `_txt`
|
||||||
- `cb` callback which is called after rendering is finished with the svg code as inparam.
|
- `cb` callback which is called after rendering is finished with the svg code as inparam.
|
||||||
- `container` selector to element in which a div with the graph temporarily will be inserted. In one is
|
- `container` selector to element in which a div with the graph temporarily will be inserted. In one is
|
||||||
provided a hidden div will be inserted in the body of the page instead. The element will be removed when rendering is
|
provided a hidden div will be inserted in the body of the page instead. The element will be removed when rendering is
|
||||||
completed.
|
completed.
|
||||||
|
- `txt` the graph definition
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
<STATE>.*"[[fork]]" {this.popState();yytext=yytext.slice(0,-8).trim();/*console.warn('Fork Fork: ',yytext);*/return 'FORK';}
|
<STATE>.*"[[fork]]" {this.popState();yytext=yytext.slice(0,-8).trim();/*console.warn('Fork Fork: ',yytext);*/return 'FORK';}
|
||||||
<STATE>.*"[[join]]" {this.popState();yytext=yytext.slice(0,-8).trim();/*console.warn('Fork Join: ',yytext);*/return 'JOIN';}
|
<STATE>.*"[[join]]" {this.popState();yytext=yytext.slice(0,-8).trim();/*console.warn('Fork Join: ',yytext);*/return 'JOIN';}
|
||||||
<STATE>["] this.begin("STATE_STRING");
|
<STATE>["] this.begin("STATE_STRING");
|
||||||
<STATE>"as"\s* {this.popState();this.pushState('STATE_ID');return "AS";}
|
<STATE>\s*"as"\s+ {this.popState();this.pushState('STATE_ID');return "AS";}
|
||||||
<STATE_ID>[^\n\{]* {this.popState();/* console.log('STATE_ID', yytext);*/return "ID";}
|
<STATE_ID>[^\n\{]* {this.popState();/* console.log('STATE_ID', yytext);*/return "ID";}
|
||||||
<STATE_STRING>["] this.popState();
|
<STATE_STRING>["] this.popState();
|
||||||
<STATE_STRING>[^"]* { /*console.log('Long description:', yytext);*/return "STATE_DESCR";}
|
<STATE_STRING>[^"]* { /*console.log('Long description:', yytext);*/return "STATE_DESCR";}
|
||||||
|
|||||||
@@ -53,6 +53,39 @@ describe('state diagram, ', function() {
|
|||||||
|
|
||||||
parser.parse(str);
|
parser.parse(str);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('handle "as" in state names', function() {
|
||||||
|
const str = `stateDiagram
|
||||||
|
assemble
|
||||||
|
state assemble
|
||||||
|
`;
|
||||||
|
|
||||||
|
parser.parse(str);
|
||||||
|
});
|
||||||
|
it('handle "as" in state names 1', function() {
|
||||||
|
const str = `stateDiagram
|
||||||
|
assemble
|
||||||
|
state assemble
|
||||||
|
`;
|
||||||
|
|
||||||
|
parser.parse(str);
|
||||||
|
});
|
||||||
|
it('handle "as" in state names 2', function() {
|
||||||
|
const str = `stateDiagram
|
||||||
|
assembleas
|
||||||
|
state assembleas
|
||||||
|
`;
|
||||||
|
|
||||||
|
parser.parse(str);
|
||||||
|
});
|
||||||
|
it('handle "as" in state names 3', function() {
|
||||||
|
const str = `stateDiagram
|
||||||
|
state "as" as as
|
||||||
|
`;
|
||||||
|
|
||||||
|
parser.parse(str);
|
||||||
|
});
|
||||||
|
|
||||||
it('scale', function() {
|
it('scale', function() {
|
||||||
const str = `stateDiagram\n
|
const str = `stateDiagram\n
|
||||||
scale 350 width
|
scale 350 width
|
||||||
|
|||||||
Reference in New Issue
Block a user