wooorm / markdown-rs

CommonMark compliant markdown parser in Rust with ASTs and extensions
https://docs.rs/markdown/1.0.0-alpha.21/markdown/
MIT License
966 stars 53 forks source link

InvalidFormat Error #132

Closed YSOcean closed 2 months ago

YSOcean commented 2 months ago

if the content of the md file is A<0, the code is as follows: `pub fn parse_md_ast<S: AsRef>(content: S){ markdown::to_mdast(content.as_ref(), &init_parse_option()).map_err(|err| { FormatError::InvalidFormat(format!("parse markdown mdast failed: {err:?}")) });

}Analysis error:InvalidFile(InvalidFormat("parse markdown mdast failed: Message { place: Some(Point(1:3 (2))), reason: \"Unexpected character0(U+0030) before name, expected a character that can start a name, such as a letter,$, or_`\", rule_id: \"unexpected-character\", source: \"markdown-rs\" }"))

wooorm commented 2 months ago

Please read the error message and don’t use invalid MDX. You have not posted any code. And your markdown is garbled. So I assume you used invalid MDX.

YSOcean commented 2 months ago

Thank you,what is MDX? my code: fn init_parse_option() -> ParseOptions { ParseOptions { constructs: Constructs { attention: true, autolink: true, block_quote: true, character_escape: true, character_reference: true, code_indented: true, code_fenced: true, code_text: true, definition: true, frontmatter: true, gfm_autolink_literal: true, gfm_footnote_definition: true, gfm_label_start_footnote: true, gfm_strikethrough: true, gfm_table: true, gfm_task_list_item: true, hard_break_escape: true, hard_break_trailing: true, heading_atx: true, heading_setext: true, html_flow: true, html_text: true, label_start_image: true, label_start_link: true, label_end: true, list_item: true, math_flow: true, math_text: true, mdx_esm: true, mdx_expression_flow: true, mdx_expression_text: true, mdx_jsx_flow: true, mdx_jsx_text: true, thematic_break: true, }, gfm_strikethrough_single_tilde: true, math_text_single_dollar: true, mdx_expression_parse: None, mdx_esm_parse: None, } }

wooorm commented 2 months ago

You are turning on MDX options... If you don’t want MDX, don’t turn on MDX. Please read the readme?