]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
libvala: gir-reader: fix spaces/newlines in img-alt-text
authorFlorian Brosch <flo.brosch@gmail.com>
Fri, 6 Jan 2012 01:26:30 +0000 (02:26 +0100)
committerFlorian Brosch <flo.brosch@gmail.com>
Fri, 6 Jan 2012 01:26:30 +0000 (02:26 +0100)
src/libvaladoc/documentation/gtkdoccommentparser.vala

index 376624e5687faf1492e28ae040a4af4d76f00703..e1aa9f03db64994507a457dafd6a820ea38f7b3d 100644 (file)
@@ -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)) {