-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: image compiling #960
fix: image compiling #960
Conversation
processor/utils.ts
Outdated
import { Node } from 'mdast'; | ||
import { MdxJsxFlowElement, MdxJsxTextElement, MdxFlowExpression } from 'mdast-util-mdx'; | ||
import { MdxJsxAttribute } from 'mdast-util-mdx-jsx'; | ||
import { | ||
MdxJsxAttribute, | ||
MdxJsxAttributeValueExpression, | ||
MdxJsxAttributeValueExpressionData, | ||
} from 'mdast-util-mdx-jsx'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these imports all types? can we specify that if so?
import type { Node } from 'mdast';
import type { MdxJsxFlowElement, MdxJsxTextElement, MdxFlowExpression } from 'mdast-util-mdx';
import type {
MdxJsxAttribute,
MdxJsxAttributeValueExpression,
MdxJsxAttributeValueExpressionData,
} from 'mdast-util-mdx-jsx';
processor/utils.ts
Outdated
} else { | ||
const proxy = mdast(`{${v}}`); | ||
const data = proxy.children[0].data as MdxJsxAttributeValueExpressionData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This else
case is a bit hard to reason through without looking at the right test! Mind adding a comment here to clarify why/what the underlying issue is?
} else { | |
const proxy = mdast(`{${v}}`); | |
const data = proxy.children[0].data as MdxJsxAttributeValueExpressionData; | |
} else { | |
/* serialize <Image> components with JSX expressions in | |
* their attributes (i.e. [border={false}]) back to MDX. | |
*/ | |
const proxy = mdast(`{${v}}`); | |
const data = proxy.children[0].data as MdxJsxAttributeValueExpressionData; |
656695d
to
3ed0e8f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appreciate the quick turnaround on my review; reaffirming my approval!
## Version 7.4.2 ### ✨ New & Improved * **Image:** fix alignment oddities ([#956](#956)) ([7382d43](7382d43)), closes [/github.com//pull/956/files#diff-1b96290f278c30bd682c1247de2db226763c471520a387108344a9d53d13de23R19](https://github.com/readmeio//github.com/readmeio/markdown/pull/956/files/issues/diff-1b96290f278c30bd682c1247de2db226763c471520a387108344a9d53d13de23R19) [/github.com//pull/956/files#diff-19c7d495b0c7303322a8a6dcaf6813764594f9e77b9aabc2e5da9a1e274a6d92](https://github.com/readmeio//github.com/readmeio/markdown/pull/956/files/issues/diff-19c7d495b0c7303322a8a6dcaf6813764594f9e77b9aabc2e5da9a1e274a6d92) ### 🛠 Fixes & Updates * image compiling ([#960](#960)) ([6e3a7ac](6e3a7ac)) ### 📘 Tests & Docs * update readme for MDX ([#957](#957)) ([0b5f89b](0b5f89b)) <!--SKIP CI-->
This PR was released!🚀 Changes included in v7.4.2 |
🧰 Changes
Fixes compiling images.
The problem was our naive transformer that could not handle non string attributes. For instance, using a
false
value would crash the compiler:This updates the
toAttributes
method to create the valid AST.🧬 QA & Testing
Do the tests pass?
You could test it locally like:
But that's roughly the same as the tests?