[valadoc] libvala: gir-reader: fix spaces/newlines in img-alt-text



commit 4727810cbffe0638ba47976c8ff13e5775482f57
Author: Florian Brosch <flo brosch gmail com>
Date:   Fri Jan 6 02:26:30 2012 +0100

    libvala: gir-reader: fix spaces/newlines in img-alt-text

 .../documentation/gtkdoccommentparser.vala         |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/src/libvaladoc/documentation/gtkdoccommentparser.vala b/src/libvaladoc/documentation/gtkdoccommentparser.vala
index 376624e..e1aa9f0 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)) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]