tylingsoft / markdown-it-mermaid Goto Github PK
View Code? Open in Web Editor NEWMermaid plugin for markdown-it.
Mermaid plugin for markdown-it.
Hi there. Looking at #4, I was able to get the plugin registered with markdown-it, but as it stands right now it is not doing anything.
Here is my code:
// `parser` is the object you get from `new MarkdownIt()`
parser.use(require('markdown-it-mermaid').default);
console.log(parser.render(`\`\`\`mermaid
graph TD
A[Christmas] -->|Get money| B(Go shopping)
B --> C{Let me think}
C -->|One| D[Laptop]
C -->|Two| E[iPhone]
C -->|Three| F[Car]
\`\`\``));
The following code is output:
<div class="mermaid">graph TD
A[Christmas] -->|Get money| B(Go shopping)
B --> C{Let me think}
C -->|One| D[Laptop]
C -->|Two| E[iPhone]
C -->|Three| F[Car]</div>
So it doesn't look like it's generating any SVG code... unless I am misunderstanding something with the implementation?
Thanks for any help you can provide!
I found that the original mermaid project has new features like git diagram and class diagram, will the plugin support those features?
Mermaid is at version 8.0.0
, but your dependency file states ^7.1.2
. What does that mean exactly?
Does it mean that even though I use 8.0.0 in my project and if I also used your plugin, your plugin would use mermaid 7.x
instead?
valeriangalliat/markdown-it-anchor#12
不管在hexo还是Ghost用都会遇到TypeError: plugin.apply is not a function
请问如何解决呢?
Hi;
I want to use this plugin on the browser but I can't figure out how, I've cloned the repository built it, but seems not working to me, because the file in dist/index.js
have only the plugin compiled there's not the mermais package there's, here's the code I had :
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else {
var a = factory();
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
}
})(typeof self !== 'undefined' ? self : this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _mermaid = __webpack_require__(1);
var _mermaid2 = _interopRequireDefault(_mermaid);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var mermaidChart = function mermaidChart(code) {
try {
_mermaid2.default.parse(code);
return '<div class="mermaid">' + code + '</div>';
} catch (_ref) {
var str = _ref.str;
var hash = _ref.hash;
return '<pre>' + str + '</pre>';
}
};
var MermaidPlugin = function MermaidPlugin(md) {
md.mermaid = _mermaid2.default;
_mermaid2.default.loadPreferences = function (preferenceStore) {
var mermaidTheme = preferenceStore.get('mermaid-theme');
if (mermaidTheme === undefined) {
mermaidTheme = 'default';
}
var ganttAxisFormat = preferenceStore.get('gantt-axis-format');
if (ganttAxisFormat === undefined) {
ganttAxisFormat = '%Y-%m-%d';
}
_mermaid2.default.initialize({
theme: mermaidTheme,
gantt: { axisFormatter: [[ganttAxisFormat, function (d) {
return d.getDay() === 1;
}]] }
});
return {
'mermaid-theme': mermaidTheme,
'gantt-axis-format': ganttAxisFormat
};
};
var temp = md.renderer.rules.fence.bind(md.renderer.rules);
md.renderer.rules.fence = function (tokens, idx, options, env, slf) {
var token = tokens[idx];
var code = token.content.trim();
if (token.info === 'mermaid') {
return mermaidChart(code);
}
var firstLine = code.split(/\n/)[0].trim();
if (firstLine === 'gantt' || firstLine === 'sequenceDiagram' || firstLine.match(/^graph (?:TB|BT|RL|LR|TD);?$/)) {
return mermaidChart(code);
}
return temp(tokens, idx, options, env, slf);
};
};
exports.default = MermaidPlugin;
/***/ }),
/* 1 */
/***/ (function(module, exports) {
module.exports = require("mermaid");
/***/ })
/******/ ]);
});
//# sourceMappingURL=index.js.map
Am I missing something?
We are in the process of adding mermaid support to Joplin, but it seems that this markdown plugin is dead.
Are you ever going to update this to the latest version of Mermaid or is it dead?
我在 vuepress
项目中如下去配置 markdown-it-mermaid
,但是无效的,请求支援。
extendMarkdown: md => {
md.set({ breaks: true })
md.use(require('markdown-it-mermaid').default)
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.