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 758137 - GtkLabel and GtkShortcutsShortcut notes on escaping character entities don't render properly
GtkLabel and GtkShortcutsShortcut notes on escaping character entities don't ...
Status: RESOLVED FIXED
Product: gtk-doc
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: 1.26
Assigned To: gtk-doc maintainers
gtk-doc maintainers
Depends on:
Blocks:
 
 
Reported: 2015-11-15 14:27 UTC by Phillip Wood
Modified: 2016-04-12 03:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix notes on escaping character entities (2.28 KB, patch)
2015-11-15 14:28 UTC, Phillip Wood
none Details | Review
Escape entity references in markdown (1.09 KB, patch)
2015-11-15 23:53 UTC, Matthias Clasen
committed Details | Review

Description Phillip Wood 2015-11-15 14:27:27 UTC
The docs for GtkLabel render as
“literal <, > and & characters must be escaped as <, >, and &.”
when they should say
“literal <, > and & characters must be escaped as &lt;, &gt;, and &amp;.”
There is a similar problem with the GtkShortcutsShortcut docs. 

The gtk-doc wiki¹ says
“Note that we no longer interpret XML markup in text, so it is no longer necessary (and not working, either) to escape the special characters '<', '>', '()', '@', '%', or '#' as XML entities "&lt;", "&gt;", "&lpar;", "&rpar;", "&commat;", "&percnt;" and "&num;".”

So they need to be written as ‘&amp;lt;’ etc.

¹https://wiki.gnome.org/Projects/GTK%2B/DocumentationSyntax/Markdown
Comment 1 Phillip Wood 2015-11-15 14:28:06 UTC
Created attachment 315631 [details] [review]
Fix notes on escaping character entities

The docs for GtkLabel render as
“literal <, > and & characters must be escaped as <, >, and &.”
when they should say
“literal <, > and & characters must be escaped as &lt;, &gt;, and
&amp;.”
There is a similar problem with the GtkShortcutsShortcut docs.

The gtk-doc wiki¹ says

“Note that we no longer interpret XML markup in text, so it is no
longer necessary (and not working, either) to escape the special
characters '<', '>', '()', '@', '%', or '#' as XML entities "&lt;",
"&gt;", "&lpar;", "&rpar;", "&commat;", "&percnt;" and "&num;".”

So they need to be written as ‘&amp;lt;’ etc.

