aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build.rs9
-rw-r--r--examples/lib.rs25
-rw-r--r--readme.md30
-rw-r--r--src/lib.rs435
-rw-r--r--src/parser.rs9
-rw-r--r--src/to_html.rs8
-rw-r--r--tests/attention.rs20
-rw-r--r--tests/autolink.rs20
-rw-r--r--tests/block_quote.rs13
-rw-r--r--tests/character_escape.rs20
-rw-r--r--tests/character_reference.rs19
-rw-r--r--tests/code_fenced.rs15
-rw-r--r--tests/code_indented.rs28
-rw-r--r--tests/code_text.rs20
-rw-r--r--tests/commonmark.rs9
-rw-r--r--tests/definition.rs20
-rw-r--r--tests/frontmatter.rs15
-rw-r--r--tests/fuzz.rs15
-rw-r--r--tests/gfm_autolink_literal.rs9
-rw-r--r--tests/gfm_footnote.rs47
-rw-r--r--tests/gfm_strikethrough.rs23
-rw-r--r--tests/gfm_table.rs102
-rw-r--r--tests/gfm_tagfilter.rs26
-rw-r--r--tests/gfm_task_list_item.rs9
-rw-r--r--tests/hard_break_escape.rs13
-rw-r--r--tests/hard_break_trailing.rs13
-rw-r--r--tests/heading_atx.rs13
-rw-r--r--tests/heading_setext.rs13
-rw-r--r--tests/html_flow.rs61
-rw-r--r--tests/html_text.rs19
-rw-r--r--tests/image.rs20
-rw-r--r--tests/link_reference.rs32
-rw-r--r--tests/link_resource.rs11
-rw-r--r--tests/list.rs23
-rw-r--r--tests/math_flow.rs15
-rw-r--r--tests/math_text.rs47
-rw-r--r--tests/mdx_esm.rs13
-rw-r--r--tests/mdx_expression_flow.rs27
-rw-r--r--tests/mdx_expression_text.rs27
-rw-r--r--tests/mdx_jsx_flow.rs14
-rw-r--r--tests/mdx_jsx_text.rs64
-rw-r--r--tests/mdx_swc.rs23
-rw-r--r--tests/misc_dangerous_html.rs9
-rw-r--r--tests/misc_default_line_ending.rs12
-rw-r--r--tests/misc_line_ending.rs9
-rw-r--r--tests/misc_tabs.rs8
-rw-r--r--tests/thematic_break.rs13
-rw-r--r--tests/xxx_document.rs6
-rw-r--r--tests/xxx_jsx_rewrite.rs6
49 files changed, 941 insertions, 516 deletions
diff --git a/build.rs b/build.rs
index a971d27..8d24e6c 100644
--- a/build.rs
+++ b/build.rs
@@ -68,15 +68,18 @@ async fn commonmark() {
// > It is generate from the latest CommonMark website.
extern crate micromark;
-use micromark::{{micromark_with_options, Options}};
+use micromark::{{micromark_with_options, CompileOptions, Options}};
use pretty_assertions::assert_eq;
#[rustfmt::skip]
#[test]
fn commonmark() -> Result<(), String> {{
let danger = Options {{
- allow_dangerous_html: true,
- allow_dangerous_protocol: true,
+ compile: CompileOptions {{
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ }},
..Options::default()
}};
diff --git a/examples/lib.rs b/examples/lib.rs
index ed108d2..d14f399 100644
--- a/examples/lib.rs
+++ b/examples/lib.rs
@@ -1,5 +1,7 @@
extern crate micromark;
-use micromark::{micromark, micromark_to_mdast, micromark_with_options, Constructs, Options};
+use micromark::{
+ micromark, micromark_to_mdast, micromark_with_options, CompileOptions, Options, ParseOptions,
+};
fn main() -> Result<(), String> {
// Turn on debugging.
@@ -15,8 +17,11 @@ fn main() -> Result<(), String> {
micromark_with_options(
"<div style=\"color: tomato\">\n\n# Hello, tomato!\n\n</div>",
&Options {
- allow_dangerous_html: true,
- allow_dangerous_protocol: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
}
)
@@ -27,24 +32,14 @@ fn main() -> Result<(), String> {
"{}",
micromark_with_options(
"* [x] contact@example.com ~~strikethrough~~",
- &Options {
- constructs: Constructs::gfm(),
- gfm_tagfilter: true,
- ..Options::default()
- }
+ &Options::gfm()
)?
);
// Access syntax tree and support MDX extensions:
println!(
"{:?}",
- micromark_to_mdast(
- "# <HelloMessage />, {username}!",
- &Options {
- constructs: Constructs::mdx(),
- ..Options::default()
- }
- )?
+ micromark_to_mdast("# <HelloMessage />, {username}!", &ParseOptions::mdx())?
);
Ok(())
diff --git a/readme.md b/readme.md
index 91b7985..1afce35 100644
--- a/readme.md
+++ b/readme.md
@@ -92,17 +92,14 @@ Extensions (in this case GFM):
```rs
extern crate micromark;
-use micromark::{micromark_with_options, Constructs, Options};
+use micromark::{micromark_with_options, Options};
fn main() -> Result<(), String> {
println!(
"{}",
micromark_with_options(
"* [x] contact@example.com ~~strikethrough~~",
- &Options {
- constructs: Constructs::gfm(),
- ..Options::default()
- }
+ &Options::gfm()
)?
);
@@ -122,6 +119,29 @@ Yields:
</ul>
```
+Syntax tree:
+
+```rs
+extern crate micromark;
+use micromark::{micromark_to_mdast, ParseOptions};
+
+fn main() -> Result<(), String> {
+ println!(
+ "{:?}",
+ micromark_to_mdast("# Hey, *you*!", &ParseOptions::default())?
+ );
+
+ Ok(())
+}
+```
+
+Yields:
+
+```text
+Root { children: [Heading { children: [Text { value: "Hey, ", position: Some(1:3-1:8 (2-7)) }, Emphasis { children: [Text { value: "you", position: Some(1:9-1:12 (8-11)) }], position: Some(1:8-1:13 (7-12)) }, Text { value: "!", position: Some(1:13-1:14 (12-13)) }], position: Some(1:1-1:14 (0-13)), depth: 1 }], position: Some(1:1-1:14 (0-13)) }
+
+```
+
## API
`micromark` exposes
diff --git a/src/lib.rs b/src/lib.rs
index 8eaa2bb..02fb5f5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -168,7 +168,7 @@ pub type MdxEsmParse = dyn Fn(&str) -> MdxSignal;
/// Not all constructs can be configured.
/// Notably, blank lines and paragraphs cannot be turned off.
#[allow(clippy::struct_excessive_bools)]
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Constructs {
/// Attention.
///
@@ -392,9 +392,9 @@ pub struct Constructs {
/// ^^^^^^^^^^^^^^^^^
/// ```
///
- /// > 👉 **Note**: you *must* pass [`options.mdx_esm_parse`][MdxEsmParse]
- /// > too.
- /// > Otherwise, this option has no affect.
+ /// > 👉 **Note**: you *must* pass [`mdx_esm_parse`][MdxEsmParse]
+ /// > in [`ParseOptions`][] too.
+ /// > Otherwise, this option has no effect.
pub mdx_esm: bool,
/// MDX: expression (flow).
///
@@ -522,10 +522,10 @@ impl Constructs {
/// (autolinks, code (indented), html), and turns on MDX (JSX,
/// expressions, ESM).
///
- /// > 👉 **Note**: you *must* pass [`options.mdx_esm_parse`][MdxEsmParse]
- /// > to support ESM.
+ /// > 👉 **Note**: you *must* pass [`mdx_esm_parse`][MdxEsmParse]
+ /// > in [`ParseOptions`][] too to support ESM.
/// > You *can* pass
- /// > [`options.mdx_expression_parse`][MdxExpressionParse]
+ /// > [`mdx_expression_parse`][MdxExpressionParse]
/// > to parse expressions according to a certain grammar (typically, a
/// > programming language).
#[must_use]
@@ -545,10 +545,10 @@ impl Constructs {
}
}
-/// Configuration (optional).
+/// Configuration that describes how to compile to HTML.
#[allow(clippy::struct_excessive_bools)]
-pub struct Options {
- // Note: when adding fields, don’t forget to add them to `fmt::Debug` below.
+#[derive(Clone, Debug, Default)]
+pub struct CompileOptions {
/// Whether to allow (dangerous) HTML.
/// The default is `false`, you can turn it on to `true` for trusted
/// content.
@@ -556,7 +556,7 @@ pub struct Options {
/// ## Examples
///
/// ```
- /// use micromark::{micromark, micromark_with_options, Options};
+ /// use micromark::{micromark, micromark_with_options, CompileOptions, Options};
/// # fn main() -> Result<(), String> {
///
/// // micromark is safe by default:
@@ -570,7 +570,10 @@ pub struct Options {
/// micromark_with_options(
/// "Hi, <i>venus</i>!",
/// &Options {
- /// allow_dangerous_html: true,
+ /// compile: CompileOptions {
+ /// allow_dangerous_html: true,
+ /// ..CompileOptions::default()
+ /// },
/// ..Options::default()
/// }
/// )?,
@@ -588,7 +591,7 @@ pub struct Options {
/// ## Examples
///
/// ```
- /// use micromark::{micromark, micromark_with_options, Options};
+ /// use micromark::{micromark, micromark_with_options, CompileOptions, Options};
/// # fn main() -> Result<(), String> {
///
/// // micromark is safe by default:
@@ -602,7 +605,10 @@ pub struct Options {
/// micromark_with_options(
/// "<javascript:alert(1)>",
/// &Options {
- /// allow_dangerous_protocol: true,
+ /// compile: CompileOptions {
+ /// allow_dangerous_protocol: true,
+ /// ..CompileOptions::default()
+ /// },
/// ..Options::default()
/// }
/// )?,
@@ -613,41 +619,8 @@ pub struct Options {
/// ```
pub allow_dangerous_protocol: bool,
- /// Which constructs to enable and disable.
- /// The default is to follow `CommonMark`.
- ///
- /// ## Examples
- ///
- /// ```
- /// use micromark::{micromark, micromark_with_options, Options, Constructs};
- /// # fn main() -> Result<(), String> {
- ///
- /// // micromark follows CommonMark by default:
- /// assert_eq!(
- /// micromark(" indented code?"),
- /// "<pre><code>indented code?\n</code></pre>"
- /// );
- ///
- /// // Pass `constructs` to choose what to enable and disable:
- /// assert_eq!(
- /// micromark_with_options(
- /// " indented code?",
- /// &Options {
- /// constructs: Constructs {
- /// code_indented: false,
- /// ..Constructs::default()
- /// },
- /// ..Options::default()
- /// }
- /// )?,
- /// "<p>indented code?</p>"
- /// );
- /// # Ok(())
- /// # }
- /// ```
- pub constructs: Constructs,
-
- /// Default line ending to use, for line endings not in `value`.
+ /// Default line ending to use when compiling to HTML, for line endings not
+ /// in `value`.
///
/// Generally, micromark copies line endings (`\r`, `\n`, `\r\n`) in the
/// markdown document over to the compiled HTML.
@@ -662,7 +635,7 @@ pub struct Options {
/// ## Examples
///
/// ```
- /// use micromark::{micromark, micromark_with_options, Options, LineEnding};
+ /// use micromark::{micromark, micromark_with_options, CompileOptions, LineEnding, Options};
/// # fn main() -> Result<(), String> {
///
/// // micromark uses `\n` by default:
@@ -676,7 +649,10 @@ pub struct Options {
/// micromark_with_options(
/// "> a",
/// &Options {
- /// default_line_ending: LineEnding::CarriageReturnLineFeed,
+ /// compile: CompileOptions {
+ /// default_line_ending: LineEnding::CarriageReturnLineFeed,
+ /// ..CompileOptions::default()
+ /// },
/// ..Options::default()
/// }
/// )?,
@@ -696,17 +672,14 @@ pub struct Options {
/// ## Examples
///
/// ```
- /// use micromark::{micromark, micromark_with_options, Options, Constructs};
+ /// use micromark::{micromark, micromark_with_options, CompileOptions, Options, ParseOptions};
/// # fn main() -> Result<(), String> {
///
/// // `"Footnotes"` is used by default:
/// assert_eq!(
/// micromark_with_options(
/// "[^a]\n\n[^a]: b",
- /// &Options {
- /// constructs: Constructs::gfm(),
- /// ..Options::default()
- /// }
+ /// &Options::gfm()
/// )?,
/// "<p><sup><a href=\"#user-content-fn-a\" id=\"user-content-fnref-a\" data-footnote-ref=\"\" aria-describedby=\"footnote-label\">1</a></sup></p>\n<section data-footnotes=\"\" class=\"footnotes\"><h2 id=\"footnote-label\" class=\"sr-only\">Footnotes</h2>\n<ol>\n<li id=\"user-content-fn-a\">\n<p>b <a href=\"#user-content-fnref-a\" data-footnote-backref=\"\" aria-label=\"Back to content\" class=\"data-footnote-backref\">↩</a></p>\n</li>\n</ol>\n</section>\n"
/// );
@@ -716,9 +689,11 @@ pub struct Options {
/// micromark_with_options(
/// "[^a]\n\n[^a]: b",
/// &Options {
- /// constructs: Constructs::gfm(),
- /// gfm_footnote_label: Some("Notes de bas de page".to_string()),
- /// ..Options::default()
+ /// parse: ParseOptions::gfm(),
+ /// compile: CompileOptions {
+ /// gfm_footnote_label: Some("Notes de bas de page".to_string()),
+ /// ..CompileOptions::gfm()
+ /// }
/// }
/// )?,
/// "<p><sup><a href=\"#user-content-fn-a\" id=\"user-content-fnref-a\" data-footnote-ref=\"\" aria-describedby=\"footnote-label\">1</a></sup></p>\n<section data-footnotes=\"\" class=\"footnotes\"><h2 id=\"footnote-label\" class=\"sr-only\">Notes de bas de page</h2>\n<ol>\n<li id=\"user-content-fn-a\">\n<p>b <a href=\"#user-content-fnref-a\" data-footnote-backref=\"\" aria-label=\"Back to content\" class=\"data-footnote-backref\">↩</a></p>\n</li>\n</ol>\n</section>\n"
@@ -735,17 +710,14 @@ pub struct Options {
/// ## Examples
///
/// ```
- /// use micromark::{micromark, micromark_with_options, Options, Constructs};
+ /// use micromark::{micromark, micromark_with_options, CompileOptions, Options, ParseOptions};
/// # fn main() -> Result<(), String> {
///
/// // `"h2"` is used by default:
/// assert_eq!(
/// micromark_with_options(
/// "[^a]\n\n[^a]: b",
- /// &Options {
- /// constructs: Constructs::gfm(),
- /// ..Options::default()
- /// }
+ /// &Options::gfm()
/// )?,
/// "<p><sup><a href=\"#user-content-fn-a\" id=\"user-content-fnref-a\" data-footnote-ref=\"\" aria-describedby=\"footnote-label\">1</a></sup></p>\n<section data-footnotes=\"\" class=\"footnotes\"><h2 id=\"footnote-label\" class=\"sr-only\">Footnotes</h2>\n<ol>\n<li id=\"user-content-fn-a\">\n<p>b <a href=\"#user-content-fnref-a\" data-footnote-backref=\"\" aria-label=\"Back to content\" class=\"data-footnote-backref\">↩</a></p>\n</li>\n</ol>\n</section>\n"
/// );
@@ -755,9 +727,11 @@ pub struct Options {
/// micromark_with_options(
/// "[^a]\n\n[^a]: b",
/// &Options {
- /// constructs: Constructs::gfm(),
- /// gfm_footnote_label_tag_name: Some("h1".to_string()),
- /// ..Options::default()
+ /// parse: ParseOptions::gfm(),
+ /// compile: CompileOptions {
+ /// gfm_footnote_label_tag_name: Some("h1".to_string()),
+ /// ..CompileOptions::gfm()
+ /// }
/// }
/// )?,
/// "<p><sup><a href=\"#user-content-fn-a\" id=\"user-content-fnref-a\" data-footnote-ref=\"\" aria-describedby=\"footnote-label\">1</a></sup></p>\n<section data-footnotes=\"\" class=\"footnotes\"><h1 id=\"footnote-label\" class=\"sr-only\">Footnotes</h1>\n<ol>\n<li id=\"user-content-fn-a\">\n<p>b <a href=\"#user-content-fnref-a\" data-footnote-backref=\"\" aria-label=\"Back to content\" class=\"data-footnote-backref\">↩</a></p>\n</li>\n</ol>\n</section>\n"
@@ -780,17 +754,14 @@ pub struct Options {
/// ## Examples
///
/// ```
- /// use micromark::{micromark, micromark_with_options, Options, Constructs};
+ /// use micromark::{micromark, micromark_with_options, CompileOptions, Options, ParseOptions};
/// # fn main() -> Result<(), String> {
///
/// // `"class=\"sr-only\""` is used by default:
/// assert_eq!(
/// micromark_with_options(
/// "[^a]\n\n[^a]: b",
- /// &Options {
- /// constructs: Constructs::gfm(),
- /// ..Options::default()
- /// }
+ /// &Options::gfm()
/// )?,
/// "<p><sup><a href=\"#user-content-fn-a\" id=\"user-content-fnref-a\" data-footnote-ref=\"\" aria-describedby=\"footnote-label\">1</a></sup></p>\n<section data-footnotes=\"\" class=\"footnotes\"><h2 id=\"footnote-label\" class=\"sr-only\">Footnotes</h2>\n<ol>\n<li id=\"user-content-fn-a\">\n<p>b <a href=\"#user-content-fnref-a\" data-footnote-backref=\"\" aria-label=\"Back to content\" class=\"data-footnote-backref\">↩</a></p>\n</li>\n</ol>\n</section>\n"
/// );
@@ -800,9 +771,11 @@ pub struct Options {
/// micromark_with_options(
/// "[^a]\n\n[^a]: b",
/// &Options {
- /// constructs: Constructs::gfm(),
- /// gfm_footnote_label_attributes: Some("class=\"footnote-heading\"".to_string()),
- /// ..Options::default()
+ /// parse: ParseOptions::gfm(),
+ /// compile: CompileOptions {
+ /// gfm_footnote_label_attributes: Some("class=\"footnote-heading\"".to_string()),
+ /// ..CompileOptions::gfm()
+ /// }
/// }
/// )?,
/// "<p><sup><a href=\"#user-content-fn-a\" id=\"user-content-fnref-a\" data-footnote-ref=\"\" aria-describedby=\"footnote-label\">1</a></sup></p>\n<section data-footnotes=\"\" class=\"footnotes\"><h2 id=\"footnote-label\" class=\"footnote-heading\">Footnotes</h2>\n<ol>\n<li id=\"user-content-fn-a\">\n<p>b <a href=\"#user-content-fnref-a\" data-footnote-backref=\"\" aria-label=\"Back to content\" class=\"data-footnote-backref\">↩</a></p>\n</li>\n</ol>\n</section>\n"
@@ -820,17 +793,14 @@ pub struct Options {
/// ## Examples
///
/// ```
- /// use micromark::{micromark, micromark_with_options, Options, Constructs};
+ /// use micromark::{micromark, micromark_with_options, CompileOptions, Options, ParseOptions};
/// # fn main() -> Result<(), String> {
///
/// // `"Back to content"` is used by default:
/// assert_eq!(
/// micromark_with_options(
/// "[^a]\n\n[^a]: b",
- /// &Options {
- /// constructs: Constructs::gfm(),
- /// ..Options::default()
- /// }
+ /// &Options::gfm()
/// )?,
/// "<p><sup><a href=\"#user-content-fn-a\" id=\"user-content-fnref-a\" data-footnote-ref=\"\" aria-describedby=\"footnote-label\">1</a></sup></p>\n<section data-footnotes=\"\" class=\"footnotes\"><h2 id=\"footnote-label\" class=\"sr-only\">Footnotes</h2>\n<ol>\n<li id=\"user-content-fn-a\">\n<p>b <a href=\"#user-content-fnref-a\" data-footnote-backref=\"\" aria-label=\"Back to content\" class=\"data-footnote-backref\">↩</a></p>\n</li>\n</ol>\n</section>\n"
/// );
@@ -840,9 +810,11 @@ pub struct Options {
/// micromark_with_options(
/// "[^a]\n\n[^a]: b",
/// &Options {
- /// constructs: Constructs::gfm(),
- /// gfm_footnote_back_label: Some("Arrière".to_string()),
- /// ..Options::default()
+ /// parse: ParseOptions::gfm(),
+ /// compile: CompileOptions {
+ /// gfm_footnote_back_label: Some("Arrière".to_string()),
+ /// ..CompileOptions::gfm()
+ /// }
/// }
/// )?,
/// "<p><sup><a href=\"#user-content-fn-a\" id=\"user-content-fnref-a\" data-footnote-ref=\"\" aria-describedby=\"footnote-label\">1</a></sup></p>\n<section data-footnotes=\"\" class=\"footnotes\"><h2 id=\"footnote-label\" class=\"sr-only\">Footnotes</h2>\n<ol>\n<li id=\"user-content-fn-a\">\n<p>b <a href=\"#user-content-fnref-a\" data-footnote-backref=\"\" aria-label=\"Arrière\" class=\"data-footnote-backref\">↩</a></p>\n</li>\n</ol>\n</section>\n"
@@ -870,17 +842,14 @@ pub struct Options {
/// ## Examples
///
/// ```
- /// use micromark::{micromark, micromark_with_options, Options, Constructs};
+ /// use micromark::{micromark, micromark_with_options, CompileOptions, Options, ParseOptions};
/// # fn main() -> Result<(), String> {
///
/// // `"user-content-"` is used by default:
/// assert_eq!(
/// micromark_with_options(
/// "[^a]\n\n[^a]: b",
- /// &Options {
- /// constructs: Constructs::gfm(),
- /// ..Options::default()
- /// }
+ /// &Options::gfm()
/// )?,
/// "<p><sup><a href=\"#user-content-fn-a\" id=\"user-content-fnref-a\" data-footnote-ref=\"\" aria-describedby=\"footnote-label\">1</a></sup></p>\n<section data-footnotes=\"\" class=\"footnotes\"><h2 id=\"footnote-label\" class=\"sr-only\">Footnotes</h2>\n<ol>\n<li id=\"user-content-fn-a\">\n<p>b <a href=\"#user-content-fnref-a\" data-footnote-backref=\"\" aria-label=\"Back to content\" class=\"data-footnote-backref\">↩</a></p>\n</li>\n</ol>\n</section>\n"
/// );
@@ -890,9 +859,11 @@ pub struct Options {
/// micromark_with_options(
/// "[^a]\n\n[^a]: b",
/// &Options {
- /// constructs: Constructs::gfm(),
- /// gfm_footnote_clobber_prefix: Some("".to_string()),
- /// ..Options::default()
+ /// parse: ParseOptions::gfm(),
+ /// compile: CompileOptions {
+ /// gfm_footnote_clobber_prefix: Some("".to_string()),
+ /// ..CompileOptions::gfm()
+ /// }
/// }
/// )?,
/// "<p><sup><a href=\"#fn-a\" id=\"fnref-a\" data-footnote-ref=\"\" aria-describedby=\"footnote-label\">1</a></sup></p>\n<section data-footnotes=\"\" class=\"footnotes\"><h2 id=\"footnote-label\" class=\"sr-only\">Footnotes</h2>\n<ol>\n<li id=\"fn-a\">\n<p>b <a href=\"#fnref-a\" data-footnote-backref=\"\" aria-label=\"Back to content\" class=\"data-footnote-backref\">↩</a></p>\n</li>\n</ol>\n</section>\n"
@@ -902,94 +873,161 @@ pub struct Options {
/// ```
pub gfm_footnote_clobber_prefix: Option<String>,
- /// Whether to support GFM strikethrough (if enabled in `constructs`) with
- /// a single tilde (default: `true`).
+ /// Whether to support the GFM tagfilter, when `allow_dangerous_html` is on
+ /// (default: `false`).
///
- /// Single tildes work on github.com but are technically prohibited by GFM.
+ /// The tagfilter is kinda weird and kinda useless.
+ /// The tag filter is a naïve attempt at XSS protection.
+ /// You should use a proper HTML sanitizing algorithm.
///
/// ## Examples
///
/// ```
- /// use micromark::{micromark, micromark_with_options, Options, Constructs};
+ /// use micromark::{micromark_with_options, CompileOptions, Options, ParseOptions};
/// # fn main() -> Result<(), String> {
///
- /// // micromark supports single tildes by default:
+ /// // With `allow_dangerous_html`, micromark passes HTML through untouched:
/// assert_eq!(
/// micromark_with_options(
- /// "~a~",
+ /// "<iframe>",
/// &Options {
- /// constructs: Constructs::gfm(),
- /// ..Options::default()
+ /// parse: ParseOptions::gfm(),
+ /// compile: CompileOptions {
+ /// allow_dangerous_html: true,
+ /// ..CompileOptions::default()
+ /// }
/// }
/// )?,
- /// "<p><del>a</del></p>"
+ /// "<iframe>"
/// );
///
- /// // Pass `gfm_strikethrough_single_tilde: false` to turn that off:
+ /// // Pass `gfm_tagfilter: true` to make some of that safe:
/// assert_eq!(
/// micromark_with_options(
- /// "~a~",
+ /// "<iframe>",
+ /// &Options {
+ /// parse: ParseOptions::gfm(),
+ /// compile: CompileOptions {
+ /// allow_dangerous_html: true,
+ /// gfm_tagfilter: true,
+ /// ..CompileOptions::default()
+ /// }
+ /// }
+ /// )?,
+ /// "&lt;iframe>"
+ /// );
+ /// # Ok(())
+ /// # }
+ /// ```
+ ///
+ /// ## References
+ ///
+ /// * [*§ 6.1 Disallowed Raw HTML (extension)* in GFM](https://github.github.com/gfm/#disallowed-raw-html-extension-)
+ /// * [`cmark-gfm#extensions/tagfilter.c`](https://github.com/github/cmark-gfm/blob/master/extensions/tagfilter.c)
+ pub gfm_tagfilter: bool,
+}
+
+impl CompileOptions {
+ /// GFM.
+ ///
+ /// <https://github.github.com/gfm/>
+ ///
+ /// This turns on the GFM tag filter (which is pretty useless).
+ #[must_use]
+ pub fn gfm() -> Self {
+ Self {
+ gfm_tagfilter: true,
+ ..Self::default()
+ }
+ }
+}
+
+/// Configuration that describes how to parse from markdown.
+#[allow(clippy::struct_excessive_bools)]
+pub struct ParseOptions {
+ // Note: when adding fields, don’t forget to add them to `fmt::Debug` below.
+ /// Which constructs to enable and disable.
+ /// The default is to follow `CommonMark`.
+ ///
+ /// ## Examples
+ ///
+ /// ```
+ /// use micromark::{micromark, micromark_with_options, Constructs, Options, ParseOptions};
+ /// # fn main() -> Result<(), String> {
+ ///
+ /// // micromark follows CommonMark by default:
+ /// assert_eq!(
+ /// micromark(" indented code?"),
+ /// "<pre><code>indented code?\n</code></pre>"
+ /// );
+ ///
+ /// // Pass `constructs` to choose what to enable and disable:
+ /// assert_eq!(
+ /// micromark_with_options(
+ /// " indented code?",
/// &Options {
- /// constructs: Constructs::gfm(),
- /// gfm_strikethrough_single_tilde: false,
+ /// parse: ParseOptions {
+ /// constructs: Constructs {
+ /// code_indented: false,
+ /// ..Constructs::default()
+ /// },
+ /// ..ParseOptions::default()
+ /// },
/// ..Options::default()
/// }
/// )?,
- /// "<p>~a~</p>"
+ /// "<p>indented code?</p>"
/// );
/// # Ok(())
/// # }
/// ```
- pub gfm_strikethrough_single_tilde: bool,
+ pub constructs: Constructs,
- /// Whether to support the GFM tagfilter, when `allow_dangerous_html` is on
- /// (default: `false`).
+ /// Whether to support GFM strikethrough (if enabled in `constructs`) with
+ /// a single tilde (default: `true`).
///
- /// The tagfilter is kinda weird and kinda useless.
- /// The tag filter is a naïve attempt at XSS protection.
- /// You should use a proper HTML sanitizing algorithm.
+ /// Single tildes work on github.com but are technically prohibited by GFM.
///
/// ## Examples
///
/// ```
- /// use micromark::{micromark_with_options, Options, Constructs};
+ /// use micromark::{micromark, micromark_with_options, Constructs, Options, ParseOptions};
/// # fn main() -> Result<(), String> {
///
- /// // With `allow_dangerous_html`, micromark passes HTML through untouched:
+ /// // micromark supports single tildes by default:
/// assert_eq!(
/// micromark_with_options(
- /// "<iframe>",
+ /// "~a~",
/// &Options {
- /// allow_dangerous_html: true,
- /// constructs: Constructs::gfm(),
+ /// parse: ParseOptions {
+ /// constructs: Constructs::gfm(),
+ /// ..ParseOptions::default()
+ /// },
/// ..Options::default()
/// }
/// )?,
- /// "<iframe>"
+ /// "<p><del>a</del></p>"
/// );
///
- /// // Pass `gfm_tagfilter: true` to make some of that safe:
+ /// // Pass `gfm_strikethrough_single_tilde: false` to turn that off:
/// assert_eq!(
/// micromark_with_options(
- /// "<iframe>",
+ /// "~a~",
/// &Options {
- /// allow_dangerous_html: true,
- /// constructs: Constructs::gfm(),
- /// gfm_tagfilter: true,
+ /// parse: ParseOptions {
+ /// constructs: Constructs::gfm(),
+ /// gfm_strikethrough_single_tilde: false,
+ /// ..ParseOptions::default()
+ /// },
/// ..Options::default()
/// }
/// )?,
- /// "&lt;iframe>"
+ /// "<p>~a~</p>"
/// );
/// # Ok(())
/// # }
/// ```
- ///
- /// ## References
- ///
- /// * [*§ 6.1 Disallowed Raw HTML (extension)* in GFM](https://github.github.com/gfm/#disallowed-raw-html-extension-)
- /// * [`cmark-gfm#extensions/tagfilter.c`](https://github.com/github/cmark-gfm/blob/master/extensions/tagfilter.c)
- pub gfm_tagfilter: bool,
+ pub gfm_strikethrough_single_tilde: bool,
/// Whether to support math (text) (if enabled in `constructs`) with a
/// single dollar (default: `true`).
@@ -1000,7 +1038,7 @@ pub struct Options {
/// ## Examples
///
/// ```
- /// use micromark::{micromark, micromark_with_options, Options, Constructs};
+ /// use micromark::{micromark, micromark_with_options, Constructs, Options, ParseOptions};
/// # fn main() -> Result<(), String> {
///
/// // micromark supports single dollars by default:
@@ -1008,9 +1046,12 @@ pub struct Options {
/// micromark_with_options(
/// "$a$",
/// &Options {
- /// constructs: Constructs {
+ /// parse: ParseOptions {
+ /// constructs: Constructs {
/// math_text: true,
/// ..Constructs::default()
+ /// },
+ /// ..ParseOptions::default()
/// },
/// ..Options::default()
/// }
@@ -1023,11 +1064,14 @@ pub struct Options {
/// micromark_with_options(
/// "$a$",
/// &Options {
- /// constructs: Constructs {
+ /// parse: ParseOptions {
+ /// constructs: Constructs {
/// math_text: true,
/// ..Constructs::default()
+ /// },
+ /// math_text_single_dollar: false,
+ /// ..ParseOptions::default()
/// },
- /// math_text_single_dollar: false,
/// ..Options::default()
/// }
/// )?,
@@ -1040,6 +1084,9 @@ pub struct Options {
/// Function to parse expressions with.
///
+ /// It only makes sense to pass this when compiling to a syntax tree
+ /// with [`micromark_to_mdast`][].
+ ///
/// This can be used to parse expressions with a parser.
/// It can be used to support for arbitrary programming languages within
/// expressions.
@@ -1050,6 +1097,9 @@ pub struct Options {
/// Function to parse ESM with.
///
+ /// It only makes sense to pass this when compiling to a syntax tree
+ /// with [`micromark_to_mdast`][].
+ ///
/// This can be used to parse ESM with a parser.
/// It can be used to support for arbitrary programming languages within
/// ESM, however, the keywords (`export`, `import`) are currently hardcoded
@@ -1061,32 +1111,14 @@ pub struct Options {
// Note: when adding fields, don’t forget to add them to `fmt::Debug` below.
}
-impl fmt::Debug for Options {
+impl fmt::Debug for ParseOptions {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- f.debug_struct("Options")
- .field("allow_dangerous_html", &self.allow_dangerous_html)
- .field("allow_dangerous_protocol", &self.allow_dangerous_protocol)
+ f.debug_struct("ParseOptions")
.field("constructs", &self.constructs)
- .field("default_line_ending", &self.default_line_ending)
- .field("gfm_footnote_label", &self.gfm_footnote_label)
- .field(
- "gfm_footnote_label_tag_name",
- &self.gfm_footnote_label_tag_name,
- )
- .field(
- "gfm_footnote_label_attributes",
- &self.gfm_footnote_label_attributes,
- )
- .field("gfm_footnote_back_label", &self.gfm_footnote_back_label)
- .field(
- "gfm_footnote_clobber_prefix",
- &self.gfm_footnote_clobber_prefix,
- )
.field(
"gfm_strikethrough_single_tilde",
&self.gfm_strikethrough_single_tilde,
)
- .field("gfm_tagfilter", &self.gfm_tagfilter)
.field("math_text_single_dollar", &self.math_text_single_dollar)
.field(
"mdx_expression_parse",
@@ -1100,21 +1132,12 @@ impl fmt::Debug for Options {
}
}
-impl Default for Options {
- /// Safe `CommonMark` defaults.
+impl Default for ParseOptions {
+ /// `CommonMark` defaults.
fn default() -> Self {
Self {
- allow_dangerous_html: false,
- allow_dangerous_protocol: false,
constructs: Constructs::default(),
- default_line_ending: LineEnding::default(),
- gfm_footnote_label: None,
- gfm_footnote_label_tag_name: None,
- gfm_footnote_label_attributes: None,
- gfm_footnote_back_label: None,
- gfm_footnote_clobber_prefix: None,
gfm_strikethrough_single_tilde: true,
- gfm_tagfilter: false,
math_text_single_dollar: true,
mdx_expression_parse: None,
mdx_esm_parse: None,
@@ -1122,6 +1145,68 @@ impl Default for Options {
}
}
+impl ParseOptions {
+ /// GFM.
+ ///
+ /// <https://github.github.com/gfm/>
+ ///
+ /// This turns on `CommonMark` + GFM.
+ #[must_use]
+ pub fn gfm() -> Self {
+ Self {
+ constructs: Constructs::gfm(),
+ ..Self::default()
+ }
+ }
+
+ /// MDX.
+ ///
+ /// <https://mdxjs.com>
+ ///
+ /// This turns on `CommonMark`, turns off some conflicting constructs
+ /// (autolinks, code (indented), html), and turns on MDX (JSX,
+ /// expressions, ESM).
+ ///
+ /// > 👉 **Note**: you *must* pass [`mdx_esm_parse`][MdxEsmParse]
+ /// > too to support ESM.
+ /// > You *can* pass
+ /// > [`mdx_expression_parse`][MdxExpressionParse]
+ /// > to parse expressions according to a certain grammar (typically, a
+ /// > programming language).
+ #[must_use]
+ pub fn mdx() -> Self {
+ Self {
+ constructs: Constructs::mdx(),
+ ..Self::default()
+ }
+ }
+}
+
+/// Configuration (optional).
+#[allow(clippy::struct_excessive_bools)]
+#[derive(Debug, Default)]
+pub struct Options {
+ /// Configuration that describes how to parse from markdown.
+ pub parse: ParseOptions,
+ /// Configuration that describes how to compile to HTML.
+ pub compile: CompileOptions,
+}
+
+impl Options {
+ /// GFM.
+ ///
+ /// <https://github.github.com/gfm/>
+ ///
+ /// This turns on `CommonMark` + GFM.
+ #[must_use]
+ pub fn gfm() -> Self {
+ Self {
+ parse: ParseOptions::gfm(),
+ compile: CompileOptions::gfm(),
+ }
+ }
+}
+
/// Turn markdown into HTML.
///
/// ## Examples
@@ -1150,12 +1235,15 @@ pub fn micromark(value: &str) -> String {
/// ## Examples
///
/// ```
-/// use micromark::{micromark_with_options, Options};
+/// use micromark::{micromark_with_options, CompileOptions, Options};
/// # fn main() -> Result<(), String> {
///
/// let result = micromark_with_options("<div>\n\n# Hello, world!\n\n</div>", &Options {
-/// allow_dangerous_html: true,
-/// allow_dangerous_protocol: true,
+/// compile: CompileOptions {
+/// allow_dangerous_html: true,
+/// allow_dangerous_protocol: true,
+/// ..CompileOptions::default()
+/// },
/// ..Options::default()
/// })?;
///
@@ -1164,8 +1252,8 @@ pub fn micromark(value: &str) -> String {
/// # }
/// ```
pub fn micromark_with_options(value: &str, options: &Options) -> Result<String, String> {
- let (events, bytes) = parse(value, options)?;
- Ok(to_html(&events, bytes, options))
+ let (events, bytes) = parse(value, &options.parse)?;
+ Ok(to_html(&events, bytes, &options.compile))
}
/// Turn markdown into a syntax tree.
@@ -1181,16 +1269,16 @@ pub fn micromark_with_options(value: &str, options: &Options) -> Result<String,
/// ## Examples
///
/// ```
-/// use micromark::{micromark_to_mdast, Options};
+/// use micromark::{micromark_to_mdast, ParseOptions};
/// # fn main() -> Result<(), String> {
///
-/// let tree = micromark_to_mdast("# hi!", &Options::default())?;
+/// let tree = micromark_to_mdast("# hi!", &ParseOptions::default())?;
///
/// println!("{:?}", tree);
/// # Ok(())
/// # }
/// ```
-pub fn micromark_to_mdast(value: &str, options: &Options) -> Result<Node, String> {
+pub fn micromark_to_mdast(value: &str, options: &ParseOptions) -> Result<Node, String> {
let (events, bytes) = parse(value, options)?;
let node = to_mdast(&events, bytes)?;
Ok(node)
@@ -1198,18 +1286,21 @@ pub fn micromark_to_mdast(value: &str, options: &Options) -> Result<Node, String
/// Do not use: exported for quick prototyping, will be removed.
#[must_use]
+#[doc(hidden)]
pub fn sanitize_(value: &str) -> String {
sanitize(value)
}
/// Do not use: exported for quick prototyping, will be removed.
#[must_use]
+#[doc(hidden)]
pub fn id_start_(char: char) -> bool {
id_start(char)
}
/// Do not use: exported for quick prototyping, will be removed.
#[must_use]
+#[doc(hidden)]
pub fn id_cont_(char: char, jsx: bool) -> bool {
id_cont(char, jsx)
}
diff --git a/src/parser.rs b/src/parser.rs
index c69eb38..b694bc5 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -4,7 +4,7 @@ use crate::event::{Event, Point};
use crate::state::{Name as StateName, State};
use crate::subtokenize::subtokenize;
use crate::tokenizer::Tokenizer;
-use crate::Options;
+use crate::ParseOptions;
use alloc::{string::String, vec, vec::Vec};
/// Info needed, in all content types, when parsing markdown.
@@ -14,7 +14,7 @@ use alloc::{string::String, vec, vec::Vec};
#[derive(Debug)]
pub struct ParseState<'a> {
/// Configuration.
- pub options: &'a Options,
+ pub options: &'a ParseOptions,
/// List of chars.
pub bytes: &'a [u8],
/// Set of defined definition identifiers.
@@ -26,7 +26,10 @@ pub struct ParseState<'a> {
/// Turn a string of markdown into events.
///
/// Passes the bytes back so the compiler can access the source.
-pub fn parse<'a>(value: &'a str, options: &'a Options) -> Result<(Vec<Event>, &'a [u8]), String> {
+pub fn parse<'a>(
+ value: &'a str,
+ options: &'a ParseOptions,
+) -> Result<(Vec<Event>, &'a [u8]), String> {
let mut parse_state = ParseState {
options,
bytes: value.as_bytes(),
diff --git a/src/to_html.rs b/src/to_html.rs
index 814f7cf..a0ab152 100644
--- a/src/to_html.rs
+++ b/src/to_html.rs
@@ -12,7 +12,7 @@ use crate::util::{
skip,
slice::{Position, Slice},
};
-use crate::{LineEnding, Options};
+use crate::{CompileOptions, LineEnding};
use alloc::{
format,
string::{String, ToString},
@@ -81,7 +81,7 @@ struct CompileContext<'a> {
/// List of bytes.
bytes: &'a [u8],
/// Configuration.
- options: &'a Options,
+ options: &'a CompileOptions,
// Fields used by handlers to track the things they need to track to
// compile markdown.
/// Rank of heading (atx).
@@ -136,7 +136,7 @@ impl<'a> CompileContext<'a> {
fn new(
events: &'a [Event],
bytes: &'a [u8],
- options: &'a Options,
+ options: &'a CompileOptions,
line_ending: LineEnding,
) -> CompileContext<'a> {
CompileContext {
@@ -208,7 +208,7 @@ impl<'a> CompileContext<'a> {
}
/// Turn events and bytes into a string of HTML.
-pub fn compile(events: &[Event], bytes: &[u8], options: &Options) -> String {
+pub fn compile(events: &[Event], bytes: &[u8], options: &CompileOptions) -> String {
let mut index = 0;
let mut line_ending_inferred = None;
diff --git a/tests/attention.rs b/tests/attention.rs
index abed33c..83e68d9 100644
--- a/tests/attention.rs
+++ b/tests/attention.rs
@@ -3,15 +3,18 @@ use micromark::{
mdast::{Emphasis, Node, Paragraph, Root, Strong, Text},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ CompileOptions, Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
#[test]
fn attention() -> Result<(), String> {
let danger = Options {
- allow_dangerous_html: true,
- allow_dangerous_protocol: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
};
@@ -821,9 +824,12 @@ fn attention() -> Result<(), String> {
micromark_with_options(
"*a*",
&Options {
- constructs: Constructs {
- attention: false,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ attention: false,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
}
@@ -833,7 +839,7 @@ fn attention() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("a *alpha* b **bravo** c.", &Options::default())?,
+ micromark_to_mdast("a *alpha* b **bravo** c.", &ParseOptions::default())?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
children: vec![
diff --git a/tests/autolink.rs b/tests/autolink.rs
index 78725b2..7ef3caa 100644
--- a/tests/autolink.rs
+++ b/tests/autolink.rs
@@ -3,15 +3,18 @@ use micromark::{
mdast::{Link, Node, Paragraph, Root, Text},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ CompileOptions, Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
#[test]
fn autolink() -> Result<(), String> {
let danger = Options {
- allow_dangerous_html: true,
- allow_dangerous_protocol: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
};
@@ -253,9 +256,12 @@ fn autolink() -> Result<(), String> {
micromark_with_options(
"<a@b.co>",
&Options {
- constructs: Constructs {
- autolink: false,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ autolink: false,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
}
@@ -267,7 +273,7 @@ fn autolink() -> Result<(), String> {
assert_eq!(
micromark_to_mdast(
"a <https://alpha.com> b <bravo@charlie.com> c.",
- &Options::default()
+ &ParseOptions::default()
)?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
diff --git a/tests/block_quote.rs b/tests/block_quote.rs
index 6b155c5..12db252 100644
--- a/tests/block_quote.rs
+++ b/tests/block_quote.rs
@@ -3,7 +3,7 @@ use micromark::{
mdast::{BlockQuote, Node, Paragraph, Root, Text},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
@@ -205,9 +205,12 @@ fn block_quote() -> Result<(), String> {
micromark_with_options(
"> # a\n> b\n> c",
&Options {
- constructs: Constructs {
- block_quote: false,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ block_quote: false,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
}
@@ -217,7 +220,7 @@ fn block_quote() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("> a", &Options::default())?,
+ micromark_to_mdast("> a", &ParseOptions::default())?,
Node::Root(Root {
children: vec![Node::BlockQuote(BlockQuote {
children: vec![Node::Paragraph(Paragraph {
diff --git a/tests/character_escape.rs b/tests/character_escape.rs
index 44eff0b..54944aa 100644
--- a/tests/character_escape.rs
+++ b/tests/character_escape.rs
@@ -3,15 +3,18 @@ use micromark::{
mdast::{Node, Paragraph, Root, Text},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ CompileOptions, Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
#[test]
fn character_escape() -> Result<(), String> {
let danger = Options {
- allow_dangerous_html: true,
- allow_dangerous_protocol: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
};
@@ -87,9 +90,12 @@ fn character_escape() -> Result<(), String> {
micromark_with_options(
"\\> a",
&Options {
- constructs: Constructs {
- character_escape: false,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ character_escape: false,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
}
@@ -99,7 +105,7 @@ fn character_escape() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("a \\* b", &Options::default())?,
+ micromark_to_mdast("a \\* b", &ParseOptions::default())?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
children: vec![Node::Text(Text {
diff --git a/tests/character_reference.rs b/tests/character_reference.rs
index ccf506e..1cc732e 100644
--- a/tests/character_reference.rs
+++ b/tests/character_reference.rs
@@ -3,7 +3,7 @@ use micromark::{
mdast::{Node, Paragraph, Root, Text},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ CompileOptions, Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
@@ -52,7 +52,11 @@ fn character_reference() -> Result<(), String> {
micromark_with_options(
"<a href=\"&ouml;&ouml;.html\">",
&Options {
- allow_dangerous_html: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
}
)?,
@@ -197,9 +201,12 @@ fn character_reference() -> Result<(), String> {
micromark_with_options(
"&amp;",
&Options {
- constructs: Constructs {
- character_reference: false,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ character_reference: false,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
}
@@ -209,7 +216,7 @@ fn character_reference() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("&nbsp; &amp; &copy; &AElig; &Dcaron;\n&frac34; &HilbertSpace; &DifferentialD;\n&ClockwiseContourIntegral; &ngE;", &Options::default())?,
+ micromark_to_mdast("&nbsp; &amp; &copy; &AElig; &Dcaron;\n&frac34; &HilbertSpace; &DifferentialD;\n&ClockwiseContourIntegral; &ngE;", &ParseOptions::default())?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
children: vec![Node::Text(Text {
diff --git a/tests/code_fenced.rs b/tests/code_fenced.rs
index 06f0d6a..6da38a9 100644
--- a/tests/code_fenced.rs
+++ b/tests/code_fenced.rs
@@ -3,7 +3,7 @@ use micromark::{
mdast::{Code, Node, Root},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
@@ -266,9 +266,12 @@ fn code_fenced() -> Result<(), String> {
micromark_with_options(
"```",
&Options {
- constructs: Constructs {
- code_fenced: false,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ code_fenced: false,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
}
@@ -280,7 +283,7 @@ fn code_fenced() -> Result<(), String> {
assert_eq!(
micromark_to_mdast(
"```js extra\nconsole.log(1)\nconsole.log(2)\n```",
- &Options::default()
+ &ParseOptions::default()
)?,
Node::Root(Root {
children: vec![Node::Code(Code {
@@ -295,7 +298,7 @@ fn code_fenced() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("```\nasd", &Options::default())?,
+ micromark_to_mdast("```\nasd", &ParseOptions::default())?,
Node::Root(Root {
children: vec![Node::Code(Code {
lang: None,
diff --git a/tests/code_indented.rs b/tests/code_indented.rs
index 7ea08b5..fd539d3 100644
--- a/tests/code_indented.rs
+++ b/tests/code_indented.rs
@@ -3,7 +3,7 @@ use micromark::{
mdast::{Code, Node, Root},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ CompileOptions, Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
@@ -124,9 +124,12 @@ fn code_indented() -> Result<(), String> {
);
let off = Options {
- constructs: Constructs {
- code_indented: false,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ code_indented: false,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
};
@@ -171,12 +174,17 @@ fn code_indented() -> Result<(), String> {
micromark_with_options(
"a <?\n ?>",
&Options {
- allow_dangerous_html: true,
- constructs: Constructs {
- code_indented: false,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ code_indented: false,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
- ..Options::default()
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ ..CompileOptions::default()
+ }
}
)?,
"<p>a <?\n?></p>",
@@ -198,7 +206,7 @@ fn code_indented() -> Result<(), String> {
assert_eq!(
micromark_to_mdast(
"\tconsole.log(1)\n console.log(2)\n",
- &Options::default()
+ &ParseOptions::default()
)?,
Node::Root(Root {
children: vec![Node::Code(Code {
diff --git a/tests/code_text.rs b/tests/code_text.rs
index f6a3379..25882c8 100644
--- a/tests/code_text.rs
+++ b/tests/code_text.rs
@@ -3,15 +3,18 @@ use micromark::{
mdast::{InlineCode, Node, Paragraph, Root, Text},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ CompileOptions, Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
#[test]
fn code_text() -> Result<(), String> {
let danger = Options {
- allow_dangerous_html: true,
- allow_dangerous_protocol: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
};
@@ -164,9 +167,12 @@ fn code_text() -> Result<(), String> {
micromark_with_options(
"`a`",
&Options {
- constructs: Constructs {
- code_text: false,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ code_text: false,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
}
@@ -176,7 +182,7 @@ fn code_text() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("a `alpha` b.", &Options::default())?,
+ micromark_to_mdast("a `alpha` b.", &ParseOptions::default())?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
children: vec![
diff --git a/tests/commonmark.rs b/tests/commonmark.rs
index e96623a..cc3d69a 100644
--- a/tests/commonmark.rs
+++ b/tests/commonmark.rs
@@ -4,15 +4,18 @@
// > It is generate from the latest CommonMark website.
extern crate micromark;
-use micromark::{micromark_with_options, Options};
+use micromark::{micromark_with_options, CompileOptions, Options};
use pretty_assertions::assert_eq;
#[rustfmt::skip]
#[test]
fn commonmark() -> Result<(), String> {
let danger = Options {
- allow_dangerous_html: true,
- allow_dangerous_protocol: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
};
diff --git a/tests/definition.rs b/tests/definition.rs
index bf9d8ad..8357a67 100644
--- a/tests/definition.rs
+++ b/tests/definition.rs
@@ -3,15 +3,18 @@ use micromark::{
mdast::{Definition, Node, Root},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ CompileOptions, Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
#[test]
fn definition() -> Result<(), String> {
let danger = Options {
- allow_dangerous_html: true,
- allow_dangerous_protocol: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
};
@@ -485,9 +488,12 @@ fn definition() -> Result<(), String> {
micromark_with_options(
"[foo]: /url \"title\"",
&Options {
- constructs: Constructs {
- definition: false,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ definition: false,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
}
@@ -497,7 +503,7 @@ fn definition() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("[a]: <b> 'c'", &Options::default())?,
+ micromark_to_mdast("[a]: <b> 'c'", &ParseOptions::default())?,
Node::Root(Root {
children: vec![Node::Definition(Definition {
url: "b".to_string(),
diff --git a/tests/frontmatter.rs b/tests/frontmatter.rs
index e9f6648..335084e 100644
--- a/tests/frontmatter.rs
+++ b/tests/frontmatter.rs
@@ -3,16 +3,19 @@ use micromark::{
mdast::{Node, Root, Toml, Yaml},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
#[test]
fn frontmatter() -> Result<(), String> {
let frontmatter = Options {
- constructs: Constructs {
- frontmatter: true,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ frontmatter: true,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
};
@@ -72,7 +75,7 @@ fn frontmatter() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("---\na: b\n---", &frontmatter)?,
+ micromark_to_mdast("---\na: b\n---", &frontmatter.parse)?,
Node::Root(Root {
children: vec![Node::Yaml(Yaml {
value: "a: b".to_string(),
@@ -84,7 +87,7 @@ fn frontmatter() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("+++\ntitle = \"Jupyter\"\n+++", &frontmatter)?,
+ micromark_to_mdast("+++\ntitle = \"Jupyter\"\n+++", &frontmatter.parse)?,
Node::Root(Root {
children: vec![Node::Toml(Toml {
value: "title = \"Jupyter\"".to_string(),
diff --git a/tests/fuzz.rs b/tests/fuzz.rs
index 47dbea5..8233ebf 100644
--- a/tests/fuzz.rs
+++ b/tests/fuzz.rs
@@ -1,5 +1,7 @@
extern crate micromark;
-use micromark::{micromark, micromark_with_options, Constructs, Options};
+use micromark::{
+ micromark, micromark_with_options, CompileOptions, Constructs, Options, ParseOptions,
+};
use pretty_assertions::assert_eq;
#[test]
@@ -16,9 +18,14 @@ fn fuzz() -> Result<(), String> {
micromark_with_options(
"a@b.c+d@e.f",
&Options {
- constructs: Constructs::gfm(),
- gfm_tagfilter: true,
- ..Options::default()
+ parse: ParseOptions {
+ constructs: Constructs::gfm(),
+ ..ParseOptions::default()
+ },
+ compile: CompileOptions {
+ gfm_tagfilter: true,
+ ..CompileOptions::default()
+ }
}
)?,
"<p><a href=\"mailto:a@b.c\">a@b.c</a><a href=\"mailto:+d@e.f\">+d@e.f</a></p>",
diff --git a/tests/gfm_autolink_literal.rs b/tests/gfm_autolink_literal.rs
index d699343..9297163 100644
--- a/tests/gfm_autolink_literal.rs
+++ b/tests/gfm_autolink_literal.rs
@@ -3,14 +3,17 @@ use micromark::{
mdast::{Link, Node, Paragraph, Root, Text},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
#[test]
fn gfm_autolink_literal() -> Result<(), String> {
let gfm = Options {
- constructs: Constructs::gfm(),
+ parse: ParseOptions {
+ constructs: Constructs::gfm(),
+ ..ParseOptions::default()
+ },
..Options::default()
};
@@ -2743,7 +2746,7 @@ www.a/~
assert_eq!(
micromark_to_mdast(
"a https://alpha.com b bravo@charlie.com c www.delta.com d xmpp:echo@foxtrot.com e mailto:golf@hotel.com f.",
- &gfm
+ &gfm.parse
)?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
diff --git a/tests/gfm_footnote.rs b/tests/gfm_footnote.rs
index 364bf90..29b0092 100644
--- a/tests/gfm_footnote.rs
+++ b/tests/gfm_footnote.rs
@@ -3,14 +3,17 @@ use micromark::{
mdast::{FootnoteDefinition, FootnoteReference, Node, Paragraph, Root, Text},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ CompileOptions, Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
#[test]
fn gfm_footnote() -> Result<(), String> {
let gfm = Options {
- constructs: Constructs::gfm(),
+ parse: ParseOptions {
+ constructs: Constructs::gfm(),
+ ..ParseOptions::default()
+ },
..Options::default()
};
@@ -38,10 +41,15 @@ fn gfm_footnote() -> Result<(), String> {
micromark_with_options(
"Noot.[^a]\n\n[^a]: dingen",
&Options {
- constructs: Constructs::gfm(),
+ parse: ParseOptions {
+ constructs: Constructs::gfm(),
+ ..ParseOptions::default()
+ },
+ compile: CompileOptions {
gfm_footnote_label: Some("Voetnoten".to_string()),
gfm_footnote_back_label: Some("Terug naar de inhoud".to_string()),
- ..Options::default()
+ ..CompileOptions::default()
+ }
}
)?,
"<p>Noot.<sup><a href=\"#user-content-fn-a\" id=\"user-content-fnref-a\" data-footnote-ref=\"\" aria-describedby=\"footnote-label\">1</a></sup></p>
@@ -60,9 +68,14 @@ fn gfm_footnote() -> Result<(), String> {
micromark_with_options(
"[^a]\n\n[^a]: b",
&Options {
- constructs: Constructs::gfm(),
+ parse: ParseOptions {
+ constructs: Constructs::gfm(),
+ ..ParseOptions::default()
+ },
+ compile: CompileOptions {
gfm_footnote_label_tag_name: Some("h1".to_string()),
- ..Options::default()
+ ..CompileOptions::default()
+ }
}
)?,
"<p><sup><a href=\"#user-content-fn-a\" id=\"user-content-fnref-a\" data-footnote-ref=\"\" aria-describedby=\"footnote-label\">1</a></sup></p>
@@ -81,9 +94,14 @@ fn gfm_footnote() -> Result<(), String> {
micromark_with_options(
"[^a]\n\n[^a]: b",
&Options {
- constructs: Constructs::gfm(),
+ parse: ParseOptions {
+ constructs: Constructs::gfm(),
+ ..ParseOptions::default()
+ },
+ compile: CompileOptions {
gfm_footnote_label_attributes: Some("class=\"footnote-heading\"".to_string()),
- ..Options::default()
+ ..CompileOptions::default()
+ }
}
)?,
"<p><sup><a href=\"#user-content-fn-a\" id=\"user-content-fnref-a\" data-footnote-ref=\"\" aria-describedby=\"footnote-label\">1</a></sup></p>
@@ -102,9 +120,14 @@ fn gfm_footnote() -> Result<(), String> {
micromark_with_options(
"[^a]\n\n[^a]: b",
&Options {
- constructs: Constructs::gfm(),
- gfm_footnote_clobber_prefix: Some("".to_string()),
- ..Options::default()
+ parse: ParseOptions {
+ constructs: Constructs::gfm(),
+ ..ParseOptions::default()
+ },
+ compile: CompileOptions {
+ gfm_footnote_clobber_prefix: Some("".to_string()),
+ ..CompileOptions::default()
+ }
}
)?,
"<p><sup><a href=\"#fn-a\" id=\"fnref-a\" data-footnote-ref=\"\" aria-describedby=\"footnote-label\">1</a></sup></p>
@@ -1603,7 +1626,7 @@ multi-paragraph list items. <a href="#user-content-fnref-longnote" data-footnote
);
assert_eq!(
- micromark_to_mdast("[^a]: b\n\tc\n\nd [^a] e.", &gfm)?,
+ micromark_to_mdast("[^a]: b\n\tc\n\nd [^a] e.", &gfm.parse)?,
Node::Root(Root {
children: vec![
Node::FootnoteDefinition(FootnoteDefinition {
diff --git a/tests/gfm_strikethrough.rs b/tests/gfm_strikethrough.rs
index e392700..ac6b62c 100644
--- a/tests/gfm_strikethrough.rs
+++ b/tests/gfm_strikethrough.rs
@@ -3,14 +3,17 @@ use micromark::{
mdast::{Delete, Node, Paragraph, Root, Text},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
#[test]
fn gfm_strikethrough() -> Result<(), String> {
let gfm = Options {
- constructs: Constructs::gfm(),
+ parse: ParseOptions {
+ constructs: Constructs::gfm(),
+ ..ParseOptions::default()
+ },
..Options::default()
};
@@ -368,8 +371,11 @@ u ~**xxx**~ zzz
micromark_with_options(
"a ~b~ ~~c~~ d",
&Options {
- constructs: Constructs::gfm(),
- gfm_strikethrough_single_tilde: false,
+ parse: ParseOptions {
+ constructs: Constructs::gfm(),
+ gfm_strikethrough_single_tilde: false,
+ ..ParseOptions::default()
+ },
..Options::default()
}
)?,
@@ -381,8 +387,11 @@ u ~**xxx**~ zzz
micromark_with_options(
"a ~b~ ~~c~~ d",
&Options {
- constructs: Constructs::gfm(),
- gfm_strikethrough_single_tilde: true,
+ parse: ParseOptions {
+ constructs: Constructs::gfm(),
+ gfm_strikethrough_single_tilde: true,
+ ..ParseOptions::default()
+ },
..Options::default()
}
)?,
@@ -391,7 +400,7 @@ u ~**xxx**~ zzz
);
assert_eq!(
- micromark_to_mdast("a ~~alpha~~ b.", &gfm)?,
+ micromark_to_mdast("a ~~alpha~~ b.", &gfm.parse)?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
children: vec![
diff --git a/tests/gfm_table.rs b/tests/gfm_table.rs
index d6bd022..1f0b93c 100644
--- a/tests/gfm_table.rs
+++ b/tests/gfm_table.rs
@@ -3,14 +3,17 @@ use micromark::{
mdast::{AlignKind, InlineCode, Node, Root, Table, TableCell, TableRow, Text},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ CompileOptions, Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
#[test]
fn gfm_table() -> Result<(), String> {
let gfm = Options {
- constructs: Constructs::gfm(),
+ parse: ParseOptions {
+ constructs: Constructs::gfm(),
+ ..ParseOptions::default()
+ },
..Options::default()
};
@@ -202,12 +205,15 @@ fn gfm_table() -> Result<(), String> {
assert_eq!(
micromark_with_options("| a |\n | - |", &Options {
- constructs: Constructs {
- code_indented: false,
- ..Constructs::gfm()
- },
- ..Options::default()
- })?,
+ parse: ParseOptions {
+ constructs: Constructs {
+ code_indented: false,
+ ..Constructs::gfm()
+ },
+ ..ParseOptions::default()
+ },
+ ..Options::default()
+ })?,
"<table>\n<thead>\n<tr>\n<th>a</th>\n</tr>\n</thead>\n</table>",
"should form a table if the delimiter row is indented w/ 4 spaces and indented code is turned off"
);
@@ -240,9 +246,15 @@ fn gfm_table() -> Result<(), String> {
micromark_with_options(
"| a |\n| - |\n<!-- HTML? -->",
&Options {
- allow_dangerous_html: true,
- constructs: Constructs::gfm(),
- ..Options::default()
+ parse: ParseOptions {
+ constructs: Constructs::gfm(),
+ ..ParseOptions::default()
+ },
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ }
}
)?,
"<table>\n<thead>\n<tr>\n<th>a</th>\n</tr>\n</thead>\n</table>\n<!-- HTML? -->",
@@ -251,20 +263,32 @@ fn gfm_table() -> Result<(), String> {
assert_eq!(
micromark_with_options("| a |\n| - |\n\tcode?", &Options {
- allow_dangerous_html: true,
- constructs: Constructs::gfm(),
- ..Options::default()
- })?,
+ parse: ParseOptions {
+ constructs: Constructs::gfm(),
+ ..ParseOptions::default()
+ },
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ }
+ })?,
"<table>\n<thead>\n<tr>\n<th>a</th>\n</tr>\n</thead>\n</table>\n<pre><code>code?\n</code></pre>",
"should be interrupted by code (indented)"
);
assert_eq!(
micromark_with_options("| a |\n| - |\n```js\ncode?", &Options {
- allow_dangerous_html: true,
- constructs: Constructs::gfm(),
- ..Options::default()
- })?,
+ parse: ParseOptions {
+ constructs: Constructs::gfm(),
+ ..ParseOptions::default()
+ },
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ }
+ })?,
"<table>\n<thead>\n<tr>\n<th>a</th>\n</tr>\n</thead>\n</table>\n<pre><code class=\"language-js\">code?\n</code></pre>\n",
"should be interrupted by code (fenced)"
);
@@ -273,9 +297,15 @@ fn gfm_table() -> Result<(), String> {
micromark_with_options(
"| a |\n| - |\n***",
&Options {
- allow_dangerous_html: true,
- constructs: Constructs::gfm(),
- ..Options::default()
+ parse: ParseOptions {
+ constructs: Constructs::gfm(),
+ ..ParseOptions::default()
+ },
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ }
}
)?,
"<table>\n<thead>\n<tr>\n<th>a</th>\n</tr>\n</thead>\n</table>\n<hr />",
@@ -1041,9 +1071,15 @@ bar
`\|\\`
"###,
&Options {
- allow_dangerous_html: true,
- constructs: Constructs::gfm(),
- ..Options::default()
+ parse: ParseOptions {
+ constructs: Constructs::gfm(),
+ ..ParseOptions::default()
+ },
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ }
}
)?,
r###"<h1>Grave accents</h1>
@@ -1350,9 +1386,15 @@ b
***
"###,
&Options {
- allow_dangerous_html: true,
- constructs: Constructs::gfm(),
- ..Options::default()
+ parse: ParseOptions {
+ constructs: Constructs::gfm(),
+ ..ParseOptions::default()
+ },
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ }
}
)?,
r###"<h2>Blank line</h2>
@@ -1792,7 +1834,7 @@ normal escape: <a href="https://github.com/github/cmark-gfm/issues/277">https://
assert_eq!(
micromark_to_mdast(
"| none | left | right | center |\n| - | :- | -: | :-: |\n| a |\n| b | c | d | e | f |",
- &gfm
+ &gfm.parse
)?,
Node::Root(Root {
children: vec![Node::Table(Table {
@@ -1895,7 +1937,7 @@ normal escape: <a href="https://github.com/github/cmark-gfm/issues/277">https://
);
assert_eq!(
- micromark_to_mdast("| `a\\|b` |\n| - |", &gfm)?,
+ micromark_to_mdast("| `a\\|b` |\n| - |", &gfm.parse)?,
Node::Root(Root {
children: vec![Node::Table(Table {
align: vec![AlignKind::None,],
diff --git a/tests/gfm_tagfilter.rs b/tests/gfm_tagfilter.rs
index 68246bd..9321d01 100644
--- a/tests/gfm_tagfilter.rs
+++ b/tests/gfm_tagfilter.rs
@@ -1,5 +1,5 @@
extern crate micromark;
-use micromark::{micromark_with_options, Options};
+use micromark::{micromark_with_options, CompileOptions, Options};
use pretty_assertions::assert_eq;
#[test]
@@ -8,7 +8,10 @@ fn gfm_tagfilter() -> Result<(), String> {
micromark_with_options(
"<iframe>",
&Options {
- allow_dangerous_html: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ ..CompileOptions::default()
+ },
..Options::default()
}
)?,
@@ -20,7 +23,10 @@ fn gfm_tagfilter() -> Result<(), String> {
micromark_with_options(
"a <i>\n<script>",
&Options {
- gfm_tagfilter: true,
+ compile: CompileOptions {
+ gfm_tagfilter: true,
+ ..CompileOptions::default()
+ },
..Options::default()
}
)?,
@@ -32,8 +38,11 @@ fn gfm_tagfilter() -> Result<(), String> {
micromark_with_options(
"<iframe>",
&Options {
- gfm_tagfilter: true,
- allow_dangerous_html: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ gfm_tagfilter: true,
+ ..CompileOptions::default()
+ },
..Options::default()
}
)?,
@@ -87,8 +96,11 @@ javascript:/*--></title></style></textarea></script></xmp><svg/onload='+/"/+/onm
<STYLE>@import'http://xss.rocks/xss.css';</STYLE>
"###,
&Options {
- gfm_tagfilter: true,
- allow_dangerous_html: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ gfm_tagfilter: true,
+ ..CompileOptions::default()
+ },
..Options::default()
}
)?,
diff --git a/tests/gfm_task_list_item.rs b/tests/gfm_task_list_item.rs
index 1a0b682..8bc0d31 100644
--- a/tests/gfm_task_list_item.rs
+++ b/tests/gfm_task_list_item.rs
@@ -3,14 +3,17 @@ use micromark::{
mdast::{List, ListItem, Node, Paragraph, Root, Text},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
#[test]
fn gfm_task_list_item() -> Result<(), String> {
let gfm = Options {
- constructs: Constructs::gfm(),
+ parse: ParseOptions {
+ constructs: Constructs::gfm(),
+ ..ParseOptions::default()
+ },
..Options::default()
};
@@ -246,7 +249,7 @@ Text.</li>
);
assert_eq!(
- micromark_to_mdast("* [x] a\n* [ ] b\n* c", &gfm)?,
+ micromark_to_mdast("* [x] a\n* [ ] b\n* c", &gfm.parse)?,
Node::Root(Root {
children: vec![Node::List(List {
ordered: false,
diff --git a/tests/hard_break_escape.rs b/tests/hard_break_escape.rs
index 9a984bf..2e88c95 100644
--- a/tests/hard_break_escape.rs
+++ b/tests/hard_break_escape.rs
@@ -3,7 +3,7 @@ use micromark::{
mdast::{Break, Node, Paragraph, Root, Text},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
@@ -49,9 +49,12 @@ fn hard_break_escape() -> Result<(), String> {
micromark_with_options(
"a\\\nb",
&Options {
- constructs: Constructs {
- hard_break_escape: false,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ hard_break_escape: false,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
}
@@ -61,7 +64,7 @@ fn hard_break_escape() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("a\\\nb.", &Options::default())?,
+ micromark_to_mdast("a\\\nb.", &ParseOptions::default())?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
children: vec![
diff --git a/tests/hard_break_trailing.rs b/tests/hard_break_trailing.rs
index 41a320e..907356a 100644
--- a/tests/hard_break_trailing.rs
+++ b/tests/hard_break_trailing.rs
@@ -3,7 +3,7 @@ use micromark::{
mdast::{Break, Node, Paragraph, Root, Text},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
@@ -115,9 +115,12 @@ fn hard_break_trailing() -> Result<(), String> {
micromark_with_options(
"a \nb",
&Options {
- constructs: Constructs {
- hard_break_trailing: false,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ hard_break_trailing: false,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
}
@@ -127,7 +130,7 @@ fn hard_break_trailing() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("a \nb.", &Options::default())?,
+ micromark_to_mdast("a \nb.", &ParseOptions::default())?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
children: vec![
diff --git a/tests/heading_atx.rs b/tests/heading_atx.rs
index c13ef1a..1b6b8a3 100644
--- a/tests/heading_atx.rs
+++ b/tests/heading_atx.rs
@@ -3,7 +3,7 @@ use micromark::{
mdast::{Heading, Node, Root, Text},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
@@ -211,9 +211,12 @@ fn heading_atx() -> Result<(), String> {
micromark_with_options(
"# a",
&Options {
- constructs: Constructs {
- heading_atx: false,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ heading_atx: false,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
}
@@ -223,7 +226,7 @@ fn heading_atx() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("## alpha #", &Options::default())?,
+ micromark_to_mdast("## alpha #", &ParseOptions::default())?,
Node::Root(Root {
children: vec![Node::Heading(Heading {
depth: 2,
diff --git a/tests/heading_setext.rs b/tests/heading_setext.rs
index 8050ed2..ed2dfa0 100644
--- a/tests/heading_setext.rs
+++ b/tests/heading_setext.rs
@@ -3,7 +3,7 @@ use micromark::{
mdast::{Heading, Node, Root, Text},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
@@ -278,9 +278,12 @@ fn heading_setext() -> Result<(), String> {
micromark_with_options(
"a\n-",
&Options {
- constructs: Constructs {
- heading_setext: false,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ heading_setext: false,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
}
@@ -290,7 +293,7 @@ fn heading_setext() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("alpha\nbravo\n==", &Options::default())?,
+ micromark_to_mdast("alpha\nbravo\n==", &ParseOptions::default())?,
Node::Root(Root {
children: vec![Node::Heading(Heading {
depth: 1,
diff --git a/tests/html_flow.rs b/tests/html_flow.rs
index 2f1d85f..ca93510 100644
--- a/tests/html_flow.rs
+++ b/tests/html_flow.rs
@@ -3,14 +3,18 @@ use micromark::{
mdast::{Html, Node, Root},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ CompileOptions, Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
#[test]
fn html_flow() -> Result<(), String> {
let danger = Options {
- allow_dangerous_html: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
};
@@ -30,9 +34,12 @@ fn html_flow() -> Result<(), String> {
micromark_with_options(
"<x>",
&Options {
- constructs: Constructs {
- html_flow: false,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ html_flow: false,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
}
@@ -42,7 +49,7 @@ fn html_flow() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("<div>\nstuff\n</div>", &Options::default())?,
+ micromark_to_mdast("<div>\nstuff\n</div>", &ParseOptions::default())?,
Node::Root(Root {
children: vec![Node::Html(Html {
value: "<div>\nstuff\n</div>".to_string(),
@@ -59,7 +66,11 @@ fn html_flow() -> Result<(), String> {
#[test]
fn html_flow_1_raw() -> Result<(), String> {
let danger = Options {
- allow_dangerous_html: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
};
@@ -221,7 +232,11 @@ p {color:blue;}
#[test]
fn html_flow_2_comment() -> Result<(), String> {
let danger = Options {
- allow_dangerous_html: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
};
@@ -326,7 +341,11 @@ fn html_flow_2_comment() -> Result<(), String> {
#[test]
fn html_flow_3_instruction() -> Result<(), String> {
let danger = Options {
- allow_dangerous_html: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
};
@@ -379,7 +398,11 @@ fn html_flow_3_instruction() -> Result<(), String> {
#[test]
fn html_flow_4_declaration() -> Result<(), String> {
let danger = Options {
- allow_dangerous_html: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
};
@@ -440,7 +463,11 @@ fn html_flow_4_declaration() -> Result<(), String> {
#[test]
fn html_flow_5_cdata() -> Result<(), String> {
let danger = Options {
- allow_dangerous_html: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
};
@@ -510,7 +537,11 @@ fn html_flow_5_cdata() -> Result<(), String> {
#[test]
fn html_flow_6_basic() -> Result<(), String> {
let danger = Options {
- allow_dangerous_html: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
};
@@ -793,7 +824,11 @@ okay.",
#[test]
fn html_flow_7_complete() -> Result<(), String> {
let danger = Options {
- allow_dangerous_html: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
};
diff --git a/tests/html_text.rs b/tests/html_text.rs
index 40e860e..bc36bd7 100644
--- a/tests/html_text.rs
+++ b/tests/html_text.rs
@@ -3,14 +3,18 @@ use micromark::{
mdast::{Html, Node, Paragraph, Root, Text},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ CompileOptions, Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
#[test]
fn html_text() -> Result<(), String> {
let danger = Options {
- allow_dangerous_html: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
};
@@ -427,9 +431,12 @@ micromark_with_options("<x> a", &danger)?,
micromark_with_options(
"a <x>",
&Options {
- constructs: Constructs {
- html_text: false,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ html_text: false,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
}
@@ -439,7 +446,7 @@ micromark_with_options("<x> a", &danger)?,
);
assert_eq!(
- micromark_to_mdast("alpha <i>bravo</b> charlie.", &Options::default())?,
+ micromark_to_mdast("alpha <i>bravo</b> charlie.", &ParseOptions::default())?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
children: vec![
diff --git a/tests/image.rs b/tests/image.rs
index 6669e8d..f52025d 100644
--- a/tests/image.rs
+++ b/tests/image.rs
@@ -3,7 +3,7 @@ use micromark::{
mdast::{Definition, Image, ImageReference, Node, Paragraph, ReferenceKind, Root, Text},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ CompileOptions, Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
@@ -201,9 +201,12 @@ fn image() -> Result<(), String> {
micromark_with_options(
"![x]()",
&Options {
- constructs: Constructs {
- label_start_image: false,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ label_start_image: false,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
}
@@ -222,7 +225,10 @@ fn image() -> Result<(), String> {
micromark_with_options(
"![](javascript:alert(1))",
&Options {
- allow_dangerous_protocol: true,
+ compile: CompileOptions {
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
}
)?,
@@ -233,7 +239,7 @@ fn image() -> Result<(), String> {
assert_eq!(
micromark_to_mdast(
"a ![alpha]() b ![bravo](charlie 'delta') c.",
- &Options::default()
+ &ParseOptions::default()
)?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
@@ -273,7 +279,7 @@ fn image() -> Result<(), String> {
assert_eq!(
micromark_to_mdast(
"[x]: y\n\na ![x] b ![x][] c ![d][x] e.",
- &Options::default()
+ &ParseOptions::default()
)?,
Node::Root(Root {
children: vec![
diff --git a/tests/link_reference.rs b/tests/link_reference.rs
index 680bb1d..c21ca0b 100644
--- a/tests/link_reference.rs
+++ b/tests/link_reference.rs
@@ -3,15 +3,18 @@ use micromark::{
mdast::{Definition, LinkReference, Node, Paragraph, ReferenceKind, Root, Text},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ CompileOptions, Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
#[test]
fn link_reference() -> Result<(), String> {
let danger = Options {
- allow_dangerous_html: true,
- allow_dangerous_protocol: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
};
@@ -393,9 +396,12 @@ fn link_reference() -> Result<(), String> {
micromark_with_options(
"[x]()",
&Options {
- constructs: Constructs {
- label_start_link: false,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ label_start_link: false,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
}
@@ -408,9 +414,12 @@ fn link_reference() -> Result<(), String> {
micromark_with_options(
"[x]()",
&Options {
- constructs: Constructs {
- label_end: false,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ label_end: false,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
}
@@ -420,7 +429,10 @@ fn link_reference() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("[x]: y\n\na [x] b [x][] c [d][x] e.", &Options::default())?,
+ micromark_to_mdast(
+ "[x]: y\n\na [x] b [x][] c [d][x] e.",
+ &ParseOptions::default()
+ )?,
Node::Root(Root {
children: vec![
Node::Definition(Definition {
diff --git a/tests/link_resource.rs b/tests/link_resource.rs
index ef79653..9f136ef 100644
--- a/tests/link_resource.rs
+++ b/tests/link_resource.rs
@@ -3,15 +3,18 @@ use micromark::{
mdast::{Link, Node, Paragraph, Root, Text},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Options,
+ CompileOptions, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
#[test]
fn link_resource() -> Result<(), String> {
let danger = Options {
- allow_dangerous_html: true,
- allow_dangerous_protocol: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
};
@@ -466,7 +469,7 @@ fn link_resource() -> Result<(), String> {
assert_eq!(
micromark_to_mdast(
"a [alpha]() b [bravo](charlie 'delta') c.",
- &Options::default()
+ &ParseOptions::default()
)?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
diff --git a/tests/list.rs b/tests/list.rs
index d485d49..560be82 100644
--- a/tests/list.rs
+++ b/tests/list.rs
@@ -3,14 +3,18 @@ use micromark::{
mdast::{List, ListItem, Node, Paragraph, Root, Text},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ CompileOptions, Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
#[test]
fn list() -> Result<(), String> {
let danger = Options {
- allow_dangerous_html: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
};
@@ -572,9 +576,12 @@ fn list() -> Result<(), String> {
micromark_with_options(
"- one\n\n two",
&Options {
- constructs: Constructs {
- list_item: false,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ list_item: false,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
}
@@ -584,7 +591,7 @@ fn list() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("* a", &Options::default())?,
+ micromark_to_mdast("* a", &ParseOptions::default())?,
Node::Root(Root {
children: vec![Node::List(List {
ordered: false,
@@ -610,7 +617,7 @@ fn list() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("3. a", &Options::default())?,
+ micromark_to_mdast("3. a", &ParseOptions::default())?,
Node::Root(Root {
children: vec![Node::List(List {
ordered: true,
@@ -636,7 +643,7 @@ fn list() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("* a\n\n b\n* c", &Options::default())?,
+ micromark_to_mdast("* a\n\n b\n* c", &ParseOptions::default())?,
Node::Root(Root {
children: vec![Node::List(List {
ordered: false,
diff --git a/tests/math_flow.rs b/tests/math_flow.rs
index abb1f32..4665eef 100644
--- a/tests/math_flow.rs
+++ b/tests/math_flow.rs
@@ -3,17 +3,20 @@ use micromark::{
mdast::{Math, Node, Root},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
#[test]
fn math_flow() -> Result<(), String> {
let math = Options {
- constructs: Constructs {
- math_text: true,
- math_flow: true,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ math_text: true,
+ math_flow: true,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
};
@@ -254,7 +257,7 @@ fn math_flow() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("$$extra\nabc\ndef\n$$", &math)?,
+ micromark_to_mdast("$$extra\nabc\ndef\n$$", &math.parse)?,
Node::Root(Root {
children: vec![Node::Math(Math {
meta: Some("extra".to_string()),
diff --git a/tests/math_text.rs b/tests/math_text.rs
index 76aa0aa..6282181 100644
--- a/tests/math_text.rs
+++ b/tests/math_text.rs
@@ -3,17 +3,20 @@ use micromark::{
mdast::{InlineMath, Node, Paragraph, Root, Text},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ CompileOptions, Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
#[test]
fn math_text() -> Result<(), String> {
let math = Options {
- constructs: Constructs {
- math_text: true,
- math_flow: true,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ math_text: true,
+ math_flow: true,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
};
@@ -34,11 +37,14 @@ fn math_text() -> Result<(), String> {
micromark_with_options(
"$foo$ $$bar$$",
&Options {
- math_text_single_dollar: false,
- constructs: Constructs {
- math_text: true,
- math_flow: true,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ math_text: true,
+ math_flow: true,
+ ..Constructs::default()
+ },
+ math_text_single_dollar: false,
+ ..ParseOptions::default()
},
..Options::default()
}
@@ -141,14 +147,19 @@ fn math_text() -> Result<(), String> {
micromark_with_options(
"<a href=\"$\">$",
&Options {
- allow_dangerous_html: true,
- allow_dangerous_protocol: true,
- constructs: Constructs {
- math_text: true,
- math_flow: true,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ math_text: true,
+ math_flow: true,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
- ..Options::default()
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ }
}
)?,
"<p><a href=\"$\">$</p>",
@@ -198,7 +209,7 @@ fn math_text() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("a $alpha$ b.", &math)?,
+ micromark_to_mdast("a $alpha$ b.", &math.parse)?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
children: vec![
diff --git a/tests/mdx_esm.rs b/tests/mdx_esm.rs
index a9c7f4a..d6021a1 100644
--- a/tests/mdx_esm.rs
+++ b/tests/mdx_esm.rs
@@ -4,7 +4,7 @@ use micromark::{
mdast::{MdxjsEsm, Node, Root},
micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
use test_utils::swc::{parse_esm, parse_expression};
@@ -12,9 +12,12 @@ use test_utils::swc::{parse_esm, parse_expression};
#[test]
fn mdx_esm() -> Result<(), String> {
let swc = Options {
- constructs: Constructs::mdx(),
- mdx_esm_parse: Some(Box::new(parse_esm)),
- mdx_expression_parse: Some(Box::new(parse_expression)),
+ parse: ParseOptions {
+ constructs: Constructs::mdx(),
+ mdx_esm_parse: Some(Box::new(parse_esm)),
+ mdx_expression_parse: Some(Box::new(parse_expression)),
+ ..ParseOptions::default()
+ },
..Options::default()
};
@@ -243,7 +246,7 @@ fn mdx_esm() -> Result<(), String> {
}
assert_eq!(
- micromark_to_mdast("import a from 'b'\nexport {a}", &swc)?,
+ micromark_to_mdast("import a from 'b'\nexport {a}", &swc.parse)?,
Node::Root(Root {
children: vec![Node::MdxjsEsm(MdxjsEsm {
value: "import a from 'b'\nexport {a}".to_string(),
diff --git a/tests/mdx_expression_flow.rs b/tests/mdx_expression_flow.rs
index b02d32b..0b13149 100644
--- a/tests/mdx_expression_flow.rs
+++ b/tests/mdx_expression_flow.rs
@@ -4,7 +4,7 @@ use micromark::{
mdast::{MdxFlowExpression, Node, Root},
micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
use test_utils::swc::{parse_esm, parse_expression};
@@ -12,7 +12,10 @@ use test_utils::swc::{parse_esm, parse_expression};
#[test]
fn mdx_expression_flow_agnostic() -> Result<(), String> {
let mdx = Options {
- constructs: Constructs::mdx(),
+ parse: ParseOptions {
+ constructs: Constructs::mdx(),
+ ..ParseOptions::default()
+ },
..Options::default()
};
@@ -87,7 +90,7 @@ fn mdx_expression_flow_agnostic() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("{alpha +\nbravo}", &mdx)?,
+ micromark_to_mdast("{alpha +\nbravo}", &mdx.parse)?,
Node::Root(Root {
children: vec![Node::MdxFlowExpression(MdxFlowExpression {
value: "alpha +\nbravo".to_string(),
@@ -104,9 +107,12 @@ fn mdx_expression_flow_agnostic() -> Result<(), String> {
#[test]
fn mdx_expression_flow_gnostic() -> Result<(), String> {
let swc = Options {
- constructs: Constructs::mdx(),
- mdx_esm_parse: Some(Box::new(parse_esm)),
- mdx_expression_parse: Some(Box::new(parse_expression)),
+ parse: ParseOptions {
+ constructs: Constructs::mdx(),
+ mdx_esm_parse: Some(Box::new(parse_esm)),
+ mdx_expression_parse: Some(Box::new(parse_expression)),
+ ..ParseOptions::default()
+ },
..Options::default()
};
@@ -176,9 +182,12 @@ fn mdx_expression_flow_gnostic() -> Result<(), String> {
#[test]
fn mdx_expression_spread() -> Result<(), String> {
let swc = Options {
- constructs: Constructs::mdx(),
- mdx_esm_parse: Some(Box::new(parse_esm)),
- mdx_expression_parse: Some(Box::new(parse_expression)),
+ parse: ParseOptions {
+ constructs: Constructs::mdx(),
+ mdx_esm_parse: Some(Box::new(parse_esm)),
+ mdx_expression_parse: Some(Box::new(parse_expression)),
+ ..ParseOptions::default()
+ },
..Options::default()
};
diff --git a/tests/mdx_expression_text.rs b/tests/mdx_expression_text.rs
index 9eb9dbf..d893a70 100644
--- a/tests/mdx_expression_text.rs
+++ b/tests/mdx_expression_text.rs
@@ -4,7 +4,7 @@ use micromark::{
mdast::{MdxTextExpression, Node, Paragraph, Root, Text},
micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
use test_utils::swc::{parse_esm, parse_expression};
@@ -12,9 +12,12 @@ use test_utils::swc::{parse_esm, parse_expression};
#[test]
fn mdx_expression_text_gnostic_core() -> Result<(), String> {
let swc = Options {
- constructs: Constructs::mdx(),
- mdx_esm_parse: Some(Box::new(parse_esm)),
- mdx_expression_parse: Some(Box::new(parse_expression)),
+ parse: ParseOptions {
+ constructs: Constructs::mdx(),
+ mdx_esm_parse: Some(Box::new(parse_esm)),
+ mdx_expression_parse: Some(Box::new(parse_expression)),
+ ..ParseOptions::default()
+ },
..Options::default()
};
@@ -148,7 +151,10 @@ fn mdx_expression_text_gnostic_core() -> Result<(), String> {
#[test]
fn mdx_expression_text_agnostic() -> Result<(), String> {
let mdx = Options {
- constructs: Constructs::mdx(),
+ parse: ParseOptions {
+ constructs: Constructs::mdx(),
+ ..ParseOptions::default()
+ },
..Options::default()
};
@@ -197,7 +203,7 @@ fn mdx_expression_text_agnostic() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("a {alpha} b.", &mdx)?,
+ micromark_to_mdast("a {alpha} b.", &mdx.parse)?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
children: vec![
@@ -227,9 +233,12 @@ fn mdx_expression_text_agnostic() -> Result<(), String> {
#[test]
fn mdx_expression_text_gnostic() -> Result<(), String> {
let swc = Options {
- constructs: Constructs::mdx(),
- mdx_esm_parse: Some(Box::new(parse_esm)),
- mdx_expression_parse: Some(Box::new(parse_expression)),
+ parse: ParseOptions {
+ constructs: Constructs::mdx(),
+ mdx_esm_parse: Some(Box::new(parse_esm)),
+ mdx_expression_parse: Some(Box::new(parse_expression)),
+ ..ParseOptions::default()
+ },
..Options::default()
};
diff --git a/tests/mdx_jsx_flow.rs b/tests/mdx_jsx_flow.rs
index 54914e6..46d2559 100644
--- a/tests/mdx_jsx_flow.rs
+++ b/tests/mdx_jsx_flow.rs
@@ -3,14 +3,17 @@ use micromark::{
mdast::{List, ListItem, MdxJsxFlowElement, Node, Paragraph, Root, Text},
micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
#[test]
fn mdx_jsx_flow_agnostic() -> Result<(), String> {
let mdx = Options {
- constructs: Constructs::mdx(),
+ parse: ParseOptions {
+ constructs: Constructs::mdx(),
+ ..ParseOptions::default()
+ },
..Options::default()
};
@@ -52,7 +55,10 @@ fn mdx_jsx_flow_agnostic() -> Result<(), String> {
#[test]
fn mdx_jsx_flow_essence() -> Result<(), String> {
let mdx = Options {
- constructs: Constructs::mdx(),
+ parse: ParseOptions {
+ constructs: Constructs::mdx(),
+ ..ParseOptions::default()
+ },
..Options::default()
};
@@ -147,7 +153,7 @@ fn mdx_jsx_flow_essence() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("<>\n * a\n</>", &mdx)?,
+ micromark_to_mdast("<>\n * a\n</>", &mdx.parse)?,
Node::Root(Root {
children: vec![Node::MdxJsxFlowElement(MdxJsxFlowElement {
name: None,
diff --git a/tests/mdx_jsx_text.rs b/tests/mdx_jsx_text.rs
index 0a27bb2..9064e83 100644
--- a/tests/mdx_jsx_text.rs
+++ b/tests/mdx_jsx_text.rs
@@ -7,7 +7,7 @@ use micromark::{
},
micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
use test_utils::swc::{parse_esm, parse_expression};
@@ -15,7 +15,10 @@ use test_utils::swc::{parse_esm, parse_expression};
#[test]
fn mdx_jsx_text_core() -> Result<(), String> {
let mdx = Options {
- constructs: Constructs::mdx(),
+ parse: ParseOptions {
+ constructs: Constructs::mdx(),
+ ..ParseOptions::default()
+ },
..Options::default()
};
@@ -50,7 +53,7 @@ fn mdx_jsx_text_core() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("a <b /> c.", &mdx)?,
+ micromark_to_mdast("a <b /> c.", &mdx.parse)?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
children: vec![
@@ -77,7 +80,7 @@ fn mdx_jsx_text_core() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("a <b>*c*</b> d.", &mdx)?,
+ micromark_to_mdast("a <b>*c*</b> d.", &mdx.parse)?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
children: vec![
@@ -114,7 +117,7 @@ fn mdx_jsx_text_core() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("<a:b />.", &mdx)?,
+ micromark_to_mdast("<a:b />.", &mdx.parse)?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
children: vec![
@@ -137,7 +140,7 @@ fn mdx_jsx_text_core() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("<a.b.c />.", &mdx)?,
+ micromark_to_mdast("<a.b.c />.", &mdx.parse)?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
children: vec![
@@ -160,7 +163,7 @@ fn mdx_jsx_text_core() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("<a {...b} />.", &mdx)?,
+ micromark_to_mdast("<a {...b} />.", &mdx.parse)?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
children: vec![
@@ -183,7 +186,7 @@ fn mdx_jsx_text_core() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("<a b c:d />.", &mdx)?,
+ micromark_to_mdast("<a b c:d />.", &mdx.parse)?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
children: vec![
@@ -215,7 +218,7 @@ fn mdx_jsx_text_core() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("<a b='c' d=\"e\" f={g} />.", &mdx)?,
+ micromark_to_mdast("<a b='c' d=\"e\" f={g} />.", &mdx.parse)?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
children: vec![
@@ -251,7 +254,7 @@ fn mdx_jsx_text_core() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("<a b='&nbsp; &amp; &copy; &AElig; &Dcaron; &frac34; &HilbertSpace; &DifferentialD; &ClockwiseContourIntegral; &ngE;' />.", &mdx)?,
+ micromark_to_mdast("<a b='&nbsp; &amp; &copy; &AElig; &Dcaron; &frac34; &HilbertSpace; &DifferentialD; &ClockwiseContourIntegral; &ngE;' />.", &mdx.parse)?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
children: vec![
@@ -281,7 +284,7 @@ fn mdx_jsx_text_core() -> Result<(), String> {
assert_eq!(
micromark_to_mdast(
"<a b='&#35; &#1234; &#992; &#0;' c='&#X22; &#XD06; &#xcab;' />.",
- &mdx
+ &mdx.parse
)?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
@@ -314,7 +317,7 @@ fn mdx_jsx_text_core() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("<a b='&nbsp &x; &#; &#x; &#987654321; &#abcdef0; &ThisIsNotDefined; &hi?;' />.", &mdx)?,
+ micromark_to_mdast("<a b='&nbsp &x; &#; &#x; &#987654321; &#abcdef0; &ThisIsNotDefined; &hi?;' />.", &mdx.parse)?,
Node::Root(Root {
children: vec![Node::Paragraph(Paragraph {
children: vec![
@@ -342,7 +345,7 @@ fn mdx_jsx_text_core() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("a </b> c", &mdx)
+ micromark_to_mdast("a </b> c", &mdx.parse)
.err()
.unwrap(),
"1:4: Unexpected closing slash `/` in tag, expected an open tag first (mdx-jsx:unexpected-closing-slash)",
@@ -350,7 +353,7 @@ fn mdx_jsx_text_core() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("a <b> c </b/> d", &mdx)
+ micromark_to_mdast("a <b> c </b/> d", &mdx.parse)
.err()
.unwrap(),
"1:12: Unexpected self-closing slash `/` in closing tag, expected the end of the tag (mdx-jsx:unexpected-self-closing-slash)",
@@ -358,7 +361,7 @@ fn mdx_jsx_text_core() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("a <b> c </b d> e", &mdx)
+ micromark_to_mdast("a <b> c </b d> e", &mdx.parse)
.err()
.unwrap(),
"1:13: Unexpected attribute in closing tag, expected the end of the tag (mdx-jsx:unexpected-attribute)",
@@ -366,7 +369,7 @@ fn mdx_jsx_text_core() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("a <>b</c> d", &mdx)
+ micromark_to_mdast("a <>b</c> d", &mdx.parse)
.err()
.unwrap(),
"1:6: Unexpected closing tag `</c>`, expected corresponding closing tag for `<>` (1:3) (mdx-jsx:end-tag-mismatch)",
@@ -374,7 +377,7 @@ fn mdx_jsx_text_core() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("a <b>c</> d", &mdx)
+ micromark_to_mdast("a <b>c</> d", &mdx.parse)
.err()
.unwrap(),
"1:7: Unexpected closing tag `</>`, expected corresponding closing tag for `<b>` (1:3) (mdx-jsx:end-tag-mismatch)",
@@ -382,26 +385,26 @@ fn mdx_jsx_text_core() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("*a <b>c* d</b>.", &mdx).err().unwrap(),
+ micromark_to_mdast("*a <b>c* d</b>.", &mdx.parse).err().unwrap(),
"1:9: Expected a closing tag for `<b>` (1:4) before the end of `Emphasis` (mdx-jsx:end-tag-mismatch)",
"should crash when building the ast on mismatched interleaving (1)"
);
assert_eq!(
- micromark_to_mdast("<a>b *c</a> d*.", &mdx).err().unwrap(),
+ micromark_to_mdast("<a>b *c</a> d*.", &mdx.parse).err().unwrap(),
"1:8: Expected the closing tag `</a>` either before the start of `Emphasis` (1:6), or another opening tag after that start (mdx-jsx:end-tag-mismatch)",
"should crash when building the ast on mismatched interleaving (2)"
);
assert_eq!(
- micromark_to_mdast("a <b>.", &mdx).err().unwrap(),
+ micromark_to_mdast("a <b>.", &mdx.parse).err().unwrap(),
"1:7: Expected a closing tag for `<b>` (1:3) before the end of `Paragraph` (mdx-jsx:end-tag-mismatch)",
"should crash when building the ast on mismatched interleaving (3)"
);
// Note: this is flow, not text.
assert_eq!(
- micromark_to_mdast("<a>", &mdx).err().unwrap(),
+ micromark_to_mdast("<a>", &mdx.parse).err().unwrap(),
"1:4: Expected a closing tag for `<a>` (1:1) (mdx-jsx:end-tag-mismatch)",
"should crash when building the ast on mismatched interleaving (4)"
);
@@ -412,7 +415,10 @@ fn mdx_jsx_text_core() -> Result<(), String> {
#[test]
fn mdx_jsx_text_agnosic() -> Result<(), String> {
let mdx = Options {
- constructs: Constructs::mdx(),
+ parse: ParseOptions {
+ constructs: Constructs::mdx(),
+ ..ParseOptions::default()
+ },
..Options::default()
};
@@ -452,9 +458,12 @@ fn mdx_jsx_text_agnosic() -> Result<(), String> {
#[test]
fn mdx_jsx_text_gnostic() -> Result<(), String> {
let swc = Options {
- constructs: Constructs::mdx(),
- mdx_esm_parse: Some(Box::new(parse_esm)),
- mdx_expression_parse: Some(Box::new(parse_expression)),
+ parse: ParseOptions {
+ constructs: Constructs::mdx(),
+ mdx_esm_parse: Some(Box::new(parse_esm)),
+ mdx_expression_parse: Some(Box::new(parse_expression)),
+ ..ParseOptions::default()
+ },
..Options::default()
};
@@ -552,7 +561,10 @@ fn mdx_jsx_text_gnostic() -> Result<(), String> {
#[test]
fn mdx_jsx_text_complete() -> Result<(), String> {
let mdx = Options {
- constructs: Constructs::mdx(),
+ parse: ParseOptions {
+ constructs: Constructs::mdx(),
+ ..ParseOptions::default()
+ },
..Options::default()
};
diff --git a/tests/mdx_swc.rs b/tests/mdx_swc.rs
index 74f975a..d4b8e46 100644
--- a/tests/mdx_swc.rs
+++ b/tests/mdx_swc.rs
@@ -1,44 +1,47 @@
extern crate micromark;
mod test_utils;
-use micromark::{micromark_with_options, Constructs, Options};
+use micromark::{micromark_with_options, Constructs, Options, ParseOptions};
use pretty_assertions::assert_eq;
use test_utils::swc::{parse_esm, parse_expression};
#[test]
fn mdx_swc() -> Result<(), String> {
- let mdx = Options {
- constructs: Constructs::mdx(),
- mdx_esm_parse: Some(Box::new(parse_esm)),
- mdx_expression_parse: Some(Box::new(parse_expression)),
+ let swc = Options {
+ parse: ParseOptions {
+ constructs: Constructs::mdx(),
+ mdx_esm_parse: Some(Box::new(parse_esm)),
+ mdx_expression_parse: Some(Box::new(parse_expression)),
+ ..ParseOptions::default()
+ },
..Options::default()
};
assert_eq!(
- micromark_with_options("{'}'}", &mdx)?,
+ micromark_with_options("{'}'}", &swc)?,
"",
"should support JavaScript-aware flow expressions w/ `mdx_expression_parse`"
);
assert_eq!(
- micromark_with_options("a {'}'} b", &mdx)?,
+ micromark_with_options("a {'}'} b", &swc)?,
"<p>a b</p>",
"should support JavaScript-aware text expressions w/ `mdx_expression_parse`"
);
assert_eq!(
- micromark_with_options("<a {...a/*}*/} />", &mdx)?,
+ micromark_with_options("<a {...a/*}*/} />", &swc)?,
"",
"should support JavaScript-aware attribute expressions w/ `mdx_expression_parse`"
);
assert_eq!(
- micromark_with_options("<a b={'}'} />", &mdx)?,
+ micromark_with_options("<a b={'}'} />", &swc)?,
"",
"should support JavaScript-aware attribute value expressions w/ `mdx_expression_parse`"
);
assert_eq!(
- micromark_with_options("import a from 'b'\n\nexport {a}\n\n# c", &mdx)?,
+ micromark_with_options("import a from 'b'\n\nexport {a}\n\n# c", &swc)?,
"<h1>c</h1>",
"should support JavaScript-aware ESM w/ `mdx_esm_parse`"
);
diff --git a/tests/misc_dangerous_html.rs b/tests/misc_dangerous_html.rs
index 8afa481..9787813 100644
--- a/tests/misc_dangerous_html.rs
+++ b/tests/misc_dangerous_html.rs
@@ -1,12 +1,15 @@
extern crate micromark;
-use micromark::{micromark, micromark_with_options, Options};
+use micromark::{micromark, micromark_with_options, CompileOptions, Options};
use pretty_assertions::assert_eq;
#[test]
fn dangerous_html() -> Result<(), String> {
let danger = &Options {
- allow_dangerous_html: true,
- allow_dangerous_protocol: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
};
diff --git a/tests/misc_default_line_ending.rs b/tests/misc_default_line_ending.rs
index b122c50..f839e2c 100644
--- a/tests/misc_default_line_ending.rs
+++ b/tests/misc_default_line_ending.rs
@@ -1,5 +1,5 @@
extern crate micromark;
-use micromark::{micromark, micromark_with_options, LineEnding, Options};
+use micromark::{micromark, micromark_with_options, CompileOptions, LineEnding, Options};
use pretty_assertions::assert_eq;
#[test]
@@ -32,7 +32,10 @@ fn default_line_ending() -> Result<(), String> {
micromark_with_options(
"> a",
&Options {
- default_line_ending: LineEnding::CarriageReturn,
+ compile: CompileOptions {
+ default_line_ending: LineEnding::CarriageReturn,
+ ..CompileOptions::default()
+ },
..Options::default()
}
)?,
@@ -44,7 +47,10 @@ fn default_line_ending() -> Result<(), String> {
micromark_with_options(
"> a\n",
&Options {
- default_line_ending: LineEnding::CarriageReturn,
+ compile: CompileOptions {
+ default_line_ending: LineEnding::CarriageReturn,
+ ..CompileOptions::default()
+ },
..Options::default()
}
)?,
diff --git a/tests/misc_line_ending.rs b/tests/misc_line_ending.rs
index 6713b32..90f9df0 100644
--- a/tests/misc_line_ending.rs
+++ b/tests/misc_line_ending.rs
@@ -1,12 +1,15 @@
extern crate micromark;
-use micromark::{micromark, micromark_with_options, Options};
+use micromark::{micromark, micromark_with_options, CompileOptions, Options};
use pretty_assertions::assert_eq;
#[test]
fn line_ending() -> Result<(), String> {
let danger = &Options {
- allow_dangerous_html: true,
- allow_dangerous_protocol: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
};
diff --git a/tests/misc_tabs.rs b/tests/misc_tabs.rs
index 5cd9f69..56698e8 100644
--- a/tests/misc_tabs.rs
+++ b/tests/misc_tabs.rs
@@ -1,11 +1,15 @@
extern crate micromark;
-use micromark::{micromark, micromark_with_options, Options};
+use micromark::{micromark, micromark_with_options, CompileOptions, Options};
use pretty_assertions::assert_eq;
#[test]
fn tabs_flow() -> Result<(), String> {
let danger = &Options {
- allow_dangerous_html: true,
+ compile: CompileOptions {
+ allow_dangerous_html: true,
+ allow_dangerous_protocol: true,
+ ..CompileOptions::default()
+ },
..Options::default()
};
diff --git a/tests/thematic_break.rs b/tests/thematic_break.rs
index d8d8104..c5612bb 100644
--- a/tests/thematic_break.rs
+++ b/tests/thematic_break.rs
@@ -3,7 +3,7 @@ use micromark::{
mdast::{Node, Root, ThematicBreak},
micromark, micromark_to_mdast, micromark_with_options,
unist::Position,
- Constructs, Options,
+ Constructs, Options, ParseOptions,
};
use pretty_assertions::assert_eq;
@@ -175,9 +175,12 @@ fn thematic_break() -> Result<(), String> {
micromark_with_options(
"***",
&Options {
- constructs: Constructs {
- thematic_break: false,
- ..Constructs::default()
+ parse: ParseOptions {
+ constructs: Constructs {
+ thematic_break: false,
+ ..Constructs::default()
+ },
+ ..ParseOptions::default()
},
..Options::default()
}
@@ -187,7 +190,7 @@ fn thematic_break() -> Result<(), String> {
);
assert_eq!(
- micromark_to_mdast("***", &Options::default())?,
+ micromark_to_mdast("***", &ParseOptions::default())?,
Node::Root(Root {
children: vec![Node::ThematicBreak(ThematicBreak {
position: Some(Position::new(1, 1, 0, 1, 4, 3))
diff --git a/tests/xxx_document.rs b/tests/xxx_document.rs
index dcbb56b..d5c8eef 100644
--- a/tests/xxx_document.rs
+++ b/tests/xxx_document.rs
@@ -3,7 +3,7 @@ extern crate swc_common;
extern crate swc_ecma_ast;
extern crate swc_ecma_codegen;
mod test_utils;
-use micromark::{micromark_to_mdast, Constructs, Options};
+use micromark::{micromark_to_mdast, Constructs, ParseOptions};
use pretty_assertions::assert_eq;
use test_utils::{
swc::{parse_esm, parse_expression, serialize},
@@ -15,11 +15,11 @@ use test_utils::{
fn from_markdown(value: &str) -> Result<String, String> {
let mdast = micromark_to_mdast(
value,
- &Options {
+ &ParseOptions {
constructs: Constructs::mdx(),
mdx_esm_parse: Some(Box::new(parse_esm)),
mdx_expression_parse: Some(Box::new(parse_expression)),
- ..Options::default()
+ ..ParseOptions::default()
},
)?;
let hast = to_hast(&mdast);
diff --git a/tests/xxx_jsx_rewrite.rs b/tests/xxx_jsx_rewrite.rs
index ad7c4b4..7a1c379 100644
--- a/tests/xxx_jsx_rewrite.rs
+++ b/tests/xxx_jsx_rewrite.rs
@@ -3,7 +3,7 @@ extern crate swc_common;
extern crate swc_ecma_ast;
extern crate swc_ecma_codegen;
mod test_utils;
-use micromark::{micromark_to_mdast, Constructs, Options};
+use micromark::{micromark_to_mdast, Constructs, ParseOptions};
use pretty_assertions::assert_eq;
use test_utils::{
jsx_rewrite::{jsx_rewrite, Options as RewriteOptions},
@@ -16,11 +16,11 @@ use test_utils::{
fn from_markdown(value: &str, options: &RewriteOptions) -> Result<String, String> {
let mdast = micromark_to_mdast(
value,
- &Options {
+ &ParseOptions {
constructs: Constructs::mdx(),
mdx_esm_parse: Some(Box::new(parse_esm)),
mdx_expression_parse: Some(Box::new(parse_expression)),
- ..Options::default()
+ ..ParseOptions::default()
},
)?;
let hast = to_hast(&mdast);