about summary refs log tree commit diff
path: root/src/librustdoc/html/length_limit.rs
AgeCommit message (Collapse)AuthorLines
2024-11-28Fix new clippy lintsGuillaume Gomez-9/+8
2023-08-16Improve code readability by moving fmt args directly into the stringGuillaume Gomez-4/+3
2023-01-27Remove from librustdoc and clippy tooScott McMurray-2/+2
2021-08-25Don't panic if `close_tag()` is called without tags to closeNoah Lev-2/+10
This can happen when a tag is opened after the length limit is reached; the tag will not end up being added to `unclosed_tags` because the queue will never be flushed. So, now, if the `unclosed_tags` stack is empty, `close_tag()` does nothing. This change fixes a panic in the `limit_0` unit test.
2021-08-25Assert that `tag_name` is alphabeticNoah Lev-0/+8
2021-08-25Add tests for `HtmlWithLimit`Noah Lev-0/+3
2021-08-21Use `write!`Noah Lev-6/+2
2021-08-21Use the length limit as the initial capacityNoah Lev-1/+11
The length limit turns out to be a surprisingly good heuristic for initial allocation size. See here for more details [1]. [1]: https://github.com/rust-lang/rust/pull/88173#discussion_r692531631
2021-08-21Clarify wording in docsNoah Lev-1/+1
2021-08-19Refactor Markdown length-limited summary implementationNoah Lev-0/+94
This commit refactors the implementation of `markdown_summary_with_limit()`, separating the logic of determining when the limit has been reached from the actual rendering process. The main advantage of the new approach is that it guarantees that all HTML tags are closed, whereas the previous implementation could generate tags that were never closed. It also ensures that no empty tags are generated (e.g., `<em></em>`). The new implementation consists of a general-purpose struct `HtmlWithLimit` that manages the length-limiting logic and a function `markdown_summary_with_limit()` that renders Markdown to HTML using the struct.