From 1bde001d3be2814c3e49d1927b22f2d15193b1d9 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 14 Mar 2010 09:29:54 -0400 Subject: HTML line numbers are clickable, and highlight the line on arrival. Also, noticed that IE8 didn't line up the line number properly, so added an unfortunate meta tag to make it right. Closes issue #55. --- CHANGES.txt | 3 +++ coverage/htmlfiles/coverage_html.js | 8 ++++++++ coverage/htmlfiles/pyfile.html | 10 ++++++++-- coverage/htmlfiles/style.css | 16 ++++++++++++++-- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 098740f2..8e63d851 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -11,6 +11,9 @@ Next version rather than increasing the executed lines to varying targets. Once suggested, this seemed blindingly obvious. +- Line numbers in HTML source pages are clickable, linking directly to that + line, which is highlighted on arrival. + - Source files with DOS line endings are now properly tokenized for syntax coloring on non-DOS machines. Fixes `issue 53`_. diff --git a/coverage/htmlfiles/coverage_html.js b/coverage/htmlfiles/coverage_html.js index 2acba5c2..b6bde6ca 100644 --- a/coverage/htmlfiles/coverage_html.js +++ b/coverage/htmlfiles/coverage_html.js @@ -65,6 +65,14 @@ function index_page_ready($) { // -- pyfile stuff -- +function pyfile_ready($) { + // If we're directed to a particular line number, highlight the line. + var frag = location.hash; + if (frag.length > 2 && frag[1] == 'n') { + $(frag).addClass('highlight'); + } +} + function toggle_lines(btn, cls) { btn = $(btn); var hide = "hide_"+cls; diff --git a/coverage/htmlfiles/pyfile.html b/coverage/htmlfiles/pyfile.html index 209887b7..4aa4309f 100644 --- a/coverage/htmlfiles/pyfile.html +++ b/coverage/htmlfiles/pyfile.html @@ -1,11 +1,17 @@ - + + {# IE8 rounds line-height incorrectly, and adding this emulateIE7 line makes it right! #} + {# http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/7684445e-f080-4d8f-8529-132763348e21 #} + Coverage for {{cu.name|escape}}: {{nums.pc_covered|format_pct}}% + @@ -31,7 +37,7 @@ {% for line in lines %} -

{{line.number}}

+

{{line.number}}

{% endfor %} diff --git a/coverage/htmlfiles/style.css b/coverage/htmlfiles/style.css index 25e7d115..a9ab5358 100644 --- a/coverage/htmlfiles/style.css +++ b/coverage/htmlfiles/style.css @@ -5,8 +5,8 @@ html, body, h1, h2, h3, p, td, th { padding: 0; border: 0; outline: 0; - font-weight: inherit; - font-style: inherit; + font-weight: normal; + font-style: normal; font-size: 100%; font-family: inherit; vertical-align: baseline; @@ -108,6 +108,18 @@ h2.stats { font-size: .625em; /* 10/16 */ line-height: 1.6em; /* 16/10 */ } +.linenos p.highlight { + background: #ffdd00; + } +.linenos p a { + text-decoration: none; + color: #999999; + } +.linenos p a:hover { + text-decoration: underline; + color: #999999; + } + td.text { width: 100%; } -- cgit v1.2.1