Let’s assume I have a custom lang.def file for GtkSourceView that defines a RegEx which renders *some bold text* as * some bold text* . Is it possible to hide the two ‘*’ while keeping some bold text being displayed bold? I want to be able to hide/show all defined markup elements thus making the document more readable (sort of View mode)…
Alternatively, instead of using GtkSourceView, you can write your own parser that apply GtkTextTags to your text. It’s much more flexible, as much more text properties are covered by tags.
What would be faster / easier - try to add invisible property to GtkSourceView style or to write a custom parser for a Markdown-like syntax and use GtkTextTags with regular GtkTextView?
Is there a way to obtain start/end iters of all the context id="asterisks-emphasis" parts found by GtkSourceView instead of writing own parser? I’d then use those iters with GtkTextTag to set extra properties on those parts of text…
Do you have some sample examples of such parsers integrated into GtkTextView?
Is it a good idea to use GLib MarkupParser to implement a Markdown-like syntax? (I saw that at least in the past it was used only for XML markup).
GtkSourceView was designed for code highlighting, it’s not adapted for advanced text formatting like you’re trying to do. I would try to avoid it, you’ll quickly end up in dead-end for more complex things.
Not really… There are APIs like gtk_text_iter_forward_to_tag_toggle() to find the start/end of a specific tag, but tags created by sourceview have no names so can’t be easily retrieved from the table…
No, sorry… Usually for markup viewing most people would go with html for rendering, as converters for html already exist. For new languages, maybe try to search if someone already wrote some kind of converter, that could help.
GLib.MarkupParser is for XML-like only. If you want to stick with GLib, better look at GLib.Scanner instead. I’m pretty sure some advanced parsing libraries exist out there, that could be integrated in your app.