After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 679299 - Allow incrementally parsing pango markup
Allow incrementally parsing pango markup
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: pango-maint
pango-maint
Depends on:
Blocks:
 
 
Reported: 2012-07-03 03:18 UTC by Jasper St. Pierre (not reading bugmail)
Modified: 2012-12-14 18:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
markup: Always start with a <markup> tag (1.98 KB, patch)
2012-07-03 03:18 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
markup: Allow incrementally parsing pango markup (10.37 KB, patch)
2012-07-03 03:18 UTC, Jasper St. Pierre (not reading bugmail)
none Details | Review
markup: Allow incrementally parsing pango markup (12.49 KB, patch)
2012-07-03 17:08 UTC, Jasper St. Pierre (not reading bugmail)
none Details | Review
markup: Allow incrementally parsing pango markup (11.58 KB, patch)
2012-07-03 17:20 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
markup: Remove error from markup parser constructor (2.01 KB, patch)
2012-12-14 18:02 UTC, Jasper St. Pierre (not reading bugmail)
none Details | Review
markup: Remove error from markup parser constructor (2.88 KB, patch)
2012-12-14 18:04 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review

Description Jasper St. Pierre (not reading bugmail) 2012-07-03 03:18:26 UTC
See patches. This is designed to be used with g_input_stream_read
and other things. Perhaps the API isn't the best -- suggestions and
other comments appreciated.
Comment 1 Jasper St. Pierre (not reading bugmail) 2012-07-03 03:18:28 UTC
Created attachment 217899 [details] [review]
markup: Always start with a <markup> tag

It doesn't do anything bad, and will help us when we move to a stream-based
approach.
Comment 2 Jasper St. Pierre (not reading bugmail) 2012-07-03 03:18:31 UTC
Created attachment 217900 [details] [review]
markup: Allow incrementally parsing pango markup

This is intended for applications that need to parse pango
markup from some sort of GIO stream.
Comment 3 Behdad Esfahbod 2012-07-03 11:43:40 UTC
(In reply to comment #1)
> Created an attachment (id=217899) [details] [review]
> markup: Always start with a <markup> tag
> 
> It doesn't do anything bad

Doesn't it now reject markup that actually has a markup tag?
Comment 4 Jasper St. Pierre (not reading bugmail) 2012-07-03 15:09:41 UTC
(In reply to comment #3)
> (In reply to comment #1)
> > Created an attachment (id=217899) [details] [review] [details] [review]
> > markup: Always start with a <markup> tag
> > 
> > It doesn't do anything bad
> 
> Doesn't it now reject markup that actually has a markup tag?

Why would it? It would become <markup><markup>Foo</markup></markup>, which isn't invalid to the parser, and the start/end tag handlers don't change any state, so it's a noop.
Comment 5 Behdad Esfahbod 2012-07-03 15:11:40 UTC
I see.  Well, that's weird, but fine.

Are you going to use this in an application?
Comment 6 Jasper St. Pierre (not reading bugmail) 2012-07-03 15:14:36 UTC
Yes.
Comment 7 Behdad Esfahbod 2012-07-03 15:43:19 UTC
Feel free to commit after adding proper "Since" tags and hooking up in documentation.
Comment 8 Jasper St. Pierre (not reading bugmail) 2012-07-03 15:44:49 UTC
"Hooking up in documentation"?
Comment 9 Behdad Esfahbod 2012-07-03 15:46:39 UTC
Add to docs/pango-sections.txt
Comment 10 Jasper St. Pierre (not reading bugmail) 2012-07-03 15:49:25 UTC
I did that in the attached patch, no?
Comment 11 Jasper St. Pierre (not reading bugmail) 2012-07-03 15:50:42 UTC
Additionally, I'm not the biggest fan of the API right now -- GMarkup isn't intropsection-friendly. Do you think we want a PangoMarkupParser * that you explicitly create, call _parse() on, and free?
Comment 12 Behdad Esfahbod 2012-07-03 15:58:18 UTC
> Additionally, I'm not the biggest fan of the API right now -- GMarkup isn't
> intropsection-friendly. Do you think we want a PangoMarkupParser * that you
> explicitly create, call _parse() on, and free?


I really like reusing GMarkupParseContext here.  Though, we should have a GMarkupParser API too, such that apps (say, The GIMP, etc) can push that onto a ParseContext.

I remember we had this discussion before, but can't find it.  Agree that the API needs more work.  CC'ing a few.
Comment 13 Jasper St. Pierre (not reading bugmail) 2012-07-03 16:52:07 UTC
I guess one thing I'm not a fan of right now is the _finish method. It returns a boolean variable and an error, but there's not much you can do with it, as the context has been freed. Maybe we should explicitly split up _free and _finish?
Comment 14 Jasper St. Pierre (not reading bugmail) 2012-07-03 17:08:57 UTC
Created attachment 217949 [details] [review]
markup: Allow incrementally parsing pango markup

This is intended for applications that need to parse pango
markup from some sort of GIO stream.



OK, I'm *much* more happy with this. After calling pango_markup_parser_finish,
you are supposed to call g_markup_parse_context_free. This makes it consistent
with the rest of our stack, and gives you a change to handle an error when
finishing before everything is cleared for you. It also removes a lot of other
dirty code.
Comment 15 Jasper St. Pierre (not reading bugmail) 2012-07-03 17:20:34 UTC
Created attachment 217950 [details] [review]
markup: Allow incrementally parsing pango markup

This is intended for applications that need to parse pango
markup from some sort of GIO stream.



Restore the memory efficiency in the pango_parse_markup case where
we have a NULL attr_list out pointer, and restore some accidentally
removed invariant checks.
Comment 16 Jasper St. Pierre (not reading bugmail) 2012-12-12 09:58:37 UTC
Ping on this?
Comment 17 Behdad Esfahbod 2012-12-13 22:14:35 UTC
LGTM.  The only thing I don't like is that the constructor function can return an error.  Also, Perhaps it should really return a subclass of GMarkupParserContext.  Oh wait, you said that's not a true GObject I think.  In which case the current patch is fine.
Comment 18 Jasper St. Pierre (not reading bugmail) 2012-12-14 07:06:01 UTC
Attachment 217899 [details] pushed as 25d4222 - markup: Always start with a <markup> tag
Attachment 217950 [details] pushed as 29020c7 - markup: Allow incrementally parsing pango markup
Comment 19 Behdad Esfahbod 2012-12-14 17:25:04 UTC
Thanks.  Still like to see the error be dropped from the constructor...
Comment 20 Jasper St. Pierre (not reading bugmail) 2012-12-14 18:02:43 UTC
Created attachment 231579 [details] [review]
markup: Remove error from markup parser constructor
Comment 21 Jasper St. Pierre (not reading bugmail) 2012-12-14 18:04:21 UTC
Created attachment 231580 [details] [review]
markup: Remove error from markup parser constructor
Comment 22 Jasper St. Pierre (not reading bugmail) 2012-12-14 18:13:20 UTC
Comment on attachment 231580 [details] [review]
markup: Remove error from markup parser constructor

Attachment 231580 [details] pushed as 7908fa2 - markup: Remove error from markup parser constructor