changeset 17768:271c0cce0f64

remove XREF from the links in the docuemntation * parser.cc(replace_links): remove "XREF" and ":" from the strings that is shown in the links of the documentation; mark links to a figure (anchor) with # in order to prevent opening a new tab; (node_text_to_html) color for current section; (info_to_html): color for title "Menu" of table of contents * webinfo.cc(link_clicked): only load tab when link does not start with #, scroll to desired anchor instead
author Torsten <ttl@justmail.de>
date Sat, 26 Oct 2013 23:20:30 +0200
parents 26992c04d5dc
children 49a5a4be04a1
files libgui/src/qtinfo/parser.cc libgui/src/qtinfo/webinfo.cc
diffstat 2 files changed, 25 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/qtinfo/parser.cc	Sat Oct 26 10:26:58 2013 -0700
+++ b/libgui/src/qtinfo/parser.cc	Sat Oct 26 23:20:30 2013 +0200
@@ -272,7 +272,7 @@
 static void
 replace_links (QString& text)
 {
-  QRegExp re ("(\\*[N|n]ote|\n\\*)([ |\n]+)([^:]+):([^:\\.,]*)([:,\\.])");
+  QRegExp re ("(\\*[N|n]ote|\n\\*)([ |\n]+)([^:]+):([^:\\.,]*)([:,\\.]+)");
   int i = 0, f;
 
   while ( (i = re.indexIn (text,i)) != -1)
@@ -280,13 +280,16 @@
       QString type     = re.cap (1);
       QString note     = re.cap (3);
       QString url_link = re.cap (4);
-      QString link     = re.cap (4) + re.cap(5);
-      QString spaces = QString("");
-      QRegExp re_linebreak ("\n([ ]*)([^ ]*)([ ]*)");
-      if (re_linebreak.indexIn (link,0) != -1)
+      QString link     = re.cap (4);
+      QString term     = re.cap (5);
+
+      QRegExp regexp_link = QRegExp("([\\s]*)XREF([^\\s]*)");
+      if (regexp_link.indexIn (link) != -1)
         {
-          link.replace (re_linebreak,"&nbsp;"+re_linebreak.cap (2)+"\n");   // prevent line breaks in links
-          spaces = re_linebreak.cap (1);
+          int ix = regexp_link.cap (1).indexOf ("\n");
+          if (ix  != -1)
+            term = term + "\n"
+                   + QString (regexp_link.cap (1).size () - ix -1,' ');
         }
 
       if (url_link.isEmpty ())
@@ -310,7 +313,14 @@
         {
           href="<img src=':/actions/icons/bookmark.png' width=10/>";
         }
-      href += re.cap(2) + "<a href='" + url_link + "'>" + note + ":" + link + "</a>" + spaces;
+
+      term.replace(":","");
+      note.replace(":","");
+
+      if (note == "fig")
+        url_link.prepend("#");
+
+      href +=  "&nbsp;<a href='" + url_link + "'>" + note + "</a>" + term;
       f = re.matchedLength ();
       text.replace (i,f,href);
       i += href.size ();
@@ -325,7 +335,7 @@
   while ( (i = re.indexIn (text, i)) != -1)
     {
       QString t = re.cap (1);
-      QString bold = "<font style=\"color:Blue;font-weight:bold\">" + t + "</font>";
+      QString bold = "<font style=\"color:#00AA00;font-weight:bold\">" + t + "</font>";
 
       f = re.matchedLength ();
       text.replace (i,f,bold);
@@ -340,7 +350,7 @@
   text.replace ("<", "&lt;");
   text.replace (">", "&gt;");
 
-  text.replace ("\n* Menu:", "\n<font style=\"text-decoration:underline;font-weight:bold\">Menu:</font>");
+  text.replace ("\n* Menu:", "\n<font style=\"color:DarkRed;font-weight:bold\">Menu:</font>");
   text.replace ("See also:", "<font style=\"color:DarkRed;font-style:italic;font-weight:bold\">See also:</font>");
   replace_colons (text);
   replace_links (text);
@@ -380,7 +390,7 @@
     }
 
   QString navigationLinks = QString (
-        "<b>Section:</b> %1<br>"
+        "<b>Section:</b> <font style=\"color:DarkRed\">%1</font><br>"
         "<img src=':/actions/icons/arrow_left.png'/> <b>Previous Section:</b> <a href='%2'>%3</a><br>"
         "<img src=':/actions/icons/arrow_right.png'/> <b>Next Section:</b> <a href='%4'>%5</a><br>"
         "<img src=':/actions/icons/arrow_up.png'/> <b>Up:</b> <a href='%6'>%7</a><br>\n"
@@ -393,7 +403,6 @@
       .arg (QString (QUrl::toPercentEncoding (nodeUp, "", "'")))
       .arg (nodeUp);
 
-
   text.prepend ("<hr>\n<pre style=\"font-family:monospace\">");
   text.append ("</pre>\n<hr><hr>\n");
   text.prepend (navigationLinks);
--- a/libgui/src/qtinfo/webinfo.cc	Sat Oct 26 10:26:58 2013 -0700
+++ b/libgui/src/qtinfo/webinfo.cc	Sat Oct 26 23:20:30 2013 +0200
@@ -134,7 +134,10 @@
 webinfo::link_clicked (const QUrl & link)
 {
   QString node = link.toString ();
-  load_node (node);
+  if (node.at (0) != '#')
+    load_node (node);
+  else
+    _text_browser->scrollToAnchor (node);
 }
 
 void