Permalink
Browse files

Only render HTML examples

Ignore GHM code blocks with specified languages other than HTML
  • Loading branch information...
1 parent 90a9da6 commit 347f44b7dccda1af44291a5e97868e89a3aeead2 @jacobrask committed Jul 8, 2012
Showing with 32 additions and 2 deletions.
  1. +1 −1 styledocco.js
  2. +15 −0 test/fixtures/code.css
  3. +9 −0 test/fixtures/code.css.blocks.json
  4. +6 −0 test/fixtures/code.css.sections.json
  5. +1 −1 test/parser.js
View
@@ -87,7 +87,7 @@ var makeSections = exports.makeSections = function(blocks) {
var newBlock = {
code: block.code,
docs: block.docs.reduce(function(tokens, token) {
- if (token.type === 'code') {
+ if (token.type === 'code' && (token.lang == null || token.lang === 'html')) {
tokens.push({
type: 'html',
pre: true,
@@ -0,0 +1,15 @@
+/* Various types of code blocks in documentation */
+
+body {
+ background: red;
+ color: white;
+}
+
+/*
+```php
+<?php
+echo 'PHP Code without rendered example';
+?>
+```
+
+ <p>HTML to be rendered</p> */
@@ -0,0 +1,9 @@
+[
+ {
+ "docs": " Various types of code blocks in documentation \n",
+ "code": "\nbody {\n background: red;\n color: white;\n}\n\n"
+ }, {
+ "docs": "\n```php\n<?php\necho 'PHP Code without rendered example';\n?>\n```\n\n <p>HTML to be rendered</p> \n",
+ "code": "\n"
+ }
+]
@@ -0,0 +1,6 @@
+[
+ {
+ "docs": "<p> Various types of code blocks in documentation \n</p>\n<pre><code class=\"lang-php\">&lt;?php\necho &#39;PHP Code without rendered example&#39;;\n?&gt;</code></pre>\n<div class=\"styledocco-example\"><p>HTML to be rendered</p> </div><pre><code>&lt;p&gt;HTML to be rendered&lt;/p&gt; </code></pre>",
+ "code": "body {\n background: red;\n color: white;\n}"
+ }
+]
View
@@ -21,7 +21,7 @@ if (typeof window === 'undefined') {
} else {
fixturePath = 'fixtures/';
}
-var fixtures = [ 'asterisk.css', 'comments.css', 'invalid.css',
+var fixtures = [ 'asterisk.css', 'code.css', 'comments.css', 'invalid.css',
'normal.css', 'structured.css' ];
exports["Documentation and code blocks"] = function(test) {

0 comments on commit 347f44b

Please sign in to comment.