diff --git a/.changeset/flat-plants-joke.md b/.changeset/flat-plants-joke.md new file mode 100644 index 00000000..a9c282d0 --- /dev/null +++ b/.changeset/flat-plants-joke.md @@ -0,0 +1,7 @@ +--- +'@pintora/diagrams': patch +'@pintora/cli': patch +'@pintora/standalone': patch +--- + +feat: [activity] support quoted word as action message diff --git a/packages/pintora-diagrams/src/activity/__tests__/activity-parser.spec.js b/packages/pintora-diagrams/src/activity/__tests__/activity-parser.spec.js index c80150df..930ca3d0 100644 --- a/packages/pintora-diagrams/src/activity/__tests__/activity-parser.spec.js +++ b/packages/pintora-diagrams/src/activity/__tests__/activity-parser.spec.js @@ -712,4 +712,14 @@ repeatwhile (data available) is (yes) not (no) const ir = db.getDiagramIR() expect(ir.title).toEqual('Hello') }) + + it('can parse quoted word in action', () => { + const example = stripStartEmptyLines(` + activityDiagram + :"for (var i = 0; i <= n; i++)"; + `) + parse(example) + const ir = db.getDiagramIR() + expect(ir.steps[0].value.message).toEqual('for (var i = 0; i <= n; i++)') + }) }) diff --git a/packages/pintora-diagrams/src/activity/parser/activityDiagram.ne b/packages/pintora-diagrams/src/activity/parser/activityDiagram.ne index f35d9ab3..370662de 100644 --- a/packages/pintora-diagrams/src/activity/parser/activityDiagram.ne +++ b/packages/pintora-diagrams/src/activity/parser/activityDiagram.ne @@ -261,9 +261,16 @@ oneLineAction -> %} multilineText -> - (%VALID_TEXT|%WS|%NL):* {% + %QUOTED_WORD {% function(d) { - // console.log('[multiline text]', d) + const ele = d[0] + return getQuotedWord(ele) + } + %} + | (%VALID_TEXT|%WS|%NL):* {% + function(d) { + const ele = d[0] + // console.log('[multiline text]', ele) const v = d[0].map(l => { return l.map(o => tv(o)) }).join('')