mirror of https://github.com/rust-lang/cargo
chore: update pulldown-cmark to 0.10.0
Fixes: https://github.com/rust-lang/cargo/issues/13509
This commit is contained in:
parent
f772ec0224
commit
604d2e40e2
|
@ -2702,15 +2702,22 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "pulldown-cmark"
|
||||
version = "0.9.3"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998"
|
||||
checksum = "dce76ce678ffc8e5675b22aa1405de0b7037e2fdf8913fea40d1926c6fe1e6e7"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"bitflags 2.4.1",
|
||||
"memchr",
|
||||
"pulldown-cmark-escape",
|
||||
"unicase",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pulldown-cmark-escape"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d5d8f9aa0e3cbcfaf8bf00300004ee3b72f74770f9cbac93f6928771f613276b"
|
||||
|
||||
[[package]]
|
||||
name = "quick-error"
|
||||
version = "1.2.3"
|
||||
|
|
|
@ -74,7 +74,7 @@ pathdiff = "0.2"
|
|||
percent-encoding = "2.3"
|
||||
pkg-config = "0.3.30"
|
||||
proptest = "1.4.0"
|
||||
pulldown-cmark = { version = "0.9.3", default-features = false }
|
||||
pulldown-cmark = { version = "0.10.0", default-features = false, features = ["html"] }
|
||||
rand = "0.8.5"
|
||||
regex = "1.10.3"
|
||||
rusqlite = { version = "0.31.0", features = ["bundled"] }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use crate::util::{header_text, parse_name_and_section};
|
||||
use crate::EventIter;
|
||||
use anyhow::{bail, Error};
|
||||
use pulldown_cmark::{Alignment, Event, HeadingLevel, LinkType, Tag};
|
||||
use pulldown_cmark::{Alignment, Event, HeadingLevel, LinkType, Tag, TagEnd};
|
||||
use std::fmt::Write;
|
||||
use url::Url;
|
||||
|
||||
|
@ -110,6 +110,7 @@ impl<'e> ManRenderer<'e> {
|
|||
let mut suppress_paragraph = false;
|
||||
let mut table_cell_index = 0;
|
||||
|
||||
let mut last_seen_link_data = None;
|
||||
while let Some((event, range)) = self.parser.next() {
|
||||
let this_suppress_paragraph = suppress_paragraph;
|
||||
suppress_paragraph = false;
|
||||
|
@ -122,7 +123,7 @@ impl<'e> ManRenderer<'e> {
|
|||
self.output.push_str(".sp\n");
|
||||
}
|
||||
}
|
||||
Tag::Heading(level, ..) => {
|
||||
Tag::Heading { level, .. } => {
|
||||
if level == HeadingLevel::H1 {
|
||||
self.push_top_header()?;
|
||||
} else if level == HeadingLevel::H2 {
|
||||
|
@ -212,7 +213,12 @@ impl<'e> ManRenderer<'e> {
|
|||
Tag::Strong => self.push_font(Font::Bold),
|
||||
// Strikethrough isn't usually supported for TTY.
|
||||
Tag::Strikethrough => self.output.push_str("~~"),
|
||||
Tag::Link(link_type, dest_url, _title) => {
|
||||
Tag::Link {
|
||||
link_type,
|
||||
dest_url,
|
||||
..
|
||||
} => {
|
||||
last_seen_link_data = Some((link_type.clone(), dest_url.to_owned()));
|
||||
if dest_url.starts_with('#') {
|
||||
// In a man page, page-relative anchors don't
|
||||
// have much meaning.
|
||||
|
@ -247,49 +253,51 @@ impl<'e> ManRenderer<'e> {
|
|||
}
|
||||
}
|
||||
}
|
||||
Tag::Image(_link_type, _dest_url, _title) => {
|
||||
Tag::Image { .. } => {
|
||||
bail!("images are not currently supported")
|
||||
}
|
||||
Tag::HtmlBlock { .. } | Tag::MetadataBlock { .. } => {}
|
||||
}
|
||||
}
|
||||
Event::End(tag) => {
|
||||
match &tag {
|
||||
Tag::Paragraph => self.flush(),
|
||||
Tag::Heading(..) => {}
|
||||
Tag::BlockQuote => {
|
||||
Event::End(tag_end) => {
|
||||
match &tag_end {
|
||||
TagEnd::Paragraph => self.flush(),
|
||||
TagEnd::Heading(..) => {}
|
||||
TagEnd::BlockQuote => {
|
||||
self.flush();
|
||||
// restore left margin, restore line length
|
||||
self.output.push_str(".br\n.RE\n.ll\n");
|
||||
}
|
||||
Tag::CodeBlock(_kind) => {
|
||||
TagEnd::CodeBlock => {
|
||||
self.flush();
|
||||
// Restore fill mode, move margin back one level.
|
||||
self.output.push_str(".fi\n.RE\n");
|
||||
}
|
||||
Tag::List(_) => {
|
||||
TagEnd::List(_) => {
|
||||
list.pop();
|
||||
}
|
||||
Tag::Item => {
|
||||
TagEnd::Item => {
|
||||
self.flush();
|
||||
// Move margin back one level.
|
||||
self.output.push_str(".RE\n");
|
||||
}
|
||||
Tag::FootnoteDefinition(_label) => {}
|
||||
Tag::Table(_) => {
|
||||
TagEnd::FootnoteDefinition => {}
|
||||
TagEnd::Table => {
|
||||
// Table end
|
||||
// I don't know why, but the .sp is needed to provide
|
||||
// space with the following content.
|
||||
self.output.push_str("\n.TE\n.sp\n");
|
||||
}
|
||||
Tag::TableHead => {}
|
||||
Tag::TableRow => {}
|
||||
Tag::TableCell => {
|
||||
TagEnd::TableHead => {}
|
||||
TagEnd::TableRow => {}
|
||||
TagEnd::TableCell => {
|
||||
// End text block.
|
||||
self.output.push_str("\nT}");
|
||||
}
|
||||
Tag::Emphasis | Tag::Strong => self.pop_font(),
|
||||
Tag::Strikethrough => self.output.push_str("~~"),
|
||||
Tag::Link(link_type, dest_url, _title) => {
|
||||
TagEnd::Emphasis | TagEnd::Strong => self.pop_font(),
|
||||
TagEnd::Strikethrough => self.output.push_str("~~"),
|
||||
TagEnd::Link => {
|
||||
if let Some((link_type, ref dest_url)) = last_seen_link_data {
|
||||
if dest_url.starts_with('#') {
|
||||
continue;
|
||||
}
|
||||
|
@ -303,12 +311,13 @@ impl<'e> ManRenderer<'e> {
|
|||
self.output.push(' ');
|
||||
}
|
||||
_ => {
|
||||
panic!("unexpected tag {:?}", tag);
|
||||
panic!("unexpected tag {:?}", tag_end);
|
||||
}
|
||||
}
|
||||
write!(self.output, "<{}>", escape(&dest_url)?)?;
|
||||
}
|
||||
Tag::Image(_link_type, _dest_url, _title) => {}
|
||||
}
|
||||
TagEnd::Image | TagEnd::HtmlBlock | TagEnd::MetadataBlock(..) => {}
|
||||
}
|
||||
}
|
||||
Event::Text(t) => {
|
||||
|
@ -346,6 +355,7 @@ impl<'e> ManRenderer<'e> {
|
|||
self.output.push_str("\\l'\\n(.lu'\n");
|
||||
}
|
||||
Event::TaskListMarker(_b) => unimplemented!(),
|
||||
Event::InlineHtml(..) => unimplemented!(),
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use crate::util::{header_text, unwrap};
|
||||
use crate::EventIter;
|
||||
use anyhow::{bail, Error};
|
||||
use pulldown_cmark::{Alignment, Event, HeadingLevel, LinkType, Tag};
|
||||
use pulldown_cmark::{Alignment, Event, HeadingLevel, LinkType, Tag, TagEnd};
|
||||
use std::fmt::Write;
|
||||
use std::mem;
|
||||
use url::Url;
|
||||
|
@ -102,6 +102,7 @@ impl<'e> TextRenderer<'e> {
|
|||
// Whether or not word-wrapping is enabled.
|
||||
let mut wrap_text = true;
|
||||
|
||||
let mut last_seen_link_data = None;
|
||||
while let Some((event, range)) = self.parser.next() {
|
||||
let this_suppress_paragraph = suppress_paragraph;
|
||||
// Always reset suppression, even if the next event isn't a
|
||||
|
@ -116,7 +117,7 @@ impl<'e> TextRenderer<'e> {
|
|||
self.flush();
|
||||
}
|
||||
}
|
||||
Tag::Heading(level, ..) => {
|
||||
Tag::Heading { level, .. } => {
|
||||
self.flush();
|
||||
if level == HeadingLevel::H1 {
|
||||
let text = header_text(&mut self.parser)?;
|
||||
|
@ -180,7 +181,12 @@ impl<'e> TextRenderer<'e> {
|
|||
Tag::Strong => {}
|
||||
// Strikethrough isn't usually supported for TTY.
|
||||
Tag::Strikethrough => self.word.push_str("~~"),
|
||||
Tag::Link(link_type, dest_url, _title) => {
|
||||
Tag::Link {
|
||||
link_type,
|
||||
dest_url,
|
||||
..
|
||||
} => {
|
||||
last_seen_link_data = Some((link_type.clone(), dest_url.to_owned()));
|
||||
if dest_url.starts_with('#') {
|
||||
// In a man page, page-relative anchors don't
|
||||
// have much meaning.
|
||||
|
@ -213,42 +219,44 @@ impl<'e> TextRenderer<'e> {
|
|||
}
|
||||
}
|
||||
}
|
||||
Tag::Image(_link_type, _dest_url, _title) => {
|
||||
Tag::Image { .. } => {
|
||||
bail!("images are not currently supported")
|
||||
}
|
||||
Tag::HtmlBlock { .. } | Tag::MetadataBlock { .. } => {}
|
||||
}
|
||||
}
|
||||
Event::End(tag) => match &tag {
|
||||
Tag::Paragraph => {
|
||||
Event::End(tag_end) => match &tag_end {
|
||||
TagEnd::Paragraph => {
|
||||
self.flush();
|
||||
self.hard_break();
|
||||
}
|
||||
Tag::Heading(..) => {}
|
||||
Tag::BlockQuote => {
|
||||
TagEnd::Heading(..) => {}
|
||||
TagEnd::BlockQuote => {
|
||||
self.indent -= 3;
|
||||
}
|
||||
Tag::CodeBlock(_kind) => {
|
||||
TagEnd::CodeBlock => {
|
||||
self.hard_break();
|
||||
wrap_text = true;
|
||||
self.indent -= 4;
|
||||
}
|
||||
Tag::List(_) => {
|
||||
TagEnd::List(..) => {
|
||||
list.pop();
|
||||
}
|
||||
Tag::Item => {
|
||||
TagEnd::Item => {
|
||||
self.flush();
|
||||
self.indent -= 3;
|
||||
self.hard_break();
|
||||
}
|
||||
Tag::FootnoteDefinition(_label) => {}
|
||||
Tag::Table(_) => {}
|
||||
Tag::TableHead => {}
|
||||
Tag::TableRow => {}
|
||||
Tag::TableCell => {}
|
||||
Tag::Emphasis => {}
|
||||
Tag::Strong => {}
|
||||
Tag::Strikethrough => self.word.push_str("~~"),
|
||||
Tag::Link(link_type, dest_url, _title) => {
|
||||
TagEnd::FootnoteDefinition => {}
|
||||
TagEnd::Table => {}
|
||||
TagEnd::TableHead => {}
|
||||
TagEnd::TableRow => {}
|
||||
TagEnd::TableCell => {}
|
||||
TagEnd::Emphasis => {}
|
||||
TagEnd::Strong => {}
|
||||
TagEnd::Strikethrough => self.word.push_str("~~"),
|
||||
TagEnd::Link => {
|
||||
if let Some((link_type, ref dest_url)) = last_seen_link_data {
|
||||
if dest_url.starts_with('#') {
|
||||
continue;
|
||||
}
|
||||
|
@ -259,13 +267,14 @@ impl<'e> TextRenderer<'e> {
|
|||
| LinkType::Collapsed
|
||||
| LinkType::Shortcut => self.flush_word(),
|
||||
_ => {
|
||||
panic!("unexpected tag {:?}", tag);
|
||||
panic!("unexpected tag {:?}", tag_end);
|
||||
}
|
||||
}
|
||||
self.flush_word();
|
||||
write!(self.word, "<{}>", dest_url)?;
|
||||
}
|
||||
Tag::Image(_link_type, _dest_url, _title) => {}
|
||||
}
|
||||
TagEnd::Image | TagEnd::HtmlBlock | TagEnd::MetadataBlock(..) => {}
|
||||
},
|
||||
Event::Text(t) | Event::Code(t) => {
|
||||
if wrap_text {
|
||||
|
@ -337,6 +346,7 @@ impl<'e> TextRenderer<'e> {
|
|||
self.flush();
|
||||
}
|
||||
Event::TaskListMarker(_b) => unimplemented!(),
|
||||
Event::InlineHtml(..) => unimplemented!(),
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -451,20 +461,20 @@ impl Table {
|
|||
| Tag::Strong => {}
|
||||
Tag::Strikethrough => self.cell.push_str("~~"),
|
||||
// Links not yet supported, they usually won't fit.
|
||||
Tag::Link(_, _, _) => {}
|
||||
Tag::Link { .. } => {}
|
||||
_ => bail!("unexpected tag in table: {:?}", tag),
|
||||
},
|
||||
Event::End(tag) => match tag {
|
||||
Tag::Table(_) => return self.render(indent),
|
||||
Tag::TableCell => {
|
||||
Event::End(tag_end) => match tag_end {
|
||||
TagEnd::Table => return self.render(indent),
|
||||
TagEnd::TableCell => {
|
||||
let cell = mem::replace(&mut self.cell, String::new());
|
||||
self.row.push(cell);
|
||||
}
|
||||
Tag::TableHead | Tag::TableRow => {
|
||||
TagEnd::TableHead | TagEnd::TableRow => {
|
||||
let row = mem::replace(&mut self.row, Vec::new());
|
||||
self.rows.push(row);
|
||||
}
|
||||
Tag::Strikethrough => self.cell.push_str("~~"),
|
||||
TagEnd::Strikethrough => self.cell.push_str("~~"),
|
||||
_ => {}
|
||||
},
|
||||
Event::Text(t) | Event::Code(t) => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! mdman markdown to man converter.
|
||||
|
||||
use anyhow::{bail, Context, Error};
|
||||
use pulldown_cmark::{CowStr, Event, LinkType, Options, Parser, Tag};
|
||||
use pulldown_cmark::{CowStr, Event, LinkType, Options, Parser, Tag, TagEnd};
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use std::io::{self, BufRead};
|
||||
|
@ -74,14 +74,21 @@ pub(crate) fn md_parser(input: &str, url: Option<Url>) -> EventIter<'_> {
|
|||
let parser = parser.into_offset_iter();
|
||||
// Translate all links to include the base url.
|
||||
let parser = parser.map(move |(event, range)| match event {
|
||||
Event::Start(Tag::Link(lt, dest_url, title)) if !matches!(lt, LinkType::Email) => (
|
||||
Event::Start(Tag::Link(lt, join_url(url.as_ref(), dest_url), title)),
|
||||
range,
|
||||
),
|
||||
Event::End(Tag::Link(lt, dest_url, title)) if !matches!(lt, LinkType::Email) => (
|
||||
Event::End(Tag::Link(lt, join_url(url.as_ref(), dest_url), title)),
|
||||
Event::Start(Tag::Link {
|
||||
link_type,
|
||||
dest_url,
|
||||
title,
|
||||
id,
|
||||
}) if !matches!(link_type, LinkType::Email) => (
|
||||
Event::Start(Tag::Link {
|
||||
link_type,
|
||||
dest_url: join_url(url.as_ref(), dest_url),
|
||||
title,
|
||||
id,
|
||||
}),
|
||||
range,
|
||||
),
|
||||
Event::End(TagEnd::Link) => (Event::End(TagEnd::Link), range),
|
||||
_ => (event, range),
|
||||
});
|
||||
Box::new(parser)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
///! General utilities.
|
||||
use crate::EventIter;
|
||||
use anyhow::{bail, format_err, Context, Error};
|
||||
use pulldown_cmark::{CowStr, Event, Tag};
|
||||
use pulldown_cmark::{CowStr, Event, TagEnd};
|
||||
|
||||
/// Splits the text `foo(1)` into "foo" and `1`.
|
||||
pub fn parse_name_and_section(text: &str) -> Result<(&str, u8), Error> {
|
||||
|
@ -31,7 +31,7 @@ pub fn header_text<'e>(parser: &mut EventIter<'e>) -> Result<CowStr<'e>, Error>
|
|||
e => bail!("expected plain text in man header, got {:?}", e),
|
||||
};
|
||||
match parser.next() {
|
||||
Some((Event::End(Tag::Heading(..)), _range)) => {
|
||||
Some((Event::End(TagEnd::Heading(..)), _range)) => {
|
||||
return Ok(text);
|
||||
}
|
||||
e => bail!("expected plain text in man header, got {:?}", e),
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
Testing tables.
|
||||
|
||||
| Single col |
|
||||
--------------
|
||||
|------------|
|
||||
| Hi! :) |
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@ Extra long text 123456789012 with mixed widths. | Extra long text 123456789012 w
|
|||
|
||||
|
||||
| Link check |
|
||||
--------------
|
||||
|------------|
|
||||
| [foo] |
|
||||
| <https://example.com/> |
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
Testing tables.
|
||||
|
||||
| Single col |
|
||||
--------------
|
||||
|------------|
|
||||
| Hi! :) |
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@ Extra long text 123456789012 with mixed widths. | Extra long text 123456789012 w
|
|||
|
||||
|
||||
| Link check |
|
||||
--------------
|
||||
|------------|
|
||||
| [foo] |
|
||||
| <https://example.com/> |
|
||||
|
||||
|
|
|
@ -108,13 +108,13 @@ which is defined by the <code>registry.default</code> config key which defaults
|
|||
|
||||
|
||||
<dt class="option-term" id="option-cargo-add---public"><a class="option-anchor" href="#option-cargo-add---public"></a><code>--public</code></dt>
|
||||
<dd class="option-desc">Mark the dependency as public. </p>
|
||||
<dd class="option-desc">Mark the dependency as public.</p>
|
||||
<p>The dependency can be referenced in your library’s public API.</p>
|
||||
<p><a href="../reference/unstable.html#public-dependency">Unstable (nightly-only)</a></dd>
|
||||
|
||||
|
||||
<dt class="option-term" id="option-cargo-add---no-public"><a class="option-anchor" href="#option-cargo-add---no-public"></a><code>--no-public</code></dt>
|
||||
<dd class="option-desc">Mark the dependency as private. </p>
|
||||
<dd class="option-desc">Mark the dependency as private.</p>
|
||||
<p>While you can use the crate in your implementation, it cannot be referenced in your public API.</p>
|
||||
<p><a href="../reference/unstable.html#public-dependency">Unstable (nightly-only)</a></dd>
|
||||
|
||||
|
|
|
@ -222,7 +222,7 @@ target artifacts are placed in a separate directory. See the
|
|||
specified with the <code>CARGO_TARGET_DIR</code> environment variable, or the
|
||||
<code>build.target-dir</code> <a href="../reference/config.html">config value</a>.
|
||||
Defaults to a new temporary folder located in the
|
||||
temporary directory of the platform. </p>
|
||||
temporary directory of the platform.</p>
|
||||
<p>When using <code>--path</code>, by default it will use <code>target</code> directory in the workspace
|
||||
of the local crate unless <code>--target-dir</code>
|
||||
is specified.</dd>
|
||||
|
|
Loading…
Reference in New Issue