Skip to content

Commit

Permalink
Merge branch 'develop' into feature/2776_katex_math
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 authored Jan 30, 2024
2 parents bc332e3 + c84c7f5 commit 0b087b7
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 35 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ on:
permissions:
contents: read

env:
node-version: 18.x

jobs:
build-mermaid:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
# uses version from "packageManager" field in package.json

- name: Setup Node.js ${{ matrix.node-version }}
- name: Setup Node.js ${{ env.node-version }}
uses: actions/setup-node@v4
with:
cache: pnpm
node-version: ${{ matrix.node-version }}
node-version: ${{ env.node-version }}

- name: Install Packages
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ permissions:
contents: read

env:
node-version: 18.x
# For PRs and MergeQueues, the target commit is used, and for push events, github.event.previous is used.
targetHash: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || (github.event.before == '0000000000000000000000000000000000000000' && 'develop' || github.event.before) }}

Expand Down Expand Up @@ -60,18 +61,17 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x]
containers: [1, 2, 3, 4]
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
# uses version from "packageManager" field in package.json

- name: Setup Node.js ${{ matrix.node-version }}
- name: Setup Node.js ${{ env.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version: ${{ env.node-version }}

# These cached snapshots are downloaded, providing the reference snapshots.
- name: Cache snapshots
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ on:
permissions:
contents: write

env:
node-version: 18.x

jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
# uses version from "packageManager" field in package.json

- name: Setup Node.js ${{ matrix.node-version }}
- name: Setup Node.js ${{ env.node-version }}
uses: actions/setup-node@v4
with:
cache: pnpm
node-version: ${{ matrix.node-version }}
node-version: ${{ env.node-version }}

- name: Install Packages
run: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ on: [push, pull_request, merge_group]
permissions:
contents: read

env:
node-version: 18.x

jobs:
unit-test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
# uses version from "packageManager" field in package.json

- name: Setup Node.js ${{ matrix.node-version }}
- name: Setup Node.js ${{ env.node-version }}
uses: actions/setup-node@v4
with:
cache: pnpm
node-version: ${{ matrix.node-version }}
node-version: ${{ env.node-version }}

- name: Install Packages
run: |
Expand Down
17 changes: 15 additions & 2 deletions demos/pie.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<body>
<h1>Pie chart demos</h1>
<pre class="mermaid">
pie title Pets adopted by volunteers
pie title Default text position: Animal adoption
accTitle: simple pie char demo
accDescr: pie chart with 3 sections: dogs, cats, rats. Most are dogs.
"Dogs": 386
Expand All @@ -27,7 +27,7 @@ <h1>Pie chart demos</h1>
<pre class="mermaid">
%%{init: {"pie": {"textPosition": 0.9}, "themeVariables": {"pieOuterStrokeWidth": "5px"}}}%%
pie
title Key elements in Product X
title Offset labels close to border: Product X
accTitle: Key elements in Product X
accDescr: This is a pie chart showing the key elements in Product X.
"Calcium": 42.96
Expand All @@ -36,6 +36,19 @@ <h1>Pie chart demos</h1>
"Iron": 5
</pre>

<pre class="mermaid">
%%{init: {"pie": {"textPosition": 0.45}, "themeVariables": {"pieOuterStrokeWidth": "5px"}}}%%
pie
title Centralized labels: Languages
accTitle: Key elements in Product X
accDescr: This is a pie chart showing the key elements in Product X.
"JavaScript": 30
"Python": 25
"Java": 20
"C#": 15
"Others": 10
</pre>

<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({
Expand Down
8 changes: 4 additions & 4 deletions docs/syntax/timeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ timeline
timeline
title MermaidChart 2023 Timeline
section 2023 Q1 <br> Release Personal Tier
Buttet 1 : sub-point 1a : sub-point 1b
Bullet 1 : sub-point 1a : sub-point 1b
: sub-point 1c
Bullet 2 : sub-point 2a : sub-point 2b
section 2023 Q2 <br> Release XYZ Tier
Buttet 3 : sub-point <br> 3a : sub-point 3b
Bullet 3 : sub-point <br> 3a : sub-point 3b
: sub-point 3c
Bullet 4 : sub-point 4a : sub-point 4b
```
Expand All @@ -176,11 +176,11 @@ timeline
timeline
title MermaidChart 2023 Timeline
section 2023 Q1 <br> Release Personal Tier
Buttet 1 : sub-point 1a : sub-point 1b
Bullet 1 : sub-point 1a : sub-point 1b
: sub-point 1c
Bullet 2 : sub-point 2a : sub-point 2b
section 2023 Q2 <br> Release XYZ Tier
Buttet 3 : sub-point <br> 3a : sub-point 3b
Bullet 3 : sub-point <br> 3a : sub-point 3b
: sub-point 3c
Bullet 4 : sub-point 4a : sub-point 4b
```
Expand Down
33 changes: 24 additions & 9 deletions packages/mermaid/src/diagrams/common/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ export const getRows = (s?: string): string[] => {
return str.split('#br#');
};

/**
* Removes script tags from a text
*
* @param txt - The text to sanitize
* @returns The safer text
*/
export const removeScript = (txt: string): string => {
const setupDompurifyHooksIfNotSetup = (() => {
let setup = false;

return () => {
if (!setup) {
setupDompurifyHooks();
setup = true;
}
};
})();

function setupDompurifyHooks() {
const TEMPORARY_ATTRIBUTE = 'data-temp-href-target';

DOMPurify.addHook('beforeSanitizeAttributes', (node: Element) => {
Expand All @@ -33,8 +38,6 @@ export const removeScript = (txt: string): string => {
}
});

const sanitizedText = DOMPurify.sanitize(txt);

DOMPurify.addHook('afterSanitizeAttributes', (node: Element) => {
if (node.tagName === 'A' && node.hasAttribute(TEMPORARY_ATTRIBUTE)) {
node.setAttribute('target', node.getAttribute(TEMPORARY_ATTRIBUTE) || '');
Expand All @@ -44,6 +47,18 @@ export const removeScript = (txt: string): string => {
}
}
});
}

/**
* Removes script tags from a text
*
* @param txt - The text to sanitize
* @returns The safer text
*/
export const removeScript = (txt: string): string => {
setupDompurifyHooksIfNotSetup();

const sanitizedText = DOMPurify.sanitize(txt);

return sanitizedText;
};
Expand Down
4 changes: 2 additions & 2 deletions packages/mermaid/src/docs/syntax/timeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ timeline
timeline
title MermaidChart 2023 Timeline
section 2023 Q1 <br> Release Personal Tier
Buttet 1 : sub-point 1a : sub-point 1b
Bullet 1 : sub-point 1a : sub-point 1b
: sub-point 1c
Bullet 2 : sub-point 2a : sub-point 2b
section 2023 Q2 <br> Release XYZ Tier
Buttet 3 : sub-point <br> 3a : sub-point 3b
Bullet 3 : sub-point <br> 3a : sub-point 3b
: sub-point 3c
Bullet 4 : sub-point 4a : sub-point 4b
```
Expand Down

0 comments on commit 0b087b7

Please sign in to comment.