aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/construct/attention.rs19
-rw-r--r--tests/attention.rs22
2 files changed, 29 insertions, 12 deletions
diff --git a/src/construct/attention.rs b/src/construct/attention.rs
index d460afb..d0689b8 100644
--- a/src/construct/attention.rs
+++ b/src/construct/attention.rs
@@ -328,6 +328,25 @@ fn resolve(tokenizer: &mut Tokenizer) -> Vec<Event> {
1
};
+ // We’re *on* a closing sequence, with a matching opening
+ // sequence.
+ // Now we make sure that we can’t have misnested attention:
+ //
+ // ```html
+ // <em>a <strong>b</em> c</strong>
+ // ```
+ //
+ // Do that by marking everything between it as no longer
+ // possible to open anything.
+ // Theoretically we could mark non-closing as well, but we
+ // don’t look for closers backwards.
+ let mut between = open + 1;
+
+ while between < close {
+ sequences[between].open = false;
+ between += 1;
+ }
+
let sequence_close = &mut sequences[close];
let close_event_index = sequence_close.event_index;
let seq_close_enter = (
diff --git a/tests/attention.rs b/tests/attention.rs
index 789d860..747bf08 100644
--- a/tests/attention.rs
+++ b/tests/attention.rs
@@ -725,19 +725,17 @@ fn attention() {
);
// Rule 15.
- // To do: interleaving attention.
- // assert_eq!(
- // micromark("*foo _bar* baz_"),
- // "<p><em>foo _bar</em> baz_</p>",
- // "should not support mismatched emphasis"
- // );
+ assert_eq!(
+ micromark("*foo _bar* baz_"),
+ "<p><em>foo _bar</em> baz_</p>",
+ "should not support mismatched emphasis"
+ );
- // To do: interleaving attention.
- // assert_eq!(
- // micromark("*foo __bar *baz bim__ bam*"),
- // "<p><em>foo <strong>bar *baz bim</strong> bam</em></p>",
- // "should not support mismatched strong emphasis"
- // );
+ assert_eq!(
+ micromark("*foo __bar *baz bim__ bam*"),
+ "<p><em>foo <strong>bar *baz bim</strong> bam</em></p>",
+ "should not support mismatched strong emphasis"
+ );
// Rule 16.
assert_eq!(