diff --git a/cypress/integration/rendering/handDraw.spec.js b/cypress/integration/rendering/handDraw.spec.js
new file mode 100644
index 000000000..208fb1bbe
--- /dev/null
+++ b/cypress/integration/rendering/handDraw.spec.js
@@ -0,0 +1,9 @@
+import { urlSnapshotTest } from '../../helpers/util.ts';
+
+describe('Hand Draw', () => {
+ it('should render the hand drawn look for all diagrams', () => {
+ urlSnapshotTest('http://localhost:9000/handDrawn.html', {
+ logLevel: 1,
+ });
+ });
+});
diff --git a/cypress/platform/handDrawn.html b/cypress/platform/handDrawn.html
new file mode 100644
index 000000000..1489b7050
--- /dev/null
+++ b/cypress/platform/handDrawn.html
@@ -0,0 +1,211 @@
+
+
+
+
+
+ Hand Drawn Diagrams
+
+
+
+ Hand-drawn Look Comparison
+
+
+
+
diff --git a/packages/mermaid/src/mermaidAPI.ts b/packages/mermaid/src/mermaidAPI.ts
index 73dd03f70..aaf52f8d8 100644
--- a/packages/mermaid/src/mermaidAPI.ts
+++ b/packages/mermaid/src/mermaidAPI.ts
@@ -447,7 +447,7 @@ const render = async function (
svgCode = cleanUpSvgCode(svgCode, isSandboxed, evaluate(config.arrowMarkerAbsolute));
if (config.look === 'handDrawn' && !diag.capabilities?.handDrawn && includeLargeFeatures) {
const { OutputType, Svg2Roughjs } = await import('svg2roughjs');
- const svg2roughjs = new Svg2Roughjs(`${enclosingDivID_selector}`, OutputType.SVG, {
+ const svg2roughjs = new Svg2Roughjs(enclosingDivID_selector, OutputType.SVG, {
seed: config.handDrawnSeed,
});
const graphDiv = document.querySelector(idSelector)!;
@@ -458,13 +458,13 @@ const render = async function (
if (!sketch) {
throw new Error('sketch not found');
}
- const sketchHeight = sketch.getAttribute('height');
- const sketchWidth = sketch.getAttribute('width');
+ const height = sketch.getAttribute('height');
+ const width = sketch.getAttribute('width');
sketch.setAttribute('id', id);
sketch.removeAttribute('height');
sketch.setAttribute('width', '100%');
- sketch.setAttribute('viewBox', `0 0 ${sketchWidth} ${sketchHeight}`);
+ sketch.setAttribute('viewBox', `0 0 ${width} ${height}`);
svgCode = sketch.outerHTML;
}