Permalink
Browse files

mermaid integration.

  • Loading branch information...
2510 committed Sep 13, 2017
1 parent 7586e82 commit f42938716d74342a2077b2ff410d7b9d31358bce
@@ -11,6 +11,8 @@ import Pikaday from 'pikaday';
import Dropzone from 'dropzone';
import Sortable from 'vendor/Sortable';
import mermaid from 'mermaid';
// libraries with import side-effects
import 'mousetrap';
import 'mousetrap/plugins/pause/mousetrap-pause';
@@ -26,6 +28,7 @@ window._ = _;
window.Pikaday = Pikaday;
window.Dropzone = Dropzone;
window.Sortable = Sortable;
window.mermaid = mermaid;
// shortcuts
import './shortcuts';
@@ -51,6 +51,8 @@
if (response.references.commands) {
this.renderReferencedCommands(response.references.commands, $form);
}
mermaid.init({}, preview.find('.mermaid'));
}).bind(this));
}
};
@@ -26,6 +26,7 @@
@import "framework/lists.scss";
@import "framework/logo.scss";
@import "framework/markdown_area.scss";
@import "framework/mermaid.scss";
@import "framework/mobile.scss";
@import "framework/modal.scss";
@import "framework/nav.scss";
@@ -0,0 +1,2 @@
@import "../../../node_modules/mermaid/dist/themes/mermaid.default.min";
@@ -0,0 +1,15 @@
module Banzai
module Filter
# Format mermaid.js style code block for client-side processing.
#
class MermaidFilter < HTML::Pipeline::Filter
def call
doc.css('pre > code[lang="mermaid"]').each do |node|
node.parent.replace('<pre class="mermaid">' + node.content + '</pre>')
end
doc
end
end
end
end
@@ -11,6 +11,7 @@ def self.filters
@filters ||= FilterArray[
Filter::PlantumlFilter,
Filter::SanitizationFilter,
Filter::MermaidFilter,
Filter::SyntaxHighlightFilter,
Filter::MathFilter,
@@ -5,7 +5,8 @@ def self.filters
@filters ||= FilterArray[
Filter::SanitizationFilter,
Filter::ExternalLinkFilter,
Filter::PlantumlFilter
Filter::PlantumlFilter,
Filter::MermaidFilter
]
end
end
@@ -0,0 +1,21 @@
module Rouge
module Lexers
class Mermaid < Lexer
title "A passthrough lexer used for mermaid input"
desc "A boring lexer that doesn't highlight anything"
tag 'mermaid'
mimetypes 'text/plain'
default_options token: 'Text'
def token
@token ||= Token[option :token]
end
def stream_tokens(string, &b)
yield self.token, string
end
end
end
end
View
@@ -35,6 +35,7 @@
"jszip": "^3.1.3",
"jszip-utils": "^0.0.2",
"marked": "^0.3.6",
"mermaid": "^7.0.14",
"mousetrap": "^1.4.6",
"pdfjs-dist": "^1.8.252",
"pikaday": "^1.5.1",
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit f429387

Please sign in to comment.