added links for line numbers

Tue, 21 Apr 2015 10:11:37 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 21 Apr 2015 10:11:37 +0200
changeset 27
53fd8595378c
parent 26
05c3c6842aef
child 28
1be8ea902ef4

added links for line numbers

src/c2html.c file | annotate | diff | comparison | revisions
test/header.html file | annotate | diff | comparison | revisions
test/jheader.html file | annotate | diff | comparison | revisions
--- a/src/c2html.c	Tue Apr 21 09:53:01 2015 +0200
+++ b/src/c2html.c	Tue Apr 21 10:11:37 2015 +0200
@@ -168,10 +168,16 @@
         // write line number
         if (showln) {
             WRITECONST(stream, out, "<span class=\"c2html-lineno\">");
-            char lnbuf[16];
-            int len = snprintf(lnbuf, 16, "%*d ", lnw, i+1);
+            char lnbuf[128];
+            int len;
+            // line number link
+            len = snprintf(lnbuf, 128, "<a name=\"l%d\" href=\"#l%d\">",
+                i+1, i+1);
             out(lnbuf, 1, len, stream);
-            WRITECONST(stream, out, "</span> ");
+            // justified line number
+            len = snprintf(lnbuf, 128, "%*d ", lnw, i+1);
+            out(lnbuf, 1, len, stream);
+            WRITECONST(stream, out, "</a></span> ");
         }
         
         // write formated (or plain) code line
--- a/test/header.html	Tue Apr 21 09:53:01 2015 +0200
+++ b/test/header.html	Tue Apr 21 10:11:37 2015 +0200
@@ -3,8 +3,9 @@
   <head>
     <title>c2html</title>
     <style type="text/css">
-      span.c2html-lineno {
+      span.c2html-lineno a {
         font-style: italic;
+        text-decoration: none;
         color: grey;
       }
       span.c2html-keyword {
--- a/test/jheader.html	Tue Apr 21 09:53:01 2015 +0200
+++ b/test/jheader.html	Tue Apr 21 10:11:37 2015 +0200
@@ -3,8 +3,9 @@
   <head>
     <title>c2html</title>
     <style type="text/css">
-      span.c2html-lineno {
+      span.c2html-lineno a {
         font-style: italic;
+        text-decoration: none;
         color: grey;
       }
       span.c2html-keyword {

mercurial