diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-10-11 09:54:56 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-10-11 09:55:16 +0200 |
commit | a4b56e7b971fa81c56a59b465f90c8016f01320d (patch) | |
tree | 7002a44087e57c8158a51dd30b6eb89eb260af2b /src/mdast.rs | |
parent | 1fd94f512834aa7bd70f22a60229ce01edfc754e (diff) | |
download | markdown-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 '')
-rw-r--r-- | src/mdast.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/mdast.rs b/src/mdast.rs index 8b5b74d..de53532 100644 --- a/src/mdast.rs +++ b/src/mdast.rs @@ -9,6 +9,10 @@ use alloc::{ vec::Vec, }; +/// Relative byte index into a string, to an absolute byte index into the +/// whole document. +pub type Stop = (usize, usize); + /// Explicitness of a reference. #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum ReferenceKind { @@ -429,7 +433,7 @@ pub enum AttributeContent { /// > | <a {...b} /> /// ^^^^^^ /// ``` - Expression(String), + Expression(String, Vec<Stop>), /// JSX property. /// /// ```markdown @@ -448,7 +452,7 @@ pub enum AttributeValue { /// > | <a b={c} /> /// ^^^ /// ``` - Expression(String), + Expression(String, Vec<Stop>), /// Static value. /// /// ```markdown @@ -1040,6 +1044,9 @@ pub struct MdxjsEsm { pub value: String, /// Positional info. pub position: Option<Position>, + + // Custom data on where each slice of `value` came from. + pub stops: Vec<Stop>, } /// MDX: expression (flow). @@ -1055,6 +1062,9 @@ pub struct MdxFlowExpression { pub value: String, /// Positional info. pub position: Option<Position>, + + // Custom data on where each slice of `value` came from. + pub stops: Vec<Stop>, } /// MDX: expression (text). @@ -1070,6 +1080,9 @@ pub struct MdxTextExpression { pub value: String, /// Positional info. pub position: Option<Position>, + + // Custom data on where each slice of `value` came from. + pub stops: Vec<Stop>, } /// MDX: JSX element (container). |