Gist HTML Preview
-If File Name is empty, it will preview index.html or the first file as default.
+Diff Gist HTML Preview
+If File Name is empty, it will preview the first file + as default.
Gist HTML Preview
+
-
+
diff --git a/diff-showdown.js b/diff-showdown.js new file mode 100644 index 0000000..d96b6c8 --- /dev/null +++ b/diff-showdown.js @@ -0,0 +1,61 @@ +/** + * Support for Mermaid in Showdown + */ +(function (extension) { + 'use strict'; + + if (typeof showdown !== 'undefined') { + // global (browser or nodejs global) + extension(showdown); + } else if (typeof define === 'function' && define.amd) { + // AMD + define(['showdown'], extension); + } else if (typeof exports === 'object') { + // Node, CommonJS-like + module.exports = extension(require('showdown')); + } else { + // showdown was not found so we throw + throw Error('Could not find showdown library'); + } + +}(function (showdown) { + 'use strict'; + + var mermaidBlocks = []; + + /** + * + * Support for mermaid.js + */ + showdown.extension('diff', function () { + return [ + { + type: 'lang', + regex: '(?:^|\\n)``` ?diff(.*)\\n([\\s\\S]*?)\\n```', + replace: function (s, match) { + var thing = s.match('(?:^|\\n)``` ?diff(.*)\\n([\\s\\S]*?)\\n```'); + var thing_group = thing.length - 1; + mermaidBlocks.push(thing[thing_group]); + var n = mermaidBlocks.length - 1; + return '%PLACEHOLDER' + n + '%'; + } + }, + + { + type: 'output', + filter: function (text) { + var new_text = ''; + for (var i = 0; i < mermaidBlocks.length; ++i) { + var pat = '%PLACEHOLDER' + i + '%'; + //text = text.replace(new RegExp(pat, 'gi'), '
'); + } + new_text = mermaidBlocks.join('\n\n') + //reset array + mermaidBlocks = []; + return new_text; + } + } + + ]; + }); +})); \ No newline at end of file diff --git a/diff2html.html b/diff2html.html new file mode 100644 index 0000000..752f16f --- /dev/null +++ b/diff2html.html @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/index.html b/index.html index 7e4638d..1bc372c 100644 --- a/index.html +++ b/index.html @@ -1,12 +1,13 @@ + -' + mermaidBlocks[i] + '