From 7803b9f794d5d6ca7671327f6b40edd66b7850a0 Mon Sep 17 00:00:00 2001 From: hikerpig Date: Sat, 3 Aug 2024 14:18:16 +0800 Subject: [PATCH] feat: [activity] support quoted word as action message --- .changeset/flat-plants-joke.md | 7 +++++++ .../src/activity/__tests__/activity-parser.spec.js | 10 ++++++++++ .../src/activity/parser/activityDiagram.ne | 11 +++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 .changeset/flat-plants-joke.md 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('')