-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for new lines in Sequence #40
Add support for new lines in Sequence #40
Conversation
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: ```bash $ echo "Alice -> Bob: send(\n msg="Hello...",\n length=8,\n)" | \ diagon Sequence --new_lines_at_bsn=true ``` output: ``` ┌─────┐ ┌───┐ │Alice│ │Bob│ └──┬──┘ └─┬─┘ │ │ │send( │ │ msg=Hello...,│ │ length=8, │ │) │ │──────────────>│ ┌──┴──┐ ┌─┴─┐ │Alice│ │Bob│ └─────┘ └───┘ ```
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 ( 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. Basicnodes:
- &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! :) More detailedoptions:
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 |
When using
diagon Sequence
it is not possible (at least I couldn'tfind a way) to add new lines to the messages in the Sequence submodule.
This patch adds parameter
--new_lines_at_bsn
that results insubstituting literal
\n
with new lines.Example:
output: