@@ -111,7 +111,11 @@ pub(crate) struct MarkdownWithToc<'a> {
111111}
112112/// A tuple struct like `Markdown` that renders the markdown escaping HTML tags
113113/// and includes no paragraph tags.
114- pub ( crate ) struct MarkdownItemInfo < ' a > ( pub ( crate ) & ' a str , pub ( crate ) & ' a mut IdMap ) ;
114+ pub ( crate ) struct MarkdownItemInfo < ' a > (
115+ pub ( crate ) & ' a str ,
116+ pub ( crate ) & ' a mut IdMap ,
117+ pub ( crate ) Edition ,
118+ ) ;
115119/// A tuple struct like `Markdown` that renders only the first paragraph.
116120pub ( crate ) struct MarkdownSummaryLine < ' a > ( pub & ' a str , pub & ' a [ RenderedLink ] ) ;
117121
@@ -1461,7 +1465,8 @@ impl MarkdownWithToc<'_> {
14611465
14621466impl MarkdownItemInfo < ' _ > {
14631467 pub ( crate ) fn write_into ( self , mut f : impl fmt:: Write ) -> fmt:: Result {
1464- let MarkdownItemInfo ( md, ids) = self ;
1468+ let MarkdownItemInfo ( md, ids, edition) = self ;
1469+ let legacy_wrap = edition != Edition :: EditionFuture ;
14651470
14661471 // This is actually common enough to special-case
14671472 if md. is_empty ( ) {
@@ -1479,10 +1484,23 @@ impl MarkdownItemInfo<'_> {
14791484 let p = HeadingLinks :: new ( p, None , ids, HeadingOffset :: H1 ) ;
14801485 let p = footnotes:: Footnotes :: new ( p, existing_footnotes) ;
14811486 let p = TableWrapper :: new ( p. map ( |( ev, _) | ev) ) ;
1487+ // in legacy wrap mode, strip <p> elements to avoid them inserting newlines
14821488 let p = p. filter ( |event| {
1483- !matches ! ( event, Event :: Start ( Tag :: Paragraph ) | Event :: End ( TagEnd :: Paragraph ) )
1489+ !legacy_wrap
1490+ || !matches ! (
1491+ event,
1492+ Event :: Start ( Tag :: Paragraph ) | Event :: End ( TagEnd :: Paragraph )
1493+ )
14841494 } ) ;
1485- html:: write_html_fmt ( & mut f, p)
1495+ if legacy_wrap {
1496+ f. write_str ( "<span class=\" legacy-wrap\" >" ) ?;
1497+ }
1498+ html:: write_html_fmt ( & mut f, p) ?;
1499+ if legacy_wrap {
1500+ f. write_str ( "</span>" ) ?;
1501+ }
1502+
1503+ Ok ( ( ) )
14861504 } )
14871505 }
14881506}
0 commit comments