michael-buschbeck / mychs-macro-magic

A simple, sane, and friendly little scripting language for your Roll20 macros.
MIT License
1 stars 1 forks source link

Support line breaks in chat messages #21

Closed michael-buschbeck closed 3 years ago

michael-buschbeck commented 3 years ago

Support adding line breaks to chat messages. (Roll20's API supports <br> in sendChat() messages.)

michael-buschbeck commented 3 years ago

This leaves the question how to specify a line break in a chat message.

It would have to be something that isn't stripped by Roll20 before the message even gets to MMM, i.e. it can't be HTML <br>.

Observation: Especially with "!mmm combine chat" existing, it seems unlikely it'll be necessary to add line breaks anywhere else than at the end of a "!mmm chat: ..." command. Maybe parametrize "chat:" somehow to say "...with a line break between this and the next chat: segment".

michael-buschbeck commented 3 years ago

...or Markdown-style – just leave an empty chat line where you want your line break:

Line Command
1 !mmm combine chat
2 !mmm     chat: first paragraph
3 !mmm     chat:
4 !mmm     chat: second paragraph
5 !mmm end combine

produces:

Finn: first paragraph
second paragraph

(That would have to be a line that's syntactically empty, not one that just happens to produce no output.)

michael-buschbeck commented 3 years ago

For what it's worth, if you sneak a <br> past Roll20's chat line parser, you can already do that now:

Line Command
1 !mmm chat: first paragraph${"<"}br>second paragraph

No, not winning any beauty contests with that one.

Slightly more polished:

Line Command
1 !mmm script
2 !mmm     set BR = "<" & "br>"
3 !mmm     chat: first paragraph${BR}second paragraph${BR}third paragraph
4 !mmm end script
michael-buschbeck commented 3 years ago

Heh, I just realized that this is truly a backwards-compatible change since chat: without anything behind it is currently a syntax error. Yay!

michael-buschbeck commented 3 years ago

I've also realized that only <br/> makes actual sense as the result of an empty chat: line – not \n because that just splits the line into several chat messages (and there's an easier way to achieve that already).