Fix links in pandoc filter. ihse-manpages-branch
authorihse
Tue, 30 Oct 2018 09:24:14 +0100
branchihse-manpages-branch
changeset 57005 f29c33ab2259
parent 57004 f43f68ae83ed
child 57006 44fe6d5e9c73
Fix links in pandoc filter.
make/scripts/pandoc-manpage-filter.js
--- a/make/scripts/pandoc-manpage-filter.js	Tue Oct 30 08:29:56 2018 +0100
+++ b/make/scripts/pandoc-manpage-filter.js	Tue Oct 30 09:24:14 2018 +0100
@@ -73,8 +73,8 @@
     return { 't': 'Str', 'c': value };
 }
 
-function Emph(value) {
-    return { 't': 'Emph', 'c': value };
+function Strong(value) {
+    return { 't': 'Strong', 'c': value };
 }
 
 function Header(value) {
@@ -103,14 +103,16 @@
         }
     }
 
-    // If it is a link, put the link name in italics. If it is internal,
-    // remove the target, otherwise, put it in brackets.
+    // If it is a link, put the link name in bold. If it is an external
+    // link, put it in brackets. Otherwise, it is either an internal link
+    // (like "#next-heading"), or a relative link to another man page
+    // (like "java.html"), so remove it for man pages.
     if (type === 'Link') {
         var target = value[2][0];
-        if (target.startsWith('#')) {
-            return Emph(value[1]);
+        if (target.match(/^http[s]?:/)) {
+            return [ Strong(value[1]), Space(), Str('[' + target + ']') ];
         } else {
-            return [ Emph(value[1]), Space(), Str('[' + target + ']') ];
+            return Strong(value[1]);
         }
     }
 }