Skip to content

Commit 1d3d40f

Browse files
committed
Switched from prettyprint to pygmentize.
1 parent b8122df commit 1d3d40f

File tree

6 files changed

+38
-21
lines changed

6 files changed

+38
-21
lines changed

entries/end.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<p>The <code>end()</code> method is useful primarily when exploiting jQuery's chaining properties. When not using chaining, we can usually just call up a previous object by variable name, so we don't need to manipulate the stack. With <code>end()</code>, though, we can string all the method calls together:</p>
2121
<pre>
2222
$('ul.first').find('.foo').css('background-color', 'red')
23-
<code>.end()</code>.find('.bar').css('background-color', 'green');
23+
.end().find('.bar').css('background-color', 'green');
2424
</pre>
2525
<p>This chain searches for items with the class <code>foo</code> within the first list only and turns their backgrounds red. Then <code>end()</code> returns the object to its state before the call to <code>find()</code>, so the second <code>find()</code> looks for '.bar' inside <code>&lt;ul class="first"&gt;</code>, not just inside that list's <code>&lt;li class="foo"&gt;</code>, and turns the matching elements' backgrounds green. The net result is that items 1 and 3 of the first list have a colored background, and none of the items from the second list do.</p>
2626
<p>A long jQuery chain can be visualized as a structured code block, with filtering methods providing the openings of nested blocks and <code>end()</code> methods closing them:</p>

