Skip to content

Commit

Permalink
fix(meta/width): bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Airkro committed Mar 4, 2024
1 parent f787259 commit ed934f7
Show file tree
Hide file tree
Showing 6 changed files with 241 additions and 137 deletions.
4 changes: 3 additions & 1 deletion lib/ast.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import kebabCase from 'kebab-case';

function patch({ data }) {
const io = data.estree.body[0].expression.properties[0];

return `${io.key.name}:${io.value.value}`;
return `${kebabCase(io.key.name)}:${io.value.value}`;
}

function attrString(attributes = []) {
Expand Down
15 changes: 12 additions & 3 deletions lib/transform.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function removeXML(string) {
function styleAst(width) {
return {
type: 'mdxJsxAttributeValueExpression',
value: `{ width: '${width}' }`,
value: `{ minWidth: '${width}' }`,
data: {
estree: {
type: 'Program',
Expand All @@ -30,7 +30,7 @@ function styleAst(width) {
computed: false,
key: {
type: 'Identifier',
name: 'width',
name: 'midWidth',
},
value: {
type: 'Literal',
Expand Down Expand Up @@ -203,5 +203,14 @@ export async function transform({ node, server, headers, output, target }) {
delete node[key];
}

Object.assign(node, modes[output]({ diagramType, data, alt, target, width }));
Object.assign(
node,
modes[output]({
diagramType,
data,
alt,
target,
width,
}),
);
}
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "remark-kroki",
"version": "0.3.2",
"version": "0.3.3",
"description": "Remark plugin for showing Kroki diagram",
"license": "MIT",
"author": {
Expand Down Expand Up @@ -50,20 +50,21 @@
},
"dependencies": {
"is-plain-obj": "^4.1.0",
"kebab-case": "^1.0.2",
"markdown-code-block-meta": "^0.0.2",
"node-fetch": "^3.3.2",
"p-memoize": "^7.1.1",
"unist-util-visit": "^5.0.0"
},
"devDependencies": {
"@bring-it/npm": "^0.5.1",
"@bring-it/npm": "^0.5.2",
"@nice-move/cli": "^0.11.3",
"@nice-move/eslint-config-base": "^0.11.1",
"@nice-move/prettier-config": "^0.10.0",
"ava": "^6.1.1",
"eslint": "^8.56.0",
"ava": "^6.1.2",
"eslint": "^8.57.0",
"eslint-plugin-ava": "^14.0.0",
"garou": "^0.7.0",
"garou": "^0.7.1",
"prettier": "^3.2.5",
"remark": "^15.0.1",
"remark-mdx": "^3.0.1",
Expand Down
Loading

0 comments on commit ed934f7

Please sign in to comment.