shithub: neatpost

Download patch

ref: f8ee2bb9d6ad4bb0e43de1bdf2c68a900c9a6366
parent: 9bc8b2e4caa3d228bf5669e2e8c64820a5e76c6b
author: Ali Gholami Rudi <ali@rudi.ir>
date: Wed Oct 25 19:48:04 EDT 2017

out: support internal links

--- a/out.c
+++ b/out.c
@@ -1,3 +1,4 @@
+#include <ctype.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -311,10 +312,17 @@
 	char lnk[1 << 12];
 	int hwid, vwid;
 	int nspec;
-	if ((nspec = sscanf(spec, "%s %d %d", lnk, &hwid, &vwid)) < 3)
+	if ((nspec = sscanf(spec, "%s %d %d", lnk, &hwid, &vwid)) != 3)
 		return;
 	o_flush();
-	outf("[ /Rect [ %d %d t %d %d t ] /Action << /Subtype /URI /URI (%s) >> "
-		"/Open true /Subtype /Link /LNK pdfmark\n",
-		o_h, o_v, o_h + hwid, o_v + vwid, lnk);
+	if (isdigit((unsigned char) lnk[0])) {
+		outf("[ /Rect [ %d %d t %d %d t ] /Page %s"
+			"/Subtype /Link /LNK pdfmark\n",
+			o_h, o_v, o_h + hwid, o_v + vwid, lnk);
+	} else {
+		outf("[ /Rect [ %d %d t %d %d t ]"
+			"/Action << /Subtype /URI /URI (%s) >> /Open true "
+			"/Subtype /Link /LNK pdfmark\n",
+			o_h, o_v, o_h + hwid, o_v + vwid, lnk);
+	}
 }