Skip to content

Commit 0fb99ba

Browse files
committed
API sites: Support <default> inside options, fix hiding of gutter
Due to some bad logic, the gutter was always displayed by default, the reverse of what the code intended. Changing the actual default now to keep the previous behaviour, but allowing opt-out, which the new <default> element is now using. Fixes #64
1 parent d60fe84 commit 0fb99ba

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

lib/highlight.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ function syntaxHighlight( html ) {
7171
(code.trim().charAt( 0 ) === "<" ? "xml" : "") ||
7272
"javascript",
7373
linenumAttr = $t.attr( "data-linenum" ),
74-
linenum = (linenumAttr === "true" ? 1 : parseInt( linenumAttr, 10 ) ) || 1,
75-
gutter = linenumAttr === undefined ? false : true,
74+
linenum = parseInt( linenumAttr, 10 ) || 1,
75+
gutter = linenumAttr === "false" ? false : true,
7676
highlighted = hljs.highlight( lang, code ),
7777
fixed = hljs.fixMarkup( highlighted.value, " " );
7878

lib/lineNumberTemplate.jst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
<div class="syntaxhighlighter <%= lang %> <% if (!gutter) { %>nogutter<% } %>">
1+
<div class="syntaxhighlighter <%= lang %>">
22
<table>
33
<tbody>
44
<tr>
5+
<% if (gutter) { %>
56
<td class="gutter">
67
<% _.forEach(lines, function(line, i) { %>
78
<div class="line n<%= i + startAt %>"><%= i + startAt %></div>
89
<% }); %>
910
</td>
11+
<% } %>
1012
<td class="code">
1113
<pre><% _.forEach(lines, function(line, i) { %><div class="container"><div class="line"><code><%= line %></code></div></div><% }); %></pre>
1214
</td>

tasks/jquery-xml/entries2html-base.xsl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,12 @@
413413
</h3>
414414
<div class="default">
415415
<strong>Default: </strong>
416-
<code><xsl:apply-templates select="@default" mode="value"/></code>
416+
<xsl:if test="@default">
417+
<code><xsl:apply-templates select="@default" mode="value"/></code>
418+
</xsl:if>
419+
<xsl:if test="default">
420+
<pre><code data-linenum="false"><xsl:copy-of select="default/text()"/></code></pre>
421+
</xsl:if>
417422
</div>
418423
<div>
419424
<xsl:apply-templates select="desc">

0 commit comments

Comments
 (0)