From: Florian Brosch Date: Fri, 6 Jan 2012 01:26:30 +0000 (+0100) Subject: libvala: gir-reader: fix spaces/newlines in img-alt-text X-Git-Tag: 0.37.1~3^2~258 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4727810cbffe0638ba47976c8ff13e5775482f57;p=thirdparty%2Fvala.git libvala: gir-reader: fix spaces/newlines in img-alt-text --- diff --git a/src/libvaladoc/documentation/gtkdoccommentparser.vala b/src/libvaladoc/documentation/gtkdoccommentparser.vala index 376624e56..e1aa9f03d 100644 --- a/src/libvaladoc/documentation/gtkdoccommentparser.vala +++ b/src/libvaladoc/documentation/gtkdoccommentparser.vala @@ -44,6 +44,9 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator { private string[]? comment_lines; + private Regex? normalize_regex = null; + + private void reset (Api.SourceComment comment) { this.scanner.reset (comment.content); this.show_warnings = !comment.file.package.is_package || settings.verbose; @@ -54,6 +57,17 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator { this.stack.clear (); } + private string normalize (string text) { + try { + if (normalize_regex == null) { + normalize_regex = new Regex ("( |\n|\t)+"); + } + return normalize_regex.replace (text, -1, 0, " "); + } catch (RegexError e) { + assert_not_reached (); + } + } + private inline Text? split_text (Text text) { int offset = 0; while ((offset = text.content.index_of_char ('.', offset)) >= 0) { @@ -395,7 +409,7 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator { if (builder.len == 0) { link.content.add (factory.create_text (url)); } else { - link.content.add (factory.create_text (builder.str)); + link.content.add (factory.create_text (normalize (builder.str))); } if (!check_xml_close_tag (tagname)) {