Good morning.

I had noticed that Dive Site notes are displayed like a very long, single
line.  This is pretty annoying if one tries to give some format to the
stored text (e.g. \n or \t).

I initially thought it was a QT thing on showing the text, as I could see
the chars in the XML file, but it happens to do with the way they are
stored as an XML attribute instead of an XML element.  On loading, the
special chars are substituted with white spaces, and displayed this way.

If the use of the XML attribute was, for some reason, intentional, please,
simply drop the attached patch.

Regards.

Salva.
From bf95adf3bc0cbbeddfaf532a15655b07a9e72765 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Salvador=20Cu=C3=B1at?= <salvador.cu...@gmail.com>
Date: Sun, 4 Oct 2015 11:17:25 +0200
Subject: [PATCH] Dive_sites-Notes shouldn't be stored as attribute
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

If so, some formatting chars (like "\n") will be dropped while parsing.
This could be pretty annoying for a user who tries to keep notes other
than a simple text, e.g. if the site is a wreck, may be interesting to
have some data shown like:
			...
		Max. Depth =  60 m
		Min. Depth =  40 m
		Prow: bla, bla, bla.
		Stern: bla, bla, bla.
			...
instead of a single text line.

Signed-off-by: Salvador Cuñat <salvador.cu...@gmail.com>
---
 save-xml.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/save-xml.c b/save-xml.c
index 6d02840..8aa5088 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -550,21 +550,19 @@ void save_dives_buffer(struct membuffer *b, const bool select_only)
 			put_degrees(b, ds->longitude, "", "'");
 		}
 		show_utf8(b, ds->description, " description='", "'", 1);
-		show_utf8(b, ds->notes, " notes='", "'", 1);
+		put_format(b, ">\n");
+		show_utf8(b, ds->notes, "  <notes>", " </notes>\n", 0);
 		if (ds->taxonomy.nr) {
-			put_format(b, ">\n");
 			for (int j = 0; j < ds->taxonomy.nr; j++) {
 				struct taxonomy *t = &ds->taxonomy.category[j];
 				if (t->category != TC_NONE) {
-					put_format(b, "<geo cat='%d'", t->category);
+					put_format(b, "  <geo cat='%d'", t->category);
 					put_format(b, " origin='%d'", t->origin);
 					show_utf8(b, t->value, " value='", "'/>\n", 1);
 				}
 			}
-			put_format(b, "</site>\n");
-		} else {
-			put_format(b, "/>\n");
 		}
+		put_format(b, "</site>\n");
 	}
 	put_format(b, "</divesites>\n<dives>\n");
 	for (trip = dive_trip_list; trip != NULL; trip = trip->next)
-- 
2.6.0

_______________________________________________
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to