Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: emersonbottero/vitepress-plugin-mermaid
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: eaa8e7a0552a3b66888ec216998c7f1d2f348140
Choose a base ref
...
head repository: emersonbottero/vitepress-plugin-mermaid
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 27b7cf0f8fb10b294f6b08aacfd5759e577896d0
Choose a head ref
  • 7 commits
  • 3 files changed
  • 3 contributors

Commits on Jan 26, 2024

  1. Unverified

    This user has not yet uploaded their public signing key.
    Copy the full SHA
    ad2396a View commit details

Commits on Jan 27, 2024

  1. Merge pull request #66 from TatsuyaYamamoto/patch-1

    fix: set `types` condition to exports field
    emersonbottero authored Jan 27, 2024
    Copy the full SHA
    1a543a3 View commit details

Commits on May 29, 2024

  1. Remove leftover sum function

    dmohns committed May 29, 2024
    Copy the full SHA
    e8de274 View commit details
  2. Add yaml to fenced code block

    dmohns committed May 29, 2024
    Copy the full SHA
    92f9b74 View commit details
  3. Copy the full SHA
    1eeb9d7 View commit details

Commits on Aug 2, 2024

  1. Merge pull request #69 from dmohns/minor-documentation-updates

    docs: minor documentation updates (yaml highlight, Gantt source code)
    emersonbottero authored Aug 2, 2024
    Copy the full SHA
    a95a9a2 View commit details

Commits on Sep 23, 2024

  1. Merge pull request #68 from dmohns/remove-leftover-sum-function

    cleanup: remove leftover `sum` function
    emersonbottero authored Sep 23, 2024
    Copy the full SHA
    27b7cf0 View commit details
Showing with 14 additions and 55 deletions.
  1. +13 −1 docs/guide/more-examples.md
  2. +1 −0 package.json
  3. +0 −54 src/mermaid-markdown.ts
14 changes: 13 additions & 1 deletion docs/guide/more-examples.md
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ title: A more complex example

💡 The theme for each page can be set in the frontmatter mermaidTheme parameter! But is only valid is light mode...

```
```yaml
---
mermaidTheme: forest
title: A more complex example
@@ -122,6 +122,18 @@ pie title Pets adopted by volunteers
```
## Gantt

```mmd
gantt
title A Gantt Diagram
dateFormat YYYY-MM-DD
section Section
A task :a1, 2014-01-01, 30d
Another task :after a1, 20d
section Another
Task in Another :2014-01-12, 12d
another task :24d
```

```mermaid
gantt
title A Gantt Diagram
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@
"module": "./dist/vitepress-plugin-mermaid.es.mjs",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/vitepress-plugin-mermaid.es.mjs",
"require": "./dist/vitepress-plugin-mermaid.umd.js"
},
54 changes: 0 additions & 54 deletions src/mermaid-markdown.ts
Original file line number Diff line number Diff line change
@@ -1,58 +1,4 @@
export const MermaidMarkdown = (md, pluginOptions) => {
const sum = (o) => {
function pad(hash, len) {
while (hash.length < len) {
hash = "0" + hash;
}
return hash;
}

function fold(hash, text) {
var i;
var chr;
var len;
if (text.length === 0) {
return hash;
}
for (i = 0, len = text.length; i < len; i++) {
chr = text.charCodeAt(i);
hash = (hash << 5) - hash + chr;
hash |= 0;
}
return hash < 0 ? hash * -2 : hash;
}

function foldObject(hash, o, seen) {
return Object.keys(o).sort().reduce(foldKey, hash);
function foldKey(hash, key) {
return foldValue(hash, o[key], key, seen);
}
}

function foldValue(input, value, key, seen) {
var hash = fold(fold(fold(input, key), toString(value)), typeof value);
if (value === null) {
return fold(hash, "null");
}
if (value === undefined) {
return fold(hash, "undefined");
}
if (typeof value === "object") {
if (seen.indexOf(value) !== -1) {
return fold(hash, "[Circular]" + key);
}
seen.push(value);
return foldObject(hash, value, seen);
}
return fold(hash, value.toString());
}

function toString(o) {
return Object.prototype.toString.call(o);
}
return pad(foldValue(0, o, "", []).toString(16), 8);
};

const fence = md.renderer.rules.fence.bind(md.renderer.rules);

md.renderer.rules.fence = (tokens, index, options, env, slf) => {