Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,12 @@ Post.prototype = {
, t = fs.readFileSync(p).toString()

// replace the raw code blocks with prettyfied html
t = t.replace(/<code>[^<]+<\/code>/g, function(code) {
return "<pre><code>" + prettyfy(code.match(/<code>([\s\S]+)<\/code>/)[1]) + "</code></pre>";
t = t.replace(/<code>[^<]+<\/code>|```[a-z]*\n[\s\S]*?\n```/g, function(code) {
var matches = code.match(/<code>([\s\S]+)<\/code>|```[a-z]*\n([\s\S]*?)\n```/)
// sanitise matches, because of regex groups
matches = matches.filter(function(e) { return e })

return "<pre><code>" + prettyfy(matches[1]) + "</code></pre>";
})

// return markdown to html
Expand Down
8 changes: 4 additions & 4 deletions posts/2013-08-07-Math.max()-behaviour.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ So next time, watch out for what you pass into `Math.max()`.

`Math.max()` typecasts all values to Numbers (`Number(x)`), e.g.:

``` javascript
Math.max(false, -1); // 0
Math.max(5, "10"); // 10
```
<code>
Math.max(false, -1); // 0
Math.max(5, "10"); // 10
</code>

— [@ixti](http://ixti.net)