Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SummaryParser::parse_title() consuming events (#1743) #1744

Merged
merged 3 commits into from
Mar 27, 2022

Conversation

ilslv
Copy link
Contributor

@ilslv ilslv commented Feb 11, 2022

Resolves #1743

The issue can be found while looking and summary parsing output:

#
- [First](./first.md)
  - [Nested](./nested.md)
- [Second](./second.md)
RUST_LOG=mdbook::book::summary=TRACE cargo run -- build
2022-02-11 11:52:10 [TRACE] (mdbook::book::summary): Next event: Some(Start(Heading(H1, None, [])))
2022-02-11 11:52:10 [DEBUG] (mdbook::book::summary): Found a h1 in the SUMMARY
2022-02-11 11:52:10 [TRACE] (mdbook::book::summary): Next event: Some(End(Heading(H1, None, [])))
2022-02-11 11:52:10 [DEBUG] (mdbook::book::summary): Parsing prefix items
2022-02-11 11:52:10 [TRACE] (mdbook::book::summary): Next event: Some(Start(List(None)))
2022-02-11 11:52:10 [TRACE] (mdbook::book::summary): Back: Start(List(None))
2022-02-11 11:52:10 [TRACE] (mdbook::book::summary): Next event: Some(Start(List(None)))
2022-02-11 11:52:10 [TRACE] (mdbook::book::summary): Back: Start(List(None))
2022-02-11 11:52:10 [TRACE] (mdbook::book::summary): Next event: Some(Start(List(None)))
2022-02-11 11:52:10 [TRACE] (mdbook::book::summary): Back: Start(List(None))
2022-02-11 11:52:10 [DEBUG] (mdbook::book::summary): Parsing numbered chapters at level 0
...

- [First](./first.md)
  - [Nested](./nested.md)
- [Second](./second.md)
RUST_LOG=mdbook::book::summary=TRACE cargo run -- build
2022-02-11 11:52:46 [TRACE] (mdbook::book::summary): Next event: Some(Start(List(None)))
2022-02-11 11:52:46 [DEBUG] (mdbook::book::summary): Parsing prefix items
2022-02-11 11:52:46 [TRACE] (mdbook::book::summary): Next event: Some(Start(Item))
2022-02-11 11:52:46 [TRACE] (mdbook::book::summary): Next event: Some(Start(Link(Inline, Borrowed("./first.md"), Borrowed(""))))
2022-02-11 11:52:46 [TRACE] (mdbook::book::summary): Next event: Some(Text(Borrowed("First")))
2022-02-11 11:52:46 [TRACE] (mdbook::book::summary): Next event: Some(End(Link(Inline, Borrowed("./first.md"), Borrowed(""))))
2022-02-11 11:52:46 [TRACE] (mdbook::book::summary): Next event: Some(Start(List(None)))
2022-02-11 11:52:46 [TRACE] (mdbook::book::summary): Back: Start(List(None))
2022-02-11 11:52:46 [TRACE] (mdbook::book::summary): Next event: Some(Start(List(None)))
2022-02-11 11:52:46 [TRACE] (mdbook::book::summary): Back: Start(List(None))
2022-02-11 11:52:46 [TRACE] (mdbook::book::summary): Next event: Some(Start(List(None)))
2022-02-11 11:52:46 [TRACE] (mdbook::book::summary): Back: Start(List(None))
2022-02-11 11:52:46 [DEBUG] (mdbook::book::summary): Parsing numbered chapters at level 0
...

By looking at first 2 lines of the output, we can see that Some(Start(List(None))) event isn't pushed back and so is skipped. This causes parser to see - [First](./first.md) as [First](./first.md) and so interprets it as prefix chapter.

After applying a fix we can see following output:

2022-02-11 12:16:38 [TRACE] (mdbook::book::summary): Next event: Some(Start(List(None)))
2022-02-11 12:16:38 [TRACE] (mdbook::book::summary): Back: Start(List(None))
2022-02-11 12:16:38 [DEBUG] (mdbook::book::summary): Parsing prefix items
2022-02-11 12:16:38 [TRACE] (mdbook::book::summary): Next event: Some(Start(List(None)))
2022-02-11 12:16:38 [TRACE] (mdbook::book::summary): Back: Start(List(None))
2022-02-11 12:16:38 [TRACE] (mdbook::book::summary): Next event: Some(Start(List(None)))
2022-02-11 12:16:38 [TRACE] (mdbook::book::summary): Back: Start(List(None))
2022-02-11 12:16:38 [TRACE] (mdbook::book::summary): Next event: Some(Start(List(None)))
2022-02-11 12:16:38 [TRACE] (mdbook::book::summary): Back: Start(List(None))
2022-02-11 12:16:38 [DEBUG] (mdbook::book::summary): Parsing numbered chapters at level 0
...

Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ehuss ehuss merged commit 1562629 into rust-lang:master Mar 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect nested summary parsing
2 participants