How to check for valid richtext syntax? #4856
Replies: 1 comment 1 reply
-
Some people are struggling with markdown also. I guess this is one of the reasons why our wiki isn't updated regularly and github provides some markup buttons at the top of editboxes. A markdown-wlrichtext converter makes writing wlrichtext easier, but for some people it might be too complicated anyway. To make it really easy for users i think there should be some markup-buttons on top of an editbox, like e.g. github has. In the long run this would also be useful for a scenario editor to apply wlrichtext to campaign windows or objectives. For addon-comments i think wlrichtext it is not really needed. At least for now. I guess most comments will be of type:
The ability to apply newlines should be enough for now, imho. |
Beta Was this translation helpful? Give feedback.
-
Is there a way to determine whether a string is valid Widelands richtext without actually rendering it?
Currently I'm testing it by rendering the text (
UI::g_fh->render(my_text, 500);
) and checking whether an exception is thrown.This has several disadvantages: It's slow; it causes large memory leaks if there really are invalid tags (which can be expected to be the case quite often); and sometimes it prints masses of undesired logs and sometimes even segfaults if I pass extremely weird data. Is there a better way?
Background: In my https://github.com/Noordfrees/widelands/tree/addons-webserver branch, which is 99% complete, I'm just polishing the UI to write comments about add-ons, and it comes with a preview pane that shows the user what his text will look like:
If there is no way to check this, an alternative would be to implement a simple markdown-to-richtext converter that interprets the user's comment as markdown and generates guaranteed valid richtext… but I'd rather keep it simple :)
Or should I do this anyway, since markup is easier to write than Widelands richtext?
Beta Was this translation helpful? Give feedback.
All reactions