¹https://wiki.gnome.org/Projects/GTK%2B/DocumentationSyntax/Markdown
Comment 2 Matthias Clasen 2015-11-15 14:34:05 UTC
Note that your reference from the gtk-doc wiki contradicts what you suggesting.
Comment 3 Phillip Wood 2015-11-15 16:12:55 UTC
(In reply to Matthias Clasen from comment #2)
> Note that your reference from the gtk-doc wiki contradicts what you
> suggesting.

I'm not sure if this is a bug with gtk-doc or gtk+ as I find the wording of the wiki confusing. What I do know is that '&lt;' renders as '<' and '&amp;lt;' renders as '&lt;' If that is inconsistent with the wiki either there is a bug in gtk-doc or the wiki is wrong. Do you know what the intended behaviour of gtk-doc is?
Comment 4 Matthias Clasen 2015-11-15 23:53:45 UTC
Created attachment 315643 [details] [review]
Escape entity references in markdown

The documentation for the markdown format promises that we can
just write &foo; or <foo> in text when discussing XML. This works
for tags, but entity references such as &lt; are still expanded.
To fix this, escape all & that we find with &amp;, not just
'freestanding' ones.
Comment 5 Phillip Wood 2015-11-16 13:12:45 UTC
I've filed Bug 758175 and Bug 758174 to convert character entities into their characters for gtk and glib as they will break if gtk-doc starts to work as advertized.
Comment 6 Phillip Wood 2015-11-16 16:53:33 UTC
Review of attachment 315643 [details] [review]:

Do we want to support character entities with \&lt; in the same way that we can escape < with \< to embed xml tags?
Comment 7 Phillip Wood 2015-11-16 18:35:43 UTC
(In reply to Phillip Wood from comment #6)
> Review of attachment 315643 [details] [review] [review]:
> 
> Do we want to support character entities with \&lt; in the same way that we
> can escape < with \< to embed xml tags?

The wiki seems to say you can escape < with \< but having tried it, it doesn't work in practice the generated xml is '\&lt;' not '<'
Comment 8 Matthias Clasen 2015-11-17 11:43:40 UTC
(In reply to Phillip Wood from comment #7)
> (In reply to Phillip Wood from comment #6)
> > Review of attachment 315643 [details] [review] [review] [review]:
> > 
> > Do we want to support character entities with \&lt; in the same way that we
> > can escape < with \< to embed xml tags?
> 
> The wiki seems to say you can escape < with \< but having tried it, it
> doesn't work in practice the generated xml is '\&lt;' not '<'

The wiki is a bit unclear on that point. The \ escaping is meant only for characters that are significant in markdown (or gtk-doc extensions), not in xml. So, you can do \@, \# and \%
Comment 9 Stefan Sauer (gstreamer, gtkdoc dev) 2015-11-19 07:31:22 UTC
Review of attachment 315643 [details] [review]:

::: gtkdoc-mkdb.in
@@ +2758,2 @@
 	# First, convert freestanding & to &amp;
+        $text =~ s/&/&amp;/g;

Should we skip this if there is a '\' before the '&'?
Comment 10 Stefan Sauer (gstreamer, gtkdoc dev) 2015-11-19 07:34:05 UTC
FYI, The gtk-doc help is the authority, the wiki page is not maintained by myself. But given comment 8. I think the patch is actually right.
Comment 11 Phillip Wood 2015-11-19 14:40:30 UTC
(In reply to Stefan Sauer (gstreamer, gtkdoc dev) from comment #10)
> FYI, The gtk-doc help is the authority, the wiki page is not maintained by
> myself. But given comment 8. I think the patch is actually right.

I've just had another look at the gtk-doc help¹ and it explicitly says one *has* to use character entities for ‘<’ etc which is incorrect. The wiki is also currently incorrect in saying that character entities are not supported.

The help also says that docbook markup is supported within markdown but that does not seem to be the case. If you look at https://developer.gnome.org/glib/stable/glib-Error-Reporting.html#gerror-rules the 9th item in the list has docbook tags in the rendered output.

The help also refers readers to the wiki for details on gtk-doc’s markdown support which is confusing if the manual is the definitive reference.

I'm happy to have a go at updating the wiki one I know what is meant to be supported and what isn't.

¹https://developer.gnome.org/gtk-doc-manual/1.24/documenting_syntax.html.en
Comment 12 Phillip Wood 2015-11-19 14:44:45 UTC
(In reply to Stefan Sauer (gstreamer, gtkdoc dev) from comment #9)
> Review of attachment 315643 [details] [review] [review]:
> 
> ::: gtkdoc-mkdb.in
> @@ +2758,2 @@
>  	# First, convert freestanding & to &amp;
> +        $text =~ s/&/&amp;/g;
> 
> Should we skip this if there is a '\' before the '&'?

That might be useful if the source does not use utf8 (e.g. wants/needs to be restricted to ascii for some reason) but using the real character is more in keeping with the markdown’s aim of readable source code.
Comment 13 Phillip Wood 2015-11-19 14:45:59 UTC
(In reply to Matthias Clasen from comment #8)
> (In reply to Phillip Wood from comment #7)
> > (In reply to Phillip Wood from comment #6)
> > > Review of attachment 315643 [details] [review] [review] [review] [review]:
> > > 
> > > Do we want to support character entities with \&lt; in the same way that we
> > > can escape < with \< to embed xml tags?
> > 
> > The wiki seems to say you can escape < with \< but having tried it, it
> > doesn't work in practice the generated xml is '\&lt;' not '<'
> 
> The wiki is a bit unclear on that point. The \ escaping is meant only for
> characters that are significant in markdown (or gtk-doc extensions), not in
> xml. So, you can do \@, \# and \%

Thanks for clearing that up. I'd forgotten that ‘>’ was used in markdown as well as xml.