Skip to content

Commit

Permalink
feat(output): img-html-base64
Browse files Browse the repository at this point in the history
  • Loading branch information
Airkro committed Oct 24, 2023
1 parent 16e05be commit 4842d1e
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 110 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Alias code language name to treat as kroki code block, meta.type will be ignored

- type: string
- default: `'img-base64'`
- enum: `['inline-svg', 'img-base64', 'object-base64']`
- enum: `['inline-svg', 'img-base64', 'img-html-base64', 'object-base64']`

How to embed SVG as image. See the different and risk on [Best Way To Embed SVG](https://vecta.io/blog/best-way-to-embed-svg).

Expand Down
6 changes: 6 additions & 0 deletions lib/transform.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ const modes = {
alt || diagramType
}" data="${toDataURL(data)}">Load SVG fail...</object>`;
},
'img-html-base64': ({ node, diagramType, data, alt }) => {
node.type = 'html';
node.value = `<img class="kroki-image" alt="${
alt || diagramType
}" src="${toDataURL(data)}" />`;
},
'inline-svg': ({ node, diagramType, data, alt }) => {
node.type = 'html';
node.value = `<div class="kroki-inline-svg" data-type="${diagramType}" data-alt="${
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "remark-kroki",
"version": "0.2.9",
"version": "0.2.10",
"description": "Remark plugin for showing Kroki diagram",
"license": "MIT",
"author": {
Expand Down Expand Up @@ -56,12 +56,12 @@
"unist-util-visit": "^5.0.0"
},
"devDependencies": {
"@bring-it/npm": "^0.3.5",
"@bring-it/npm": "^0.3.9",
"@nice-move/cli": "^0.10.13",
"@nice-move/eslint-config-base": "^0.9.22",
"@nice-move/prettier-config": "^0.9.6",
"@nice-move/prettier-config": "^0.9.7",
"ava": "^5.3.1",
"eslint": "^8.51.0",
"eslint": "^8.52.0",
"eslint-plugin-ava": "^14.0.0",
"garou": "^0.6.17",
"prettier": "^3.0.3",
Expand All @@ -76,7 +76,7 @@
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"packageManager": "pnpm@8.8.0",
"packageManager": "pnpm@8.9.2",
"eslintConfig": {
"extends": "@nice-move/eslint-config-base"
},
Expand Down
Loading

0 comments on commit 4842d1e

Please sign in to comment.