rexrainbow / phaser3-rex-notes

Notes of phaser3 engine
MIT License
1.21k stars 260 forks source link

It would be really nice to be able to exclude user-made messages from BBCode. #249

Closed rexrainbow closed 2 years ago

rexrainbow commented 2 years ago

It would be really nice to be able to exclude user-made messages from BBCode.

For example:

A message with [b]BBCode[/b] and an [esc][b]escaped message[/b][/esc].

would output:

A message with BBCode and an [b]escaped message[/b].

Just an example, maybe it can be done differently.

Originally posted by @robinheidrich in https://github.com/rexrainbow/phaser3-rex-notes/discussions/247

rexrainbow commented 2 years ago

rexBBCodeText : Add escape tags. Tags between [esc] ... [/esc] or [raw] ... [/raw] will be treated as content.

Demo

rexrainbow commented 2 years ago

@robinheidrich

robinheidrich commented 2 years ago

This is perfect, thank you!

robinheidrich commented 2 years ago

@rexrainbow Would it also be possible for escaping to stop only at the last [/esc] or [/raw]? Otherwise user-made messages could also contain [/esc] and stop escaping.

As an example: I use [esc]${message}[/esc] and the message contains [/esc] whereupon escaping stops and BBCode is formatted again.

rexrainbow commented 2 years ago

Don't have plan for this feature.

You might use [raw]${message}[/raw] to escape content, and left [esc], [/esc] tags for user.

rexrainbow commented 2 years ago

Let me explain more detail. BBCodeText class will parse content from start. It can't know tags after current tag. Thus I can't determinate current [/esc] is last [/esc] or not.

robinheidrich commented 2 years ago

That's a shame, then I guess I'll have to block [ and ] in general for user-made messages.

If this is ever planned, it would be very helpful especially for this BBCode tag!

rexrainbow commented 2 years ago

I tried to implement escape by adding ~ before ], like [b~]....[/b~]. It worked well excepted text-typing, text-paging, and text-scrolling. Thus I did not use this solution.