From ed2bf56c00ff71b18e7581b47cd2c5fbcd1b00bf Mon Sep 17 00:00:00 2001 From: "mikesamuel@gmail.com" Date: Wed, 21 Jul 2010 18:19:01 +0000 Subject: [PATCH] fix line numbers on IE. On IE String.match returns a different value for unmatched groups and IE uses margin-left to indent lists. --- src/prettify.css | 2 +- src/prettify.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/prettify.css b/src/prettify.css index 4874b1f5..60e270fe 100644 --- a/src/prettify.css +++ b/src/prettify.css @@ -14,7 +14,7 @@ pre.prettyprint { padding: 2px; border: 1px solid #888; display: list } /* Specify class=linenums on a pre to get line numbering */ -ol.linenums { margin: 0 } +ol.linenums { margin-top: 0; margin-bottom: 0 } /* IE indents via margin-left */ li.L0, li.L1, li.L2, diff --git a/src/prettify.js b/src/prettify.js index 1262dda5..6010b8ab 100644 --- a/src/prettify.js +++ b/src/prettify.js @@ -1113,7 +1113,8 @@ window['_pr_isIE6'] = function () { for (var i = 0; i < 10; ++i) { lineBreaks[i] = lineBreakHtml + '
  • '; } - var lineNum = numberLines[1] - 1 || 0; // Lines are 1-indexed + var lineNum = numberLines[1] && numberLines[1].length + ? numberLines[1] - 1 : 0; // Lines are 1-indexed html.push('