Skip to content

Definition lists do not work if they are embedded in another block type #1014

Description

@alyjak

Edited

It looks like the definition lists do not work if they are embedded in another block type for the offset_iter. Both of these examples are failing for me on v0.12.2 with the following panic:

panicked at /home/alyjak/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pulldown-cmark-0.12.2/src/firstpass.rs:1540:38:
called `Option::unwrap()` on a `None` value`.

Offset iter is necessary in this example for it to panic:

use pulldown_cmark::{Parser, Event, Options};
use std::ops::Range;

let mut options = Options::empty();
options.insert(Options::ENABLE_DEFINITION_LIST);

let block_quote = "As defined by the foo:

> The Foo
> :   This defines foo.
>";

format!("{:?}", Parser::new_ext(&block_quote, options).into_offset_iter().collect::<Vec<(Event<'_>, Range<usize>)>>())

A standard parse panics here:

use pulldown_cmark::{Parser, Event, Options};
use std::ops::Range;

let mut options = Options::empty();
options.insert(Options::ENABLE_DEFINITION_LIST);

let triple_def = "A very nested definition
:   Def 1.1
    :   Def 1.1.1
        :   Text

A succeeding paragraph
";

println!("{:?}", Parser::new_ext(&triple_def, options).collect::<Vec<Event<'_>>>())

Thanks for the hard work. I really appreciate this library.

Originally posted by @alyjak in #915 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions