diff --git a/lib/ast.mjs b/lib/ast.mjs new file mode 100644 index 0000000..f520d07 --- /dev/null +++ b/lib/ast.mjs @@ -0,0 +1,47 @@ +function attrString(attr) { + const buff = []; + + for (const [name, value] of Object.entries(attr)) { + buff.push(`${name}="${value}"`); + } + + if (buff.length === 0) { + return ''; + } + + return ` ${buff.join(' ')}`; +} + +// eslint-disable-next-line consistent-return +function stringifier(buff, doc) { + switch (doc.type) { + case 'text': { + return buff + doc.value; + } + case 'tag': { + // eslint-disable-next-line no-param-reassign + buff += `<${doc.name}${doc.attr ? attrString(doc.attr) : ''}${ + doc.void ? ' />' : '>' + }`; + + if (doc.void) { + return buff; + } + + return `${ + buff + + doc.children.reduce( + (accumulator, element) => stringifier(accumulator, element), + '', + ) + }`; + } + default: + } +} + +export function stringify(doc) { + return doc.reduce((token, rootEl) => { + return token + stringifier('', rootEl); + }, ''); +} diff --git a/lib/transform.mjs b/lib/transform.mjs index 4f8ec5a..ea0ff5f 100644 --- a/lib/transform.mjs +++ b/lib/transform.mjs @@ -1,5 +1,6 @@ import { getValue, parse } from 'markdown-code-block-meta'; +import { stringify } from './ast.mjs'; import { fetchData, mime, toDataURL } from './utils.mjs'; /* eslint-disable no-param-reassign */ @@ -14,6 +15,7 @@ const modes = { node.children = [ { type: 'image', + _meta: { kroki: true, type: diagramType }, alt: alt || diagramType, url: toDataURL(data), }, @@ -21,21 +23,61 @@ const modes = { }, 'object-base64': ({ node, diagramType, data, alt }) => { node.type = 'html'; - node.value = `Load SVG fail...`; + node.value = stringify([ + { + type: 'tag', + name: 'object', + attr: { + type: mime, + class: 'kroki-object', + 'data-type': diagramType, + title: alt || diagramType, + data: toDataURL(data), + }, + children: [ + { + type: 'text', + value: 'Load SVG fail...', + }, + ], + }, + ]); }, 'img-html-base64': ({ node, diagramType, data, alt }) => { node.type = 'html'; - node.value = `${
-      alt || diagramType
-    }`; + node.value = stringify([ + { + type: 'tag', + name: 'img', + void: true, + attr: { + class: 'kroki-image', + alt: alt || diagramType, + 'data-type': diagramType, + src: toDataURL(data), + }, + }, + ]); }, 'inline-svg': ({ node, diagramType, data, alt }) => { node.type = 'html'; - node.value = `
${removeXML(data.toString())}
`; + node.value = stringify([ + { + type: 'tag', + name: 'div', + attr: { + class: 'kroki-inline-svg', + 'data-type': diagramType, + 'data-alt': alt || diagramType, + }, + children: [ + { + type: 'text', + value: removeXML(data.toString()), + }, + ], + }, + ]); }, }; diff --git a/test/output.mjs b/test/output.mjs index b7dafca..52c5a48 100644 --- a/test/output.mjs +++ b/test/output.mjs @@ -2,6 +2,10 @@ import test from 'ava'; import { TransformSnapshot } from './helper/lib.mjs'; +test.before((t) => { + t.timeout(1000 ** 3); +}); + function macro(t, { output }) { return TransformSnapshot( t, diff --git a/test/snapshots/base.mjs.md b/test/snapshots/base.mjs.md index 0b50d6c..79e91b7 100644 --- a/test/snapshots/base.mjs.md +++ b/test/snapshots/base.mjs.md @@ -85,6 +85,10 @@ Generated by [AVA](https://avajs.dev). { children: [ { + _meta: { + kroki: true, + type: 'plantuml', + }, alt: 'abc', type: 'image', url: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXMtYXNjaWkiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBjb250ZW50U3R5bGVUeXBlPSJ0ZXh0L2NzcyIgaGVpZ2h0PSIxMDVweCIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSIgc3R5bGU9IndpZHRoOjY4cHg7aGVpZ2h0OjEwNXB4O2JhY2tncm91bmQ6I0ZGRkZGRjsiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDY4IDEwNSIgd2lkdGg9IjY4cHgiIHpvb21BbmRQYW49Im1hZ25pZnkiPjxkZWZzLz48Zz48bGluZSBzdHlsZT0ic3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2U6IzE4MTgxODtzdHJva2Utd2lkdGg6MC41OyIgd2lkdGg9IjI0IiB4PSIzOCIgeT0iNSIvPjx0ZXh0IGZpbGw9IiMwMDAwMDAiIGZvbnQtZmFtaWx5PSJzYW5zLXNlcmlmIiBmb250LXNpemU9IjE0IiBsZW5ndGhBZGp1c3Q9InNwYWNpbmciIHRleHRMZW5ndGg9IjEwIiB4PSI0NSIgeT0iMjQuOTk1MSI+QjwvdGV4dD48cmVjdCBmaWxsPSIjRTJFMkYwIiBoZWlnaHQ9IjMwLjI5NjkiIHJ4PSIyLjUiIHJ5PSIyLjUiIHN0eWxlPSJzdHJva2U6IzE4MTgxODtzdHJva2Utd2lkdGg6MC41OyIgd2lkdGg9IjI0IiB4PSIzOCIgeT0iNjkuMjk2OSIvPjx0ZXh0IGZpbGw9IiMwMDAwMDAiIGZvbnQtZmFtaWx5PSJzYW5zLXNlcmlmIiBmb250LXNpemU9IjE0IiBsZW5ndGhBZGp1c3Q9InNwYWNpbmciIHRleHRMZW5ndGg9IjEwIiB4PSI0NSIgeT0iODkuMjkyIj5CPC90ZXh0Pjxwb2x5Z29uIGZpbGw9IiMxODE4MTgiIHBvaW50cz0iMzgsNDguMjk2OSw0OCw1Mi4yOTY5LDM4LDU2LjI5NjksNDIsNTIuMjk2OSIgc3R5bGU9InN0cm9rZTojMTgxODE4O3N0cm9rZS13aWR0aDoxLjA7Ii8+PGxpbmUgc3R5bGU9InN0cm9rZTojMTgxODE4O3N0cm9rZS13aWR0aDoxLjA7c3Ryb2tlLWRhc2hhcnJheToyLjAsMi4wOyIgeDE9IjE2LjUiIHgyPSI0NCIgeTE9IjUyLjI5NjkiIHkyPSI1Mi4yOTY5Ii8+PCEtLVNSQz1bU3JKR3JSTEpTMDgwXS0tPjwvZz48L3N2Zz4=', @@ -125,6 +129,10 @@ Generated by [AVA](https://avajs.dev). { children: [ { + _meta: { + kroki: true, + type: 'plantuml', + }, alt: 'abc', type: 'image', url: 'data:image/svg+xml;base64,PD94bW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2x5Z29uIGZpbGw9IiMxODE4MTgiIHBvaW50cz0iMzgsNDguMjk2OSw0OCw1Mi4yOTY5LDM4LDU2LjI5NjksNDIsNTIuMjk2OSIgc3R5bGU9InN0cm9rZTojMTgxODE4O3N0cm9rZS13aWR0aDoxLjA7Ii8+PGxpbmUgc3R5bGU9InN0cm9rZTojMTgxODE4O3N0cm9rZS13aWR0aDoxLjA7c3Ryb2tlLWRhc2hhcnJheToyLjAsMi4wOyIgeDE9IjE2LjUiIHgyPSI0NCIgeTE9IjUyLjI5NjkiIHkyPSI1Mi4yOTY5Ii8+PCEtLVNSQz1bU3JKR3JSTEpTMDgwXS0tPjwvZz48L3N2Zz4=', diff --git a/test/snapshots/base.mjs.snap b/test/snapshots/base.mjs.snap index e691882..5d37cec 100644 Binary files a/test/snapshots/base.mjs.snap and b/test/snapshots/base.mjs.snap differ diff --git a/test/snapshots/fail.mjs.md b/test/snapshots/fail.mjs.md index a718749..f07dc47 100644 --- a/test/snapshots/fail.mjs.md +++ b/test/snapshots/fail.mjs.md @@ -31,6 +31,10 @@ Generated by [AVA](https://avajs.dev). { children: [ { + _meta: { + kroki: true, + type: 'plantuml', + }, alt: '00', type: 'image', url: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2MDAgMTgwIj4KICA8cGF0aAogICAgZmlsbD0iI2FhYSIKICAgIGQ9Ik05Mi4xNyAzOS43NWMtLjE4LjIxIDAgLjk5Ljk3IDQuMTEuNzcgMi41Ljk1IDMuNy42OCA0LjY2LS4yMy44Mi0uNjEgMS4xOC0xLjYgMS40OS0uNDIuMTMtLjg2LjI4LS45OC4zMi0uMTIuMDQtLjM3LjAxLS41NS0uMDYtLjU5LS4yNC0xLjcxLTIuMTUtMi41Mi00LjMxLTEuNjMtNC4zNS0zLjc2LTE0LjQyLTUuNy0yNi45LS42MS0zLjk0LS43My01Ljc2LS40Ni02LjcxLjIyLS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S44MVptNy4xMS0uMWMtMS41NSAxLjg0LTEuOSAyLjU3LTEuOSAzLjkgMCAyLjA3Ljc4IDMuMjIgMi40OSAzLjY3Ljc3LjIgMi42Ni4wNCAzLjU0LS4zMiAxLjI2LS40OSAyLjQtMS4zMSAzLjczLTIuNjQgMS4zMy0xLjM1IDIuMDQtMi40MyAyLjYtMy45Ny42Ny0xLjg0LjYxLTMuOTctLjE1LTUuNDctLjQ1LS45Mi0uOTgtMS4yNy0xLjg1LTEuMjYtMS44LjAzLTUuNzcgMi44OS04LjQ2IDYuMDlaIgogIC8+CiAgPHRleHQgeT0iODAiIGZpbGw9IiNhYWEiIGZvbnQtc2l6ZT0iMTQiPkZhaWwsIHBsZWFzZSBjaGVjayB5b3VyIGlucHV0LjwvdGV4dD4KICA8Zm9yZWlnbk9iamVjdCB3aWR0aD0iNjAwIiBoZWlnaHQ9IjgwIiB5PSI5MCIgZm9udC1zaXplPSIxNCI+CiAgICA8ZGl2CiAgICAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hodG1sIgogICAgICBzdHlsZT0iY29sb3I6I2ZmMjIwMDt3b3JkLWJyZWFrOmJyZWFrLWFsbCIKICAgID4KICAgICAgRXJyb3IgNDAwOiBTeW50YXggRXJyb3I/IChsaW5lOiAxKQogICAgPC9kaXY+CiAgPC9mb3JlaWduT2JqZWN0Pgo8L3N2Zz4K', @@ -71,6 +75,10 @@ Generated by [AVA](https://avajs.dev). { children: [ { + _meta: { + kroki: true, + type: 'fake', + }, alt: 'fake', type: 'image', url: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2MDAgMTgwIj4KICA8cGF0aAogICAgZmlsbD0iI2FhYSIKICAgIGQ9Ik05Mi4xNyAzOS43NWMtLjE4LjIxIDAgLjk5Ljk3IDQuMTEuNzcgMi41Ljk1IDMuNy42OCA0LjY2LS4yMy44Mi0uNjEgM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NDIgOS4wNy0uMSAxLjkxLS4zOSAzLjAxLTEuMTcgNC41OC0xLjcxIDMuNDItNC41NyA2LjIxLTguMDkgNy45LTIuMzEgMS4xMS01LjA1IDEuNTktNy4yNiAxLjI4LTMuNzItLjUxLTYuMTctMy4wNi02Ljk4LTcuMjMtLjI5LTEuNTEtLjI3LTQuNDUuMDMtNS44MVptNy4xMS0uMWMtMS41NSAxLjg0LTEuOSAyLjU3LTEuOSAzLjkgMCAyLjA3Ljc4IDMuMjIgMi40OSAzLjY3Ljc3LjIgMi42Ni4wNCAzLjU0LS4zMiAxLjI2LS40OSAyLjQtMS4zMSAzLjczLTIuNjQgMS4zMy0xLjM1IDIuMDQtMi40MyAyLjYtMy45Ny42Ny0xLjg0LjYxLTMuOTctLjE1LTUuNDctLjQ1LS45Mi0uOTgtMS4yNy0xLjg1LTEuMjYtMS44LjAzLTUuNzcgMi44OS04LjQ2IDYuMDlaIgogIC8+CiAgPHRleHQgeT0iODAiIGZpbGw9IiNhYWEiIGZvbnQtc2l6ZT0iMTQiPkZhaWwsIHBsZWFzZSBjaGVjayB5b3VyIGlucHV0LjwvdGV4dD4KICA8Zm9yZWlnbk9iamVjdCB3aWR0aD0iNjAwIiBoZWlnaHQ9IjgwIiB5PSI5MCIgZm9udC1zaXplPSIxNCI+CiAgICA8ZGl2CiAgICAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hodG1sIgogICAgICBzdHlsZT0iY29sb3I6I2ZmMjIwMDt3b3JkLWJyZWFrOmJyZWFrLWFsbCIKICAgID4KICAgICAgRXJyb3IgNDA0OiBOb3QgRm91bmQKICAgIDwvZGl2PgogIDwvZm9yZWlnbk9iamVjdD4KPC9zdmc+Cg==', diff --git a/test/snapshots/fail.mjs.snap b/test/snapshots/fail.mjs.snap index a61a250..76ffebd 100644 Binary files a/test/snapshots/fail.mjs.snap and b/test/snapshots/fail.mjs.snap differ diff --git a/test/snapshots/output.mjs.md b/test/snapshots/output.mjs.md index 96e4a3e..c1053d6 100644 --- a/test/snapshots/output.mjs.md +++ b/test/snapshots/output.mjs.md @@ -65,6 +65,10 @@ Generated by [AVA](https://avajs.dev). { children: [ { + _meta: { + kroki: true, + type: 'plantuml', + }, alt: 'plantuml', type: 'image', url: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXMtYXNjaWkiIHN0YW5kYWxvbmU9Im5vIj8+PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBjb250ZW50U3R5bGVUeXBlPSJ0ZXh0L2NzcyIgaGVpZ2h0PSIxMDVweCIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSIgc3R5bGU9IndpZHRoOjY4cHg7aGVpZ2h0OjEwNXB4O2JhY2tncm91bmQ6I0ZGRkZGRjsiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDY4IDEwNSIgd2lkdGg9IjY4cHgiIHpvb21BbmRQYW49Im1hZ25pZnkiPjxkZWZzLz48Zz48bGluZSBzdHlsZT0ic3Ryb2tlOiMxODE4MTg7c3Ryb2tlLXdpZHRoOjAuNTtzdHJva2UtZGFzaGFycmF5OjUuMCw1LjA7IiB4MT0iMTYiIHgyPSIxNiIgeTE9IjM2LjI5NjkiIHkyPSI3MC4yOTY5Ii8+PGxpbmUgc3R5bGU9InN0cm9rZTojMTgxODE4O3N0cm9rZS13aWR0aDowLjU7c3Ryb2tlLWRhc2hhcnJheTo1LjAsNS4wOyIgeDE9IjUwIiB4Mj0iNTAiIHkxPSIzNi4yOTY5IiB5Mj0iNzAuMjk2OSIvPjxyZWN0IGZpbGw9IiNFMkUyRjAiIGhlaWdodD0iMzAuMjk2OSIgcng9IjIuNSIgcnk9IjIuNSIgc3R5bGU9InN0cm9rZTojMTgxODE4O3N0cm9rZS13aWR0aDowLjU7IiB3aWR0aD0iM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bGw9IiMwMDAwMDAiIGZvbnQtZmFtaWx5PSJzYW5zLXNlcmlmIiBmb250LXNpemU9IjE0IiBsZW5ndGhBZGp1c3Q9InNwYWNpbmciIHRleHRMZW5ndGg9IjEwIiB4PSI0NSIgeT0iODkuMjkyIj5CPC90ZXh0Pjxwb2x5Z29uIGZpbGw9IiMxODE4MTgiIHBvaW50cz0iMzgsNDguMjk2OSw0OCw1Mi4yOTY5LDM4LDU2LjI5NjksNDIsNTIuMjk2OSIgc3R5bGU9InN0cm9rZTojMTgxODE4O3N0cm9rZS13aWR0aDoxLjA7Ii8+PGxpbmUgc3R5bGU9InN0cm9rZTojMTgxODE4O3N0cm9rZS13aWR0aDoxLjA7c3Ryb2tlLWRhc2hhcnJheToyLjAsMi4wOyIgeDE9IjE2LjUiIHgyPSI0NCIgeTE9IjUyLjI5NjkiIHkyPSI1Mi4yOTY5Ii8+PCEtLVNSQz1bU3JKR3JSTEpTMDgwXS0tPjwvZz48L3N2Zz4=', @@ -104,13 +108,13 @@ Generated by [AVA](https://avajs.dev). [ { type: 'html', - value: 'plantuml', + value: 'plantuml', }, ] > Snapshot 4 - 'plantuml' + 'plantuml' ## object-base64 diff --git a/test/snapshots/output.mjs.snap b/test/snapshots/output.mjs.snap index 7d478c5..4c5224c 100644 Binary files a/test/snapshots/output.mjs.snap and b/test/snapshots/output.mjs.snap differ