{"id":54,"date":"2008-08-10T19:59:41","date_gmt":"2008-08-11T01:59:41","guid":{"rendered":"http:\/\/bililite.nfshost.com\/blog\/?p=54"},"modified":"2012-08-05T21:32:38","modified_gmt":"2012-08-06T03:32:38","slug":"testing-chili","status":"publish","type":"post","link":"https:\/\/bililite.com\/blog\/2008\/08\/10\/testing-chili\/","title":{"rendered":"Testing Chili"},"content":{"rendered":"<p>Update: I no longer (2012-08-05) use Chili; I've switched to <a href=\"http:\/\/prismjs.com\">Prism<\/a>.<\/p>\r\n<p>I like the idea of syntax coloring, so let's see if <a href=\"http:\/\/noteslog.com\/chili\/\">Chili<\/a> works:<\/p>\r\n<pre><code class=\"language-javascript\">\r\nalert('Hello, world');\r\n<\/code><\/pre>\r\n\r\n<p>and another: <code class=\"language-html\">&lt;div&gt;Hello, &lt;em&gt;world&lt;\/em&gt;&lt;\/div&gt;<\/code><\/p>\r\n\r\n<p>I'm trying to be as HTML5-compliant as possible, at least in the sense of using their standards rather than making up my own, so the Chili setup I'm using is:<\/p>\r\n<pre><code class=\"language-javascript\">\r\n    $.extend(ChiliBook, {\r\n        automatic: false,\r\n        codeLanguage: function(el){\r\n            \/\/ use the HTML5 language class\r\n            var recipeName = \/language-(\\S+)\/.exec(el.className);\r\n            return recipeName ? recipeName[1] : &#39;&#39;;\r\n        }\r\n    });\r\n    $(function(){\r\n        $(&#39;code[class*=language-]&#39;).not($('pre code')).chili({lineNumbers: false})\r\n                                  .otherwise().chili({lineNumbers: true});\r\n    });\r\n\r\n <\/code><\/pre>\r\n<p>Sweet! The idea of the above code is to look for a class that starts with \"language-\" and use that as the recipe for Chili (rather than Chili's built-in way of taking the entire className). It also assumes that any code in a <code>pre<\/code> element should have line numbers, and anything else should not. It uses the cute and brilliant <code>otherwise<\/code> plugin from\r\nhttp:\/\/groups.google.com\/group\/jquery-en\/browse_thread\/thread\/6be2a127822a108d.\r\n<\/p>\r\n\r\n<p>Update: It looks like line numbering works only intermittently. Oh well; I won't fix it.<\/p>","protected":false},"excerpt":{"rendered":"Update: I no longer (2012-08-05) use Chili; I've switched to Prism. I like the idea of syntax coloring, so let's see if Chili works: alert('Hello, world'); and another: &lt;div&gt;Hello, &lt;em&gt;world&lt;\/em&gt;&lt;\/div&gt; I'm trying to be as HTML5-compliant as possible, at least in the sense of using their standards rather than making up my own, so the [&hellip;]","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,20],"tags":[],"_links":{"self":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/54"}],"collection":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/comments?post=54"}],"version-history":[{"count":26,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/54\/revisions"}],"predecessor-version":[{"id":2554,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/54\/revisions\/2554"}],"wp:attachment":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/media?parent=54"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/categories?post=54"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/tags?post=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}