diff options
| author | 2022-07-05 15:10:54 +0200 | |
|---|---|---|
| committer | 2022-07-05 15:10:54 +0200 | |
| commit | 187d51acc953720d79f40e82aabe90ea5d58a8a3 (patch) | |
| tree | 46ec628f50f96760621216b924908376cc8b6b48 /src | |
| parent | fec46e918e5bdf4a9137041298ab1475d2f43202 (diff) | |
| download | markdown-rs-187d51acc953720d79f40e82aabe90ea5d58a8a3.tar.gz markdown-rs-187d51acc953720d79f40e82aabe90ea5d58a8a3.tar.bz2 markdown-rs-187d51acc953720d79f40e82aabe90ea5d58a8a3.zip | |
Fix misnested attention
Diffstat (limited to '')
| -rw-r--r-- | src/construct/attention.rs | 19 | 
1 files changed, 19 insertions, 0 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 = ( | 
