Page MenuHomePhabricator

Implement efl2_text_serializer_markup.eo
Open, Incoming QueuePublic


It should parse markup and insert the text / annotations to the canvas text object.
It's a stricter XML-like variant as described in the original proposal, with the only allowed tags at the moment being: <span> <item>, <a>, <ps> and <br>. For compatibility this should also allow </> as a generic tag closer.

It should just use the public cursor and attribute APIs, though should be sufficient.

It's essentially mostly a copy-paste from textblock.c and just passes the format strings directly to textblock to process, it doesn't actually need to validate the properties themselves.

I'm not sure if it's any good, but there's eina_xml that could help with parsing.

It should be strict, as I said, so should no longer allow <font=12> it should be a span if that is what's wanted.

Also make sure to take the new annotation ephemeral property into account. Those with this set to true should not be serialized as they are just temporary decorations and not part of the content.

tasn created this task.Sep 9 2019, 11:24 AM
zmike added a comment.Sep 16 2019, 8:16 AM

Is there a reason why this needs to be efl2 if the original efl_text_markup has not been stabilized (T7858)? You can just rework/reuse the existing API.

tasn added a comment.Sep 16 2019, 1:30 PM

It's all going to be named efl_text_markup in the end. It's just so we have everything in parallel in a branch so we don't have to battle with what's already there until everything is stable, and then we can just sed everything to be efl_.

tasn added a comment.Oct 3 2019, 6:43 AM

I renamed it (per @zmike's comment) to something that makes more sense. It'll sit there with other serializers under this namespace.

It's also now ready to be implemented. It should just parse and validate the tags to just be balanced <> and etc, no need for a deep understanding of how textblock works.

It should then call a stub (not yet implemented, we'll replace it once it is): _attribute_insert(cur_start, cur_end, tag_name: string, attributes: string) where tag name would be for example span and attributes for example font_size=12 font_weight=bold. It should just insert text using normal cursor functions and it should translate &nbsp; and the likes like it currently does.

I hope this is clear.

zmike added a comment.Oct 4 2019, 7:42 AM

I think there's some value in exploring having a general text style string creating/parsing API (possibly in eina) for handling this more clearly. For "standardized" attributes, there can be explicit wrapper functions to get/set the values on the string context to make it easier for users to access instead of the historical "you just have to know this" methodology.

Everything you've said here sounds good though.

tasn added a comment.Oct 7 2019, 5:29 AM

I don't think so, but maybe? I don't think it's useful in relation to using text API, though if we want to add this generic utility function for whatever other reason, then we can.

Currently, just setting the values correctly is a matter of doing: eina_strbuf_append_printf(strbuf, "font_size=%d font_weight=%s", size, weight), and in most cases, people will just have an hardcoded string anyway.

tasn renamed this task from Implement efl2_text_markup.eo to Implement efl2_text_serializer_markup.eo.Oct 10 2019, 2:23 AM
tasn updated the task description. (Show Details)

Updated the description.

tasn reassigned this task from tasn to woohyun.Oct 12 2019, 7:34 AM
tasn updated the task description. (Show Details)Oct 12 2019, 7:39 AM