GraphObjects.md: [ and ] should be escaped in text (they're links otherwise)
flow.jison: fixed a parsing issue when the direction is omitted (defaults to 'TB')
stateRenderer-v2: was silently failing due to a try/catch in the parse function. (intentional?) removed to show errorHandler
mermaidAPI: removed unnecessary call to updateRendererConfigs since reinitialize does this
This commit is contained in:
chris moran
2020-07-28 04:44:38 -04:00
parent 0299ff0a79
commit 283faf7a2f
4 changed files with 20 additions and 13 deletions

View File

@@ -113,8 +113,8 @@ Required edgeData for proper rendering:
| label | overlap between label and labelText? | | label | overlap between label and labelText? |
| labelPos | | | labelPos | |
| labelType | overlap between label and labelText? | | labelType | overlap between label and labelText? |
| thickness | Sets the thinkess of the edge. Can be ['normal', 'thick'] | | thickness | Sets the thinkess of the edge. Can be \['normal', 'thick'\] |
| pattern | Sets the pattern of the edge. Can be ['solid', 'dotted', 'dashed'] | | pattern | Sets the pattern of the edge. Can be \['solid', 'dotted', 'dashed'\] |
# Markers # Markers
@@ -122,7 +122,7 @@ Required edgeData for proper rendering:
Define what markers that should be included in the diagram with the insert markers function. The function takes two arguments, first the element in which the markers should be included and a list of the markers that should be added. Define what markers that should be included in the diagram with the insert markers function. The function takes two arguments, first the element in which the markers should be included and a list of the markers that should be added.
Ex: Ex:
insertMarkers(el, ['point', 'circle']) insertMarkers(el, \['point', 'circle'\])
The example above adds the markers point and cross. This means that edges with the arrowTypes arrow_cross, double_arrow_cross, arrow_point and double_arrow_cross will get the corresponding markers but arrowType arrow_cross will have no impact. The example above adds the markers point and cross. This means that edges with the arrowTypes arrow_cross, double_arrow_cross, arrow_point and double_arrow_cross will get the corresponding markers but arrowType arrow_cross will have no impact.
@@ -136,4 +136,4 @@ Current markers:
# Common functions used by the renderer to be implemented by the Db # Common functions used by the renderer to be implemented by the Db
getDirection getDirection
getClasses getClasses

View File

@@ -6,10 +6,15 @@
/* lexical grammar */ /* lexical grammar */
%lex %lex
%options case-insensitive
%x string %x string
%x dir %x dir
%x vertex %x vertex
%x open_directive type_directive arg_directive %x open_directive
%x type_directive
%x arg_directive
%x close_directive
%% %%
\%\%\{ { this.begin('open_directive'); return 'open_directive'; } \%\%\{ { this.begin('open_directive'); return 'open_directive'; }
@@ -33,6 +38,7 @@
"flowchart" {if(yy.lex.firstGraph()){this.begin("dir");} return 'GRAPH';} "flowchart" {if(yy.lex.firstGraph()){this.begin("dir");} return 'GRAPH';}
"subgraph" return 'subgraph'; "subgraph" return 'subgraph';
"end"\b\s* return 'end'; "end"\b\s* return 'end';
<dir>[^\n\s]* { this.popState(); }
<dir>\s*"LR" { this.popState(); return 'DIR'; } <dir>\s*"LR" { this.popState(); return 'DIR'; }
<dir>\s*"RL" { this.popState(); return 'DIR'; } <dir>\s*"RL" { this.popState(); return 'DIR'; }
<dir>\s*"TB" { this.popState(); return 'DIR'; } <dir>\s*"TB" { this.popState(); return 'DIR'; }
@@ -187,7 +193,7 @@
"{" return 'DIAMOND_START' "{" return 'DIAMOND_START'
"}" return 'DIAMOND_STOP' "}" return 'DIAMOND_STOP'
"\"" return 'QUOTE'; "\"" return 'QUOTE';
(\r|\n|\r\n)+ return 'NEWLINE'; (\r?\n)+ return 'NEWLINE';
\s return 'SPACE'; \s return 'SPACE';
<<EOF>> return 'EOF'; <<EOF>> return 'EOF';
@@ -233,8 +239,10 @@ directive
graphConfig graphConfig
: SPACE graphConfig : SPACE graphConfig
| NEWLINE graphConfig | NEWLINE graphConfig
| GRAPH FirstStmtSeperator
{ console.log('GRAPH FirstStmtSeperator');yy.setDirection('TB');$$ = 'TB';}
| GRAPH DIR FirstStmtSeperator | GRAPH DIR FirstStmtSeperator
{ yy.setDirection($2);$$ = $2;} { console.log('GRAPH DIR FirstStmtSeperator');yy.setDirection($2);$$ = $2;}
// | GRAPH SPACE TAGEND FirstStmtSeperator // | GRAPH SPACE TAGEND FirstStmtSeperator
// { yy.setDirection("LR");$$ = $3;} // { yy.setDirection("LR");$$ = $3;}
// | GRAPH SPACE TAGSTART FirstStmtSeperator // | GRAPH SPACE TAGSTART FirstStmtSeperator

View File

@@ -211,11 +211,11 @@ export const draw = function(text, id) {
parser.yy = stateDb; parser.yy = stateDb;
// Parse the graph definition // Parse the graph definition
try { // try {
parser.parse(text); parser.parse(text);
} catch (err) { // } catch (err) {
logger.debug('Parsing failed'); // logger.error('Parsing failed', err);
} // }
// Fetch the default direction, use TD if none was found // Fetch the default direction, use TD if none was found
let dir = stateDb.getDirection(); let dir = stateDb.getDirection();

View File

@@ -205,7 +205,6 @@ const render = function(id, _txt, cb, container) {
} else { } else {
configApi.reset(); configApi.reset();
const siteConfig = getSiteConfig(); const siteConfig = getSiteConfig();
updateRendererConfigs(siteConfig);
reinitialize(siteConfig); reinitialize(siteConfig);
} }