entries/jQuery.cssHooks.xml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<p>For example, some versions of Webkit-based browsers require <code>-webkit-border-radius</code> to set the <code>border-radius</code> on an element, while earlier Firefox versions require <code>-moz-border-radius</code>. A css hook can normalize these vendor-prefixed properties to let <code>.css()</code> accept a single, standard property name (<code>border-radius</code>, or with DOM property syntax, <code>borderRadius</code>).</p>
88
<p>In addition to providing fine-grained control over how specific style properties are handled, <code>$.cssHooks</code> also extends the set of properties available to the <code>.animate()</code> method.</p>
99
<p>Defining a new css hook is straight-forward. The skeleton template below can serve as a guide to creating your own. </p>
10-
<pre class="prettyprint">(function($) {
10+
<pre><code>(function($) {
1111
// first, check to see if cssHooks are supported
1212
if ( !$.cssHooks ) {
1313
// if not, output an error message
@@ -24,10 +24,10 @@
2424
}
2525
};
2626
})(jQuery);
27-
</pre>
27+
</code></pre>
2828
<h4 id="feature-testing">Feature Testing</h4>
2929
<p>Before normalizing a vendor-specific CSS property, first determine whether the browser supports the standard property or a vendor-prefixed variation. For example, to check for support of the <code>border-radius</code> property, see if any variation is a member of a temporary element's <code>style</code> object.</p>
30-
<pre class="prettyprint">(function($) {
30+
<pre><code>(function($) {
3131
function styleSupport( prop ) {
3232
var vendorProp, supportedProp,
3333

@@ -64,10 +64,10 @@
6464
// call the function, e.g. testing for "border-radius" support:
6565
styleSupport( "borderRadius" );
6666
})(jQuery);
67-
</pre>
67+
</code></pre>
6868
<h4 id="defining-complete-csshook">Defining a complete css hook</h4>
6969
<p>To define a complete css hook, combine the support test with a filled-out version of the skeleton template provided in the first example:</p>
70-
<pre class="prettyprint">(function($) {
70+
<pre><code>(function($) {
7171
if ( !$.cssHooks ) {
7272
throw("jQuery 1.4.3+ is needed for this plugin to work");
7373
return;
@@ -111,15 +111,15 @@
111111
};
112112
}
113113
})(jQuery);
114-
</pre>
114+
</code></pre>
115115

116116
<p>You can then set the border radius in a supported browser using either the DOM (camelCased) style or the CSS (hyphenated) style:</p>
117-
<pre class="prettyprint">
117+
<pre><code>
118118
$("#element").css("borderRadius", "10px");
119119
$("#another").css("border-radius", "20px");
120-
</pre>
120+
</code></pre>
121121
<p>If the browser lacks support for any form of the CSS property, vendor-prefixed or not, the style is not applied to the element. However, if the browser supports a proprietary alternative, it can be applied to the cssHooks instead. </p>
122-
<pre class="prettyprint">
122+
<pre><code>
123123
(function($) {
124124
// feature test for support of a CSS property
125125
// and a proprietary alternative
@@ -150,18 +150,18 @@ $("#another").css("border-radius", "20px");
150150
}
151151

152152
})(jQuery);
153-
</pre>
153+
</code></pre>
154154
<h4 id="special-units">Special units</h4>
155155
<p>By default, jQuery adds a "px" unit to the values passed to the <code>.css()</code> method. This behavior can be prevented by adding the property to the <code>jQuery.cssNumber</code> object</p>
156156

157-
<pre class="prettyprint">$.cssNumber["someCSSProp"] = true;</pre>
157+
<pre><code>$.cssNumber["someCSSProp"] = true;</code></pre>
158158

159159
<h4 id="animating">Animating with cssHooks</h4>
160160
<p>A css hook can also hook into jQuery's animation mechanism by adding a property to the <code>jQuery.fx.step</code> object:</p>
161-
<pre class="prettyprint">$.fx.step["someCSSProp"] = function(fx){
161+
<pre><code>$.fx.step["someCSSProp"] = function(fx){
162162
$.cssHooks["someCSSProp"].set( fx.elem, fx.now + fx.unit );
163163
};
164-
</pre>
164+
</code></pre>
165165
<p>Note that this works best for simple numeric-value animations. More custom code may be required depending on the CSS property, the type of value it returns, and the animation's complexity.</p>
166166
</longdesc>
167167
<category slug="css"/>

entries/jQuery.map.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<longdesc>
2222
<p>The <code>$.map()</code> method applies a function to each item in an array or object and maps the results into a new array. <strong>Prior to jQuery 1.6</strong>, <code>$.map()</code> supports traversing <em>arrays only</em>. <strong>As of jQuery 1.6</strong> it also traverses objects.</p>
2323
<p>Array-like objects &#8212; those with a <code>.length</code> property <em>and</em> a value on the <code>.length - 1</code> index &#8212; must be converted to actual arrays before being passed to <code>$.map()</code>. The jQuery library provides <a href="http://api.jquery.com/jQuery.makeArray/">$.makeArray()</a> for such conversions.</p>
24-
<pre class="prettyprint">
24+
<pre><code>
2525
// The following object masquerades as an array.
2626
var fakeArray = {"length": 1, 0: "Addy", 1: "Subtracty"};
2727

@@ -32,7 +32,7 @@ var realArray = $.makeArray( fakeArray )
3232
$.map( realArray, function(val, i) {
3333
// do something
3434
});
35-
</pre>
35+
</code></pre>
3636
<p>The translation function that is provided to this method is called for each top-level element in the array or object and is passed two arguments: The element's value and its index or key within the array or object.</p>
3737
<p>The function can return:</p>
3838
<ul>

entries2html.xsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@
254254
<xsl:value-of select="position() - 1"/>
255255
</xsl:attribute>
256256
<h4><xsl:if test="$number-examples &gt; 1">Example: </xsl:if><span class="desc"><xsl:value-of select="desc" /></span></h4>
257-
<pre class="prettyprint"><code><xsl:choose>
258-
<xsl:when test="html"><xsl:attribute name="class">example demo-code</xsl:attribute>&lt;!DOCTYPE html&gt;
257+
<pre><code><xsl:choose>
258+
<xsl:when test="html">&lt;!DOCTYPE html&gt;
259259
&lt;html&gt;
260260
&lt;head&gt;<xsl:if test="css/text()">
261261
&lt;style&gt;<xsl:copy-of select="css/text()" />&lt;/style&gt;</xsl:if>

grunt.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module.exports = function( grunt ) {
44
var // modules
55
fs = require( "fs" ),
66
path = require( "path" ),
7+
pygmentize = require( "pygmentize" ),
78
spawn = require( "child_process" ).spawn,
89

910
// files
@@ -86,10 +87,25 @@ grunt.registerTask( "build-entries", function() {
8687
return;
8788
}
8889
grunt.verbose.ok();
90+
8991
targetFileName = targetDir + path.basename( fileName );
9092
targetFileName = targetFileName.substr( 0, targetFileName.length - "xml".length ) + "html";
91-
grunt.file.write( targetFileName, result );
92-
fileDone();
93+
94+
grunt.verbose.write( "Pygmentizing " + targetFileName + "..." );
95+
pygmentize.file( result, function( error, data ) {
96+
if ( error ) {
97+
grunt.verbose.error();
98+
grunt.log.error( error );
99+
fileDone();
100+
return;
101+
}
102+
grunt.verbose.ok();
103+
104+
grunt.file.write( targetFileName, data );
105+
106+
fileDone();
107+
});
108+
93109
});
94110
}, function() {
95111
if ( task.errorCount ) {

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"dependencies": {
2424
"grunt": "0.3.x",
2525
"grunt-clean": "0.1.0",
26-
"grunt-wordpress": "0.1.0"
26+
"grunt-wordpress": "0.1.0",
27+
"pygmentize": "0.2.0"
2728
},
2829
"devDependencies": {},
2930
"keywords": []

0 commit comments

Comments
 (0)