From a4b56e7b971fa81c56a59b465f90c8016f01320d Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 11 Oct 2022 09:54:56 +0200 Subject: 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` --- src/lib.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 02fb5f5..fd0580a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,6 +41,9 @@ use util::{ sanitize_uri::sanitize, }; +#[doc(hidden)] +pub use util::location::Location; + /// Type of line endings in markdown. #[derive(Clone, Debug, Default, Eq, PartialEq)] pub enum LineEnding { @@ -1252,8 +1255,8 @@ pub fn micromark(value: &str) -> String { /// # } /// ``` pub fn micromark_with_options(value: &str, options: &Options) -> Result { - let (events, bytes) = parse(value, &options.parse)?; - Ok(to_html(&events, bytes, &options.compile)) + let (events, parse_state) = parse(value, &options.parse)?; + Ok(to_html(&events, parse_state.bytes, &options.compile)) } /// Turn markdown into a syntax tree. @@ -1279,8 +1282,8 @@ pub fn micromark_with_options(value: &str, options: &Options) -> Result Result { - let (events, bytes) = parse(value, options)?; - let node = to_mdast(&events, bytes)?; + let (events, parse_state) = parse(value, options)?; + let node = to_mdast(&events, parse_state.bytes)?; Ok(node) } -- cgit