Closed tg-m closed 2 years ago
Thanks!
Please let me some time to review this patch. I believe this is a good thing to add.
Thank you!
I am also thinking about an alternative syntax:
A->B: |
This is
a multiline string
similar to YAML: https://yaml-multiline.info/
TBH, my first impression was to abandon the custom grammar and switch to YAML, but I needed multi-line support quite fast, thus the patch.
Also... I think there is an issue with the Sequence grammar definition. It does not handle colons (:
) in message text / label correctly.
YAML will give far more flexibility, but it's somewhat verbose... I had something like below in my mind, when I was looking at the grammar.
nodes:
- &ref_alice
name: Alice
- &ref_bob
name: Bob
- &ref_charlie
name: Charlie
messages:
- from: *ref_alice
to: *ref_bob
label: "Hello Alice! It's me, Bob."
- from: *ref_bob
to: *ref_charlie
label: |-
A label with...
Not only one or two lines.
Not even three!
But four! :)
options:
message-arrow-ending: triangle
node-style:
- name
- label
nodes:
- &ref_alice
label: "Alice node"
name: A
rotate: 90
- &ref_bob
label: "Bob"
name: B
- &ref_charlie
label: "Charlie"
name: C
node-style:
- label
messages:
- from: *ref_alice
to: *ref_bob
label: "Hello Alice! It's me, Bob."
align: left
order: 11
message-arrow-ending: square ## custom arrow ending
- from: *ref_bob
to: *ref_charlie
label: |-
A label with...
Not only one or two lines.
Not even three!
But four! :)
align: centre ## or center for US speakers ;)
order: 2
## message-arrow-ending: triangle ## defaults to what is in options
Sorry, I didn't meant switching toward yaml. I just meant updating the syntax, so that we can use something similar to YAML multiline strings.
Yes, I was aware of that. After a little bit of sleep, I think that your grammar is more concise than YAML, thus better in this case.
It would be nice to have support for |
, |-
and |+
variants of YAML's |
. See, e.g., https://yaml-multiline.info/. (Added: Oh, you've already pasted that link, I missed that...)
When using
diagon Sequence
it is not possible (at least I couldn't find a way) to add new lines to the messages in the Sequence submodule.This patch adds parameter
--new_lines_at_bsn
that results in substituting literal\n
with new lines.Example:
output: