aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_utils/to_hast.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-10-11 09:54:56 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-10-11 09:55:16 +0200
commita4b56e7b971fa81c56a59b465f90c8016f01320d (patch)
tree7002a44087e57c8158a51dd30b6eb89eb260af2b /tests/test_utils/to_hast.rs
parent1fd94f512834aa7bd70f22a60229ce01edfc754e (diff)
downloadmarkdown-rs-a4b56e7b971fa81c56a59b465f90c8016f01320d.tar.gz
markdown-rs-a4b56e7b971fa81c56a59b465f90c8016f01320d.tar.bz2
markdown-rs-a4b56e7b971fa81c56a59b465f90c8016f01320d.zip
Add support for proper positional info in swc tree
* Fix some positional info in SWC error messages * Add positional info in `to_document` on duplicate layouts * Add support for `path` on `Program` (`to_swc`, `to_document`, `jsx_rewrite`), for the path of a file on disk * Add support for `development` to `jsx-rewrite`, which when defined will embed info on where tags were written into the runtime code when they are not passed * Refactor to move some utilities to `micromark_swc_utils.rs`, `swc_utils.rs`
Diffstat (limited to 'tests/test_utils/to_hast.rs')
-rw-r--r--tests/test_utils/to_hast.rs22
1 files changed, 18 insertions, 4 deletions
diff --git a/tests/test_utils/to_hast.rs b/tests/test_utils/to_hast.rs
index 0716daa..4907e23 100644
--- a/tests/test_utils/to_hast.rs
+++ b/tests/test_utils/to_hast.rs
@@ -827,10 +827,23 @@ fn transform_math(_state: &mut State, _node: &mdast::Node, math: &mdast::Math) -
/// [`MdxFlowExpression`][mdast::MdxFlowExpression],[`MdxTextExpression`][mdast::MdxTextExpression].
fn transform_mdx_expression(_state: &mut State, node: &mdast::Node) -> Result {
- Result::Node(hast::Node::MdxExpression(hast::MdxExpression {
- value: node.to_string(),
- position: node.position().cloned(),
- }))
+ match node {
+ mdast::Node::MdxFlowExpression(node) => {
+ Result::Node(hast::Node::MdxExpression(hast::MdxExpression {
+ value: node.value.clone(),
+ position: node.position.clone(),
+ stops: node.stops.clone(),
+ }))
+ }
+ mdast::Node::MdxTextExpression(node) => {
+ Result::Node(hast::Node::MdxExpression(hast::MdxExpression {
+ value: node.value.clone(),
+ position: node.position.clone(),
+ stops: node.stops.clone(),
+ }))
+ }
+ _ => unreachable!("expected expression"),
+ }
}
/// [`MdxJsxFlowElement`][mdast::MdxJsxFlowElement],[`MdxJsxTextElement`][mdast::MdxJsxTextElement].
@@ -858,6 +871,7 @@ fn transform_mdxjs_esm(
Result::Node(hast::Node::MdxjsEsm(hast::MdxjsEsm {
value: mdxjs_esm.value.clone(),
position: mdxjs_esm.position.clone(),
+ stops: mdxjs_esm.stops.clone(),
}))
}