+++ /dev/null
-var Cheerio = require('cheerio');
-var Inky = require('inky');
-var format = require('string-template');
-var hljs = require('highlight.js');
-var multiline = require('multiline');
-var fs = require('fs');
-var path = require('path');
-
-var fileCounter = 0;
-var examplesPath = path.join(process.cwd(), './_build/examples');
-
-var INKY_TEMPLATE = multiline(function() {/*
-<div class="docs-code" data-docs-code>
- <pre>
- <code class="{0}">{1}</code>
- </pre>
-</div>
-<div class="docs-code" data-docs-code>
- <pre>
- <code class="{0}">{2}</code>
- </pre>
-</div>
-<iframe class="docs-code-iframe" src="examples/{3}"></iframe>
-*/});
-
-var IFRAME_TEMPLATE = multiline(function() {/*
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="viewport" content="width=device-width"/>
- <link rel="stylesheet" href="../assets/css/ink.css">
- </head>
- <body>
- <table class="body">
- <tr>
- <td class="center" align="center" valign="top">
- <table class="container">
- <tr>
- <td>
- {0}
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </body>
-</html>
-*/});
-
-module.exports = function(code) {
- // Load Inky code sample into Inky parser
- var $ = Cheerio.load(code);
- var output = Inky.releaseTheKraken($, {});
-
- // Separate Inky code and HTML code
- var inkyCode = hljs.highlight('html', code).value;
- var htmlCode = hljs.highlight('html', output.html()).value;
-
- // Create iframe code
- var iframeCode = format(IFRAME_TEMPLATE, [output.html()]);
- var iframeFile = 'example-' + (fileCounter++) + '.html';
-
- // Create folder for code samples if it doesn't exist
- if (!fs.existsSync(examplesPath)) {
- fs.mkdirSync(examplesPath);
- }
-
- // Write an iframe with the full HTML needed to the build folder
- fs.writeFileSync(path.join(examplesPath, iframeFile), iframeCode);
-
- // Return a final code sample with Inky source, HTML source, and iframe reference
- return format(INKY_TEMPLATE, ['html', inkyCode, htmlCode, iframeFile]);
-}
+++ /dev/null
-var marked = require('marked');
-var multiline = require('multiline');
-var handlebars = require('handlebars');
-var hljs = require('highlight.js');
-var format = require('string-template');
-var querystring = require('querystring');
-
-var ISSUE_TEXT = multiline(function() {/*
-**How can we reproduce this bug?**
-
-1. Step one
-2. Step two
-3. Step three
-
-**What did you expect to happen?**
-
-**What happened instead?**
-
-**Test case**
-
-Give us a link to a [CodePen](http://codepen.io) or [JSFiddle](http://jsfiddle.net) that recreates the issue.
-*/});
-
-// Converts Markdown to HTML
-handlebars.registerHelper('md', function(text) {
- return marked(text);
-});
-
-// Creates a heading with an anchor link
-handlebars.registerHelper('heading', function(level, anchor, options) {
- // Allow for optional second parameter
- if (typeof anchor === 'object') {
- options = anchor;
- anchor = options.fn(this);
- }
-
- var escapedText = anchor.toLowerCase().replace(/[^\w]+/g, '-');
-
- return format('<h{0} id="{1}" class="docs-heading"><a class="docs-heading-icon" href="#{1}"></a>{2}</h{0}>', [level, escapedText, options.fn(this)]);
-});
-
-// Escapes a string for use as a URL hash
-handlebars.registerHelper('escape', function(text) {
- if (typeof text === 'undefined') return '';
-
- return text.toLowerCase().replace(/[^\w]+/g, '-');
-});
-
-// Capitalizes the first letter of a string
-handlebars.registerHelper('toUpper', function(str) {
- return str[0].toUpperCase() + str.slice(1);
-});
-
-// Makes an entire string lowercase
-handlebars.registerHelper('toLower', function(str) {
- if (typeof str === 'undefined') str = '';
- return str.toLowerCase();
-});
-
-// Formats a mixin using a SassDoc mixin object to look like this:
-// @include mixinName($param, $param) { }
-handlebars.registerHelper('writeMixin', function(mixin) {
- var name = mixin['context']['name'];
- var params = mixin['parameter'];
-
- var str = '@include ';
- str += name;
-
- if (params) str += '(';
-
- for (var i in params) {
- str += '$' + params[i]['name'] + ', ';
- }
-
- if (params) str = str.slice(0, -2) + ')';
-
- if (typeof mixin.content === 'string') {
- str += ' { }';
- }
- else {
- str += ';'
- }
-
- str = hljs.highlight('scss', str).value;
-
- return str;
-});
-
-// Formats a function using a SassDoc function object to look like this:
-// function($param, $param)
-handlebars.registerHelper('writeFunction', function(func) {
- var name = func['context']['name'];
- var params = func['parameter'];
-
- var str = '';
- str += name + '(';
-
- for (var i in params) {
- str += '$' + params[i]['name'] + ', ';
- }
- if (params) str = str.slice(0, -2);
- str += ')';
-
- str = hljs.highlight('scss', str).value;
-
- return str;
-});
-
-// Formats a variable declaration using a SassDoc variable object to look like this:
-// $name: $value;
-handlebars.registerHelper('writeVariable', function(variable) {
- var name = variable['context']['name'];
- var value = variable['context']['value'];
- var str = '$' + name + ': ' + value + ';';
- str = hljs.highlight('scss', str).value;
-
- return str;
-});
-
-// Adds an external link, pulled from a SassDock @link annotation.
-handlebars.registerHelper('externalLink', function(link) {
- if (!link) return '';
-
- return format('<p><strong>Learn more:</strong> <a href="{0}">{1}</a></p>', [link[0].url, link[0].caption]);
-});
-
-// Format Sass variable types to read "x or y or z"
-handlebars.registerHelper('sassTypes', function(types) {
- if (typeof types === 'undefined') return '';
-
- var types = types.replace(' ', '').split('|');
- var output = '';
-
- for (var i in types) {
- output += types[i] + ' or ';
- }
-
- return output.slice(0, -4);
-});
-
-// Format a Sass value to pretty-print a map, or "None" if there's no value
-handlebars.registerHelper('sassValue', function(value) {
- if (typeof value === 'undefined') return '<span style="color: #999;">None</span>';
-
- if (value[0] === '(' && value[value.length - 1] === ')') {
- value = value.slice(1, -1).split(',').join('<br>');
- }
-
- return value;
-});
-
-handlebars.registerHelper('editLink', function(value) {
- return format('https://github.com/zurb/foundation-sites-6/edit/master/{0}', [value.replace('.html', '.md')]);
-});
-
-handlebars.registerHelper('issueLink', function(name) {
- return 'https://github.com/zurb/foundation-sites-6/issues/new?' + querystring.stringify({
- title: format('[{0}] Issue Name', [name]),
- body: ISSUE_TEXT
- });
-});
-
-handlebars.registerHelper('sourceLink', function(files) {
- var output = '';
- var text = {
- 'sass': 'Sass',
- 'js': 'JavaScript'
- }
- var both = files.sass && files.js;
-
- for (var i in files) {
- var module = files[i];
- if (typeof module === 'string') module = [module];
- module = module.filter(function(val) {
- return val[0] !== '!';
- }).map(function(val) {
- if (val.indexOf('*') > -1) {
- val = val.split('*')[0];
- }
- return val;
- })[0];
- output += format('<li><a href="{0}">{1}</a></li>', [
- 'https://github.com/zurb/foundation-sites-6/tree/master/' + module,
- (both ? 'View ' + text[i] + ' Source' : 'View Source')
- ]);
- }
-
- return output;
-});
-
-module.exports = handlebars;
+++ /dev/null
-var marked = require('marked');
-var format = require('string-template');
-var hljs = require('highlight.js');
-var buildInkySample = require('./buildInkySample');
-
-var mdRenderer = new marked.Renderer();
-
-// Adds an anchor link to each heading created
-mdRenderer.heading = function(text, level) {
- var escapedText = text.toLowerCase().replace(/[^\w]+/g, '-');
-
- return format('<h{0} id="{1}" class="docs-heading"><a class="docs-heading-icon" href="#{1}"></a>{2}</h{0}>', [level, escapedText, text]);
-}
-
-// Adds special formatting to each code block created
-// If the language is suffixed with "_example", the raw HTML is printed after the code sample, creating a live example.
-mdRenderer.code = function(code, language) {
- var extraOutput = '';
-
- if (language === 'inky') {
- return buildInkySample(code);
- }
-
- if (typeof language === 'undefined') language = 'html';
-
- // If the language is *_example, live code will print out along with the sample
- if (language.match(/_example$/)) {
- extraOutput = format('\n\n<div class="docs-code-live">{0}</div>', [code]);
- language = language.replace(/_example$/, '');
- }
-
- var renderedCode = hljs.highlight(language, code).value;
- var output = format('<div class="docs-code" data-docs-code><pre><code class="{0}">{1}</code></pre></div>', [language, renderedCode]);
-
- return output + extraOutput;
-}
-
-module.exports = mdRenderer;