Rollup merge of #88173 - camelid:refactor-markdown-length-limit, r=GuillaumeGomez

Refactor Markdown length-limited summary implementation

This PR is a new approach to #79749.

This PR 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.

r? `@GuillaumeGomez`
This commit is contained in:
Guillaume Gomez
2021-08-29 16:25:28 +02:00
committed by GitHub
6 changed files with 271 additions and 43 deletions

View File

@@ -5,6 +5,7 @@
#![feature(rustc_private)]
#![feature(array_methods)]
#![feature(box_patterns)]
#![feature(control_flow_enum)]
#![feature(in_band_lifetimes)]
#![feature(nll)]
#![feature(test)]