Giter VIP home page Giter VIP logo

markdown-it-mermaid's People

Contributors

tylerlong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

markdown-it-mermaid's Issues

is this project dead?

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 中使用这个插件无效

我在 vuepress 项目中如下去配置 markdown-it-mermaid,但是无效的,请求支援。

extendMarkdown: md => {
      md.set({ breaks: true })
      md.use(require('markdown-it-mermaid').default)
}

Using the plugin on the browser

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?

does the mermaid dependency lock mermaid version to 7.x?

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?

Unable to integrate with markdown-it as plugin

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.