Debian Codegraph @

src/block.rs

raw symbols SCIP
1 //! Module for converting HTML markup to blocks with Pango Markup formatted content.
2 //!
3 //! The functions in this module turn the HTML input to a list of block elements (see
4 //! [`HtmlBlock`]) rather then an output string. This can be useful if the blocks are rendered
5 //! separately, for example if you have some text followed by a code block. The former may be
6 //! rendered using a different widget than the latter.
7 //!
8 //! The main function of this module is [`markup_html`].
9 //! It yields HTML blocks for the following tags:
10 //! * `<h1>`, `<h2>`, `<h3>`, `<h4>`, `<h5>`, `<h6>` => [`HtmlBlock::Heading`]
11 //! * `<pre>` => [`HtmlBlock::Code`]
12 //! * `<ul>` => [`HtmlBlock::UList`]
13 //! * `<ol>` => [`HtmlBlock::OList`]
14 //! * `<blockquote>` => [`HtmlBlock::Quote`]
15 //!
16 //! It handles the following tags as text, yielding an [`HtmlBlock::Text`] with the contents:
17 //! * `<a>` => `<a>` with only the `href` attribute set
18 //! * `<b>` and `<strong>` => `<b>`
19 //! * `<body>` and `<mx-reply>` => removed
20 //! * `<br>` => `\n`
21 //! * `<code>` => `<tt>`
22 //! * `<del>` and `<s>` => `<s>`
23 //! * `<em>` and `<i>` => `<i>`
24 //! * `<span>` and `<font>` => `<span>`
25 //! * `<p>` => contents followed by `\n`
26 //! * `<u>` => `<u>`
27 //!
28 //! Finally, it removes all other tags and replaces URIs by HTML link tags. and merges
29 //! subsequent text HTML blocks into a single one.
30 //!
31 //! # Examples
32 //!
33 //! Converting HTML markup with a heading and two paragraphs:
34 //!
35 //! ```rust
36 //! # use html2pango::block::*;
37 //! let blks =
38 //! markup_html("<h1>Heading</h1><p>This is paragraph 1.</p><p>Paragraph 2</p>").unwrap();
39 //! assert_eq!(blks[0], HtmlBlock::Heading(1, String::from("Heading")));
40 //! assert_eq!(blks[1], HtmlBlock::Text(String::from("This is paragraph 1.\n\nParagraph 2")));
41 //! ```
42 //!
43 //! Converting HTML markup with an unordered list and some formatting:
44 //!
45 //! ```rust
46 //! # use html2pango::block::*;
47 //! let blks =
48 //! markup_html("<ul><li>This is <b>bold</b></li><li><code>Some code</code></ul>").unwrap();
49 //! assert_eq!(
50 //! blks[0],
51 //! HtmlBlock::UList(vec![
52 //! String::from("This is <b>bold</b>"),
53 //! String::from("<tt>Some code</tt>"),
54 //! ])
55 //! );
56 //! ```
57 //!
58 //! Converting HTML markup links and URIs that are converted into links:
59 //!
60 //! ```rust
61 //! # use html2pango::block::*;
62 //! let blks = markup_html("a <a href=\"https://gnome.org\" rel=\"nofollow\">link</a> and \
63 //! another: https://gnome.org").unwrap();
64 //! assert_eq!(
65 //! blks[0],
66 //! HtmlBlock::Text(
67 //! String::from(
68 //! "a <a href=\"https://gnome.org\" title=\"https://gnome.org\">link</a> and \
69 //! another: <a href=\"https://gnome.org\">https://gnome.org</a>"
70 //! )
71 //! )
72 //! );
73 //! ```
74 //!
75 //! For more examples, see [`markup_html`].
76
77 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/::RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#;
78 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/::Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#;
79
80 use superrust-analyzer cargo html2pango 0.6.0 crate/::html_escaperust-analyzer cargo html2pango 0.6.0 html_escape().;
81 use superrust-analyzer cargo html2pango 0.6.0 crate/::markup_linksrust-analyzer cargo html2pango 0.6.0 markup_links().;
82
83 use html5everrust-analyzer cargo html5ever 0.35.0 crate/::tendrilrust-analyzer cargo tendril 0.4.3 crate/::TendrilSinkrust-analyzer cargo tendril 0.4.3 stream/TendrilSink#;
84 use html5everrust-analyzer cargo html5ever 0.35.0 crate/::tree_builderrust-analyzer cargo html5ever 0.35.0 tree_builder/::Attributerust-analyzer cargo markup5ever 0.35.0 interface/Attribute#;
85 use html5everrust-analyzer cargo html5ever 0.35.0 crate/::tree_builderrust-analyzer cargo html5ever 0.35.0 tree_builder/::TreeBuilderOptsrust-analyzer cargo html5ever 0.35.0 tree_builder/TreeBuilderOpts#;
86 use html5everrust-analyzer cargo html5ever 0.35.0 crate/::{parse_documentrust-analyzer cargo html5ever 0.35.0 driver/parse_document()., ParseOptsrust-analyzer cargo html5ever 0.35.0 driver/ParseOpts#};
87 use markup5ever_rcdomrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial crate/::Noderust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial Node#;
88 use markup5ever_rcdomrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial crate/::NodeDatarust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#;
89 use markup5ever_rcdomrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial crate/::RcDomrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial RcDom#;
90
91 /// Supported HTML block elements.
92 ///
93 /// Each block element contains a textual representation of the contained inline HTML elements in
94 /// [Pango Markup]. The exception is [`HtmlBlock::Quote`], which contains the list of block
95 /// elements that are contained in the quote.
96 ///
97 /// [Pango Markup]: https://docs.gtk.org/Pango/pango_markup.html
98 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
99 pub enum HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock# {
100 /// Just some text.
101 Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#),
102 /// Heading with its level and text.
103 Headingrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Heading#(u32, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#),
104 /// Unordered list of text.
105 UListrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#UList#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>),
106 /// Ordered list of text.
107 OListrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#OList#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>),
108 /// Code block with its contained (preformatted) text.
109 Coderust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Code#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#),
110 /// (Block)quote with its contained block elements.
111 Quoterust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Quote#(Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#>>),
112 /// Vertical separator (i.e. horizontal rule)
113 Separatorrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Separator#,
114 }
115
116 /// Converts HTML body markup into a list of HTML blocks while ignoring some tags.
117 ///
118 /// The provided tags are ignored while parsing as if they are not there, i.e. the parser just
119 /// descends into them and leaves them out of the result.
120 ///
121 /// For more details on what is actually converted, see the [module documentation](crate::block).
122 ///
123 /// # Errors
124 ///
125 /// Returns an error if reading from the strings fails or if parsing somehow fails.
126 ///
127 /// # Examples
128 ///
129 /// ```rust
130 /// # use html2pango::block::*;
131 /// let blks =
132 /// markup_html_ignore_tags("<reply>this is <em>nice</em></reply>", &["body"]).unwrap();
133 /// assert_eq!(blks, vec![HtmlBlock::Text(String::from("this is <i>nice</i>"))]);
134 /// ```
135 ///
136 /// For more examples about the markup conversion, see [`markup_html`].
137 pub fn markup_html_ignore_tagsrust-analyzer cargo html2pango 0.6.0 block/markup_html_ignore_tags().(s: &str, tags: &[&str]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#>, anyhowrust-analyzer cargo anyhow 1.0.104 crate/::Errorrust-analyzer cargo anyhow 1.0.104 Error#> {
138 let opts = ParseOptsrust-analyzer cargo html5ever 0.35.0 driver/ParseOpts# {
139 tree_builderrust-analyzer cargo html5ever 0.35.0 driver/ParseOpts#tree_builder.: TreeBuilderOptsrust-analyzer cargo html5ever 0.35.0 tree_builder/TreeBuilderOpts# {
140 drop_doctyperust-analyzer cargo html5ever 0.35.0 tree_builder/TreeBuilderOpts#drop_doctype.: true,
141 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo html5ever 0.35.0 tree_builder/impl#[TreeBuilderOpts][Default]default().()
142 },
143 ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo html5ever 0.35.0 driver/impl#[ParseOpts][Default]default().()
144 };
145 let dom = parse_documentrust-analyzer cargo html5ever 0.35.0 driver/parse_document().(RcDomrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial RcDom#::defaultrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial impl#[RcDom][Default]default().(), opts)
146 .from_utf8rust-analyzer cargo html5ever 0.35.0 driver/impl#[`Parser<Sink>`]from_utf8().()
147 .read_fromrust-analyzer cargo tendril 0.4.3 stream/TendrilSink#read_from().(&mut s.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
148
149 let document = &dom.documentrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial RcDom#document.;
150 let mut html = document.childrenrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial Node#children..borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().().clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().();
151 // TODO: When writing `<i>...</i>` in markdown, the first children is of type
152 // Comment { contents: "raw HTML omitted" }
153 // This should be handled more gracefully
154 html.retainrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]retain().(|x| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(x.datarust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial Node#data., NodeDatarust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#::Commentrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#Comment# { .. }));
155
156 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(h) = &html.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(0) {
157 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(node) = &h.childrenrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial Node#children..borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().().getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(1) {
158 let markup = convert_noderust-analyzer cargo html2pango 0.6.0 block/convert_node().(node, tags);
159 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(trim_text_blocksrust-analyzer cargo html2pango 0.6.0 block/trim_text_blocks().(markup));
160 }
161 }
162 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(anyhowrust-analyzer cargo anyhow 1.0.104 crate/::anyhowrust-analyzer cargo anyhow 1.0.104 macros/anyhow!!(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Could not parse {:?}", html)))
163 }
164
165 /// Converts HTML body markup into a list of HTML blocks.
166 ///
167 /// Calls [`markup_html_ignore_tags`] to do the actual work instructing it to ignore the `<body>`
168 /// and `mx-reply` (for Matrix) tags.
169 ///
170 /// For more details on what is actually converted, see the [module documentation](crate::block).
171 ///
172 /// # Errors
173 ///
174 /// Returns an error if reading from the string fails or if parsing fails.
175 ///
176 /// # Examples
177 ///
178 /// Some HTML markup of a heading and an unordered list:
179 ///
180 /// ```rust
181 /// # use html2pango::block::*;
182 /// let blks =
183 /// markup_html("<body><h1>Heading 1</h1><ul><li>First</li><li>Second</li><body>").unwrap();
184 /// assert_eq!(blks[0], HtmlBlock::Heading(1, String::from("Heading 1")));
185 /// assert_eq!(blks[1], HtmlBlock::UList(vec![String::from("First"), String::from("Second")]));
186 /// ```
187 ///
188 /// Pango Markup is applied, paragraphs are handled but merged:
189 ///
190 /// ```rust
191 /// # use html2pango::block::*;
192 /// let blks =
193 /// markup_html("<body><p>This is <em>nice</em>!</p><p>Second paragraph.</p></body>").unwrap();
194 /// assert_eq!(
195 /// blks[0],
196 /// HtmlBlock::Text(String::from("This is <i>nice</i>!\n\nSecond paragraph."))
197 /// );
198 /// ```
199 ///
200 /// URIs are replaced by links:
201 ///
202 /// ```rust
203 /// # use html2pango::block::*;
204 /// let blks =
205 /// markup_html("<body>Go to https://gnome.org</body>").unwrap();
206 /// assert_eq!(
207 /// blks[0],
208 /// HtmlBlock::Text(String::from("Go to <a href=\"https://gnome.org\">https://gnome.org</a>"))
209 /// );
210 /// ```
211 ///
212 pub fn markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#>, anyhowrust-analyzer cargo anyhow 1.0.104 crate/::Errorrust-analyzer cargo anyhow 1.0.104 Error#> {
213 let tags = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!["body", "mx-reply"];
214 markup_html_ignore_tagsrust-analyzer cargo html2pango 0.6.0 block/markup_html_ignore_tags().(s, &tags)
215 }
216
217 fn to_pangorust-analyzer cargo html2pango 0.6.0 block/to_pango().(t: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(&'static str, &'static str)> {
218 let allowed = [
219 "u", "del", "s", "em", "i", "strong", "b", "code", "a", "br", "sub", "sup",
220 ];
221
222 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().allowed.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&t) {
223 return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
224 }
225
226 match t {
227 "a" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(("<a>", "</a>")),
228 "br" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(("", "\n")),
229 "em" | "i" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(("<i>", "</i>")),
230 "strong" | "b" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(("<b>", "</b>")),
231 "del" | "s" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(("<s>", "</s>")),
232 "u" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(("<u>", "</u>")),
233 "code" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(("<tt>", "</tt>")),
234 "sub" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(("<sub>", "</sub>")),
235 "sup" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(("<sup>", "</sup>")),
236 _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
237 }
238 }
239
240 fn parse_linkrust-analyzer cargo html2pango 0.6.0 block/parse_link().(node: &Noderust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial Node#, attrs: &RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Attributerust-analyzer cargo markup5ever 0.35.0 interface/Attribute#>>) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
241 let mut link = "".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
242 for attr in attrs.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().().iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() {
243 let s = attr.namerust-analyzer cargo markup5ever 0.35.0 interface/Attribute#name..localrust-analyzer cargo markup5ever 0.35.0 interface/QualName#local..to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
244 if &s[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."href" {
245 link = attr.valuerust-analyzer cargo markup5ever 0.35.0 interface/Attribute#value..to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
246 }
247 }
248
249 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
250 "<a href=\"{0}\" title=\"{0}\">{1}</a>",
251 html_escaperust-analyzer cargo html2pango 0.6.0 html_escape().(&link),
252 get_text_contentrust-analyzer cargo html2pango 0.6.0 block/get_text_content().(node)
253 )
254 }
255
256 fn get_text_contentrust-analyzer cargo html2pango 0.6.0 block/get_text_content().(node: &Noderust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial Node#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
257 let text = node
258 .childrenrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial Node#children.
259 .borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().()
260 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
261 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|node| match node.datarust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial Node#data. {
262 NodeDatarust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#::Textrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#Text# { contentsrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#Text#contents.: ref c } => {
263 markup_linksrust-analyzer cargo html2pango 0.6.0 markup_links().(&replace_html_whitespacerust-analyzer cargo html2pango 0.6.0 block/replace_html_whitespace().(&html_escaperust-analyzer cargo html2pango 0.6.0 html_escape().(&c.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().())))
264 }
265 NodeDatarust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#::Elementrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#Element# {
266 namerust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#Element#name.: ref n,
267 attrsrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#Element#attrs.: ref a,
268 ..
269 } => {
270 let inside = get_text_contentrust-analyzer cargo html2pango 0.6.0 block/get_text_content().(node);
271
272 if &n.localrust-analyzer cargo markup5ever 0.35.0 interface/QualName#local. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."a" {
273 return parse_linkrust-analyzer cargo html2pango 0.6.0 block/parse_link().(node, a);
274 }
275
276 match to_pangorust-analyzer cargo html2pango 0.6.0 block/to_pango().(&n.localrust-analyzer cargo markup5ever 0.35.0 interface/QualName#local.) {
277 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((t1, t2)) => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}{}{}", t1, inside, t2),
278 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => inside,
279 }
280 }
281 _ => get_text_contentrust-analyzer cargo html2pango 0.6.0 block/get_text_content().(node),
282 })
283 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>()
284 .concatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]concat().();
285
286 collapse_spacesrust-analyzer cargo html2pango 0.6.0 block/collapse_spaces().(&text)
287 }
288
289 fn get_plain_text_contentrust-analyzer cargo html2pango 0.6.0 block/get_plain_text_content().(node: &Noderust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial Node#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
290 node.childrenrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial Node#children.
291 .borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().()
292 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
293 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|node| match node.datarust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial Node#data. {
294 NodeDatarust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#::Textrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#Text# { contentsrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#Text#contents.: ref c } => c.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
295 NodeDatarust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#::Elementrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#Element# {
296 namerust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#Element#name.: ref n,
297 attrsrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#Element#attrs.: ref _a,
298 ..
299 } => {
300 let inside = get_plain_text_contentrust-analyzer cargo html2pango 0.6.0 block/get_plain_text_content().(node);
301 match to_pangorust-analyzer cargo html2pango 0.6.0 block/to_pango().(&n.localrust-analyzer cargo markup5ever 0.35.0 interface/QualName#local.) {
302 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((t1, t2)) => {
303 // We don't want tt tags inside codeblocks which
304 // already have <tt>.
305 if t1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne()."<tt>" {
306 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}{}{}", t1, inside, t2)
307 } else {
308 inside
309 }
310 }
311 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => inside,
312 }
313 }
314 _ => get_plain_text_contentrust-analyzer cargo html2pango 0.6.0 block/get_plain_text_content().(node),
315 })
316 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>()
317 .concatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]concat().()
318 }
319
320 fn get_li_elementsrust-analyzer cargo html2pango 0.6.0 block/get_li_elements().(node: &Noderust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial Node#) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
321 node.childrenrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial Node#children.
322 .borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().()
323 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
324 .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|node| match node.datarust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial Node#data. {
325 NodeDatarust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#::Elementrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#Element# { namerust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#Element#name.: ref n, .. } if &n.localrust-analyzer cargo markup5ever 0.35.0 interface/QualName#local. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."li" => {
326 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(get_text_contentrust-analyzer cargo html2pango 0.6.0 block/get_text_content().(node))
327 }
328 _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
329 })
330 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>()
331 }
332
333 fn join_text_blocksrust-analyzer cargo html2pango 0.6.0 block/join_text_blocks().(mut blocks: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#>) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#> {
334 use HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#;
335
336 blocks.drainrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]drain().(..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#).foldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#fold().(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#>::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(), |mut v, b| {
337 let last = v.lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().();
338 if let (Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(c), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(a))) = (&b, last) {
339 let t = join_collapse_spacesrust-analyzer cargo html2pango 0.6.0 block/join_collapse_spaces().(a, c);
340 v.poprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]pop().();
341 v.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(t));
342 } else {
343 v.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(b);
344 }
345
346 v
347 })
348 }
349
350 fn join_collapse_spacesrust-analyzer cargo html2pango 0.6.0 block/join_collapse_spaces().(s: &str, extra: &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
351 if s.ends_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]ends_with().(' ') && (extra.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().('\n') || extra.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().(' ')) {
352 s.trim_endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_end().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().+rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().extra
353 } else if s.ends_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]ends_with().('\n') && extra.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().(' ') {
354 s.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().+rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().extra.trim_startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_start().()
355 } else {
356 s.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().+rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().extra
357 }
358 }
359
360 fn collapse_spacesrust-analyzer cargo html2pango 0.6.0 block/collapse_spaces().(s: &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
361 let mut collapsed_s = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]with_capacity().(s.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().());
362 let mut iter = s.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().peekablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#peekable().();
363 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(c) = iter.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().() {
364 match (c, iter.peekrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`]peek().()) {
365 (' ', Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#('\n')) | (' ', Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(' ')) => continue,
366 ('\n', Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(' ')) => {
367 iter.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().(); // Drop the following space
368 while iter.peekrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`]peek().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&' ') {
369 iter.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().();
370 }
371 }
372 _ => {}
373 }
374
375 collapsed_s.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(c);
376 }
377
378 collapsed_s
379 }
380
381 fn replace_html_whitespacerust-analyzer cargo html2pango 0.6.0 block/replace_html_whitespace().(s: &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
382 let mut result = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().();
383 let mut last = 0;
384
385 for (index, matched) in s.match_indicesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]match_indices().(|c: char| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().c.is_ascii_whitespacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]is_ascii_whitespace().()) {
386 if last rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().index {
387 result.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(' ');
388 }
389 result.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(matched);
390 last = index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().matched.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().();
391 }
392 if last rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().s.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() {
393 result.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(' ');
394 }
395
396 result
397 }
398
399 fn html_unescaperust-analyzer cargo html2pango 0.6.0 block/html_unescape().(s: &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
400 s.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
401 .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().("&amp;", "&")
402 .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().("&lt;", "<")
403 .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().("&gt;", ">")
404 .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().("&quot;", "\"")
405 }
406
407 fn trim_text_blocksrust-analyzer cargo html2pango 0.6.0 block/trim_text_blocks().(mut blocks: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#>) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#> {
408 blocks.drainrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]drain().(..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#).foldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#fold().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![], |mut v, b| {
409 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(c) = &b {
410 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().c.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().().is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() {
411 v.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(c.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
412 }
413 } else {
414 v.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(b);
415 }
416 v
417 })
418 }
419
420 fn convert_noderust-analyzer cargo html2pango 0.6.0 block/convert_node().(node: &Noderust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial Node#, tags_to_ignore: &[&str]) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#> {
421 let mut output = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
422
423 match node.datarust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial Node#data. {
424 NodeDatarust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#::Textrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#Text# { contentsrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#Text#contents.: ref c } => {
425 let s = markup_linksrust-analyzer cargo html2pango 0.6.0 markup_links().(&replace_html_whitespacerust-analyzer cargo html2pango 0.6.0 block/replace_html_whitespace().(&html_escaperust-analyzer cargo html2pango 0.6.0 html_escape().(&c.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().())));
426 output.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(s));
427 }
428
429 NodeDatarust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#::Elementrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#Element# {
430 namerust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#Element#name.: ref n,
431 attrsrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial NodeData#Element#attrs.: ref a,
432 ..
433 } => {
434 match &n.localrust-analyzer cargo markup5ever 0.35.0 interface/QualName#local. as &str {
435 // tags to ignore
436 tag if tags_to_ignore.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&tag) => {
437 for child in node.childrenrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial Node#children..borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().().iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() {
438 for block in convert_noderust-analyzer cargo html2pango 0.6.0 block/convert_node().(child, tags_to_ignore) {
439 output.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(block);
440 }
441 }
442 }
443
444 h if ["h1", "h2", "h3", "h4", "h5", "h6"].containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&h) => {
445 let n: u32 = h[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().(6);
446 let text = get_text_contentrust-analyzer cargo html2pango 0.6.0 block/get_text_content().(node);
447 output.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Headingrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Heading#(n, text));
448 }
449
450 "a" => {
451 let link = parse_linkrust-analyzer cargo html2pango 0.6.0 block/parse_link().(node, a);
452 output.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(link));
453 }
454
455 "pre" => {
456 let text = get_plain_text_contentrust-analyzer cargo html2pango 0.6.0 block/get_plain_text_content().(node);
457 output.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Coderust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Code#(html_unescaperust-analyzer cargo html2pango 0.6.0 block/html_unescape().(text.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().())));
458 }
459
460 "ul" => {
461 let elements = get_li_elementsrust-analyzer cargo html2pango 0.6.0 block/get_li_elements().(node);
462 output.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::UListrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#UList#(elements));
463 }
464
465 "ol" => {
466 let elements = get_li_elementsrust-analyzer cargo html2pango 0.6.0 block/get_li_elements().(node);
467 output.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::OListrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#OList#(elements));
468 }
469
470 "blockquote" => {
471 let mut content = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
472 for child in node.childrenrust-analyzer cargo markup5ever_rcdom 0.35.0+unofficial Node#children..borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().().iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() {
473 for block in convert_noderust-analyzer cargo html2pango 0.6.0 block/convert_node().(child, tags_to_ignore) {
474 content.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(block);
475 }
476 }
477 content = trim_text_blocksrust-analyzer cargo html2pango 0.6.0 block/trim_text_blocks().(join_text_blocksrust-analyzer cargo html2pango 0.6.0 block/join_text_blocks().(content));
478 output.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Quoterust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Quote#(Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T>`]new().(content)));
479 }
480
481 "p" => {
482 let content = &get_text_contentrust-analyzer cargo html2pango 0.6.0 block/get_text_content().(node);
483 output.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("\n{}\n", content.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().())));
484 }
485
486 "hr" => {
487 output.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Separatorrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Separator#);
488 }
489
490 "br" => {
491 output.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#("\n".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
492 }
493
494 "font" | "span" => {
495 let attrs = a.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().();
496 let span_attrs = attrs
497 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
498 .flat_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flat_map().(|attr| match &*rust-analyzer cargo string_cache 0.8.9 atom/impl#[`Atom<Static>`][Deref]deref().attr.namerust-analyzer cargo markup5ever 0.35.0 interface/Attribute#name..localrust-analyzer cargo markup5ever 0.35.0 interface/QualName#local. {
499 "color" | "data-mx-color" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(("foreground", &*rust-analyzer cargo tendril 0.4.3 tendril/impl#[`Tendril<F, A>`][Deref]deref().attr.valuerust-analyzer cargo markup5ever 0.35.0 interface/Attribute#value.)),
500 "data-mx-bg-color" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(("background", &*rust-analyzer cargo tendril 0.4.3 tendril/impl#[`Tendril<F, A>`][Deref]deref().attr.valuerust-analyzer cargo markup5ever 0.35.0 interface/Attribute#value.)),
501 _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
502 })
503 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(&str, &str)>>();
504 let content = get_text_contentrust-analyzer cargo html2pango 0.6.0 block/get_text_content().(node);
505 let mut span = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().();
506 craterust-analyzer cargo html2pango 0.6.0 crate/::format_spanrust-analyzer cargo html2pango 0.6.0 format_span().(&mut span, content, span_attrs);
507
508 output.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(span));
509 }
510
511 tag => {
512 let content = get_text_contentrust-analyzer cargo html2pango 0.6.0 block/get_text_content().(node);
513 let block = match to_pangorust-analyzer cargo html2pango 0.6.0 block/to_pango().(tag) {
514 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((t1, t2)) => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}{}{}", t1, content, t2),
515 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => content,
516 };
517
518 output.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(block));
519 }
520 };
521 }
522 _ => {}
523 }
524
525 join_text_blocksrust-analyzer cargo html2pango 0.6.0 block/join_text_blocks().(output)
526 }
527
528 #[cfg(test)]
529 mod testrust-analyzer cargo html2pango 0.6.0 block/test/ {
530 use superrust-analyzer cargo html2pango 0.6.0 block/::*;
531 use pretty_assertionsrust-analyzer cargo pretty_assertions 1.4.1 crate/::assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!;
532
533 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
534 fn test_html_blocksrust-analyzer cargo html2pango 0.6.0 block/test/test_html_blocks().() {
535 let text = "<h1>heading 1 <em>italic</em></h1>\n<h2>heading 2</h2>\n<p>Some text with <em>markup</em> and <strong>other</strong> and more text and some <code>inline code</code>, that's all. And maybe some links http://google.es or <a href=\"http://gnome.org\">GNOME</a>.</p>\n<pre><code>Block text\n</code></pre>\n<ul>\n<li>This is a list</li>\n<li>second element</li>\n</ul>\n<ol>\n<li>another list</li>\n<li>that's all</li>\n</ol>\n<hr/>";
536 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text);
537 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(blocks.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
538 let blocks = blocks.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
539 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 7);
540
541 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(
542 blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().,
543 HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Headingrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Heading#(1, "heading 1 <i>italic</i>".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
544 );
545 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Headingrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Heading#(2, "heading 2".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
546
547 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(&blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().2]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(..)));
548 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(&blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().3]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Coderust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Code#(..)));
549 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(&blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().4]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::UListrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#UList#(..)));
550 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(&blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().5]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::OListrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#OList#(..)));
551 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(&blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().6]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Separatorrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Separator#));
552 }
553
554 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
555 fn test_html_blocks_quoterust-analyzer cargo html2pango 0.6.0 block/test/test_html_blocks_quote().() {
556 let text = "
557 <blockquote>
558 <h1>heading 1 <em>bold</em></h1>
559 <h2>heading 2</h2>
560 <p>Some text with <em>markup</em> and <strong>other</strong> and more things ~~strike~~ and more text and some <code>inline code</code>, that's all. And maybe some links http://google.es or &lt;a href=&quot;http://gnome.org&quot;&gt;GNOME&lt;/a&gt;, <a href=\"http://gnome.org\">GNOME</a>.</p>
561 <pre><code>`Block text
562 `
563 </code></pre>
564 <ul>
565 <li>This is a list</li>
566 <li>second element</li>
567 </ul>
568 </blockquote>
569 <p>quote :D</p>
570 ";
571
572 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text);
573 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(blocks.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
574 let blocks = blocks.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
575 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2);
576
577 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Quoterust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Quote#(blks) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
578 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 5);
579 }
580 }
581
582 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
583 fn test_separatorrust-analyzer cargo html2pango 0.6.0 block/test/test_separator().() {
584 let text = "aaa\n<hr/>foobar<hr/>baz<hr></hr>";
585
586 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text);
587 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(blocks.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
588 let blocks = blocks.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
589 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 6);
590
591 let expected_blocks = [
592 HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("aaa")),
593 HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Separatorrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Separator#,
594 HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("foobar")),
595 HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Separatorrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Separator#,
596 HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("baz")),
597 HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Separatorrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Separator#,
598 ];
599 for (block, expected) in blocks.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(expected_blocks.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()) {
600 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(block, expected);
601 }
602 }
603
604 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
605 fn test_mxreplyrust-analyzer cargo html2pango 0.6.0 block/test/test_mxreply().() {
606 let text = "<mx-reply><blockquote><a href=\"https://matrix.to/#/!hwiGbsdSTZIwSRfybq:matrix.org/$1553513281991555ZdMuB:matrix.org\">In reply to</a> <a href=\"https://matrix.to/#/@afranke:matrix.org\">@afranke:matrix.org</a><br><a href=\"https://matrix.to/#/@gergely:polonkai.eu\">Gergely Polonkai</a>: we have https://gitlab.gnome.org/GNOME/fractal/issues/467 and https://gitlab.gnome.org/GNOME/fractal/issues/347 open, does your issue fit any of these two?</blockquote></mx-reply><p>#467 <em>might</em> be it, let me test a bit<p>";
607
608 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text);
609 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(blocks.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
610 let blocks = blocks.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
611 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2);
612
613 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(t) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
614 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(t, "<a href=\"https://matrix.to/#/!hwiGbsdSTZIwSRfybq:matrix.org/$1553513281991555ZdMuB:matrix.org\">In reply to</a> <a href=\"https://matrix.to/#/@afranke:matrix.org\">@afranke:matrix.org</a><a href=\"https://matrix.to/#/@gergely:polonkai.eu\">Gergely Polonkai</a>: we have <a href=\"https://gitlab.gnome.org/GNOME/fractal/issues/467\">https://gitlab.gnome.org/GNOME/fractal/issues/467</a> and <a href=\"https://gitlab.gnome.org/GNOME/fractal/issues/347\">https://gitlab.gnome.org/GNOME/fractal/issues/347</a> open, does your issue fit any of these two?\n#467 <i>might</i> be it, let me test a bit");
615 }
616 }
617
618 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
619 fn test_html_listsrust-analyzer cargo html2pango 0.6.0 block/test/test_html_lists().() {
620 let text = "
621 <ul>
622 <li>item 1</li>
623 <li>item 2</li>
624 </ul>
625 ";
626
627 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text);
628 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(blocks.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
629 let blocks = blocks.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
630 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
631
632 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::UListrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#UList#(t) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
633 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(t.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2);
634 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(t[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., "item 1");
635 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(t[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., "item 2");
636 }
637 }
638
639 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
640 fn test_html_paragraphsrust-analyzer cargo html2pango 0.6.0 block/test/test_html_paragraphs().() {
641 let text = "
642 <p>text</p>
643 <p><i>text2</i></p>
644 <p><b>text3</b></p>
645 <ul><li>li<li/></ul>
646 <p>text4</p>
647 <p>text5</p>
648 ";
649 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text);
650 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(blocks.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
651 let blocks = blocks.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
652 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().blocks.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
653 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 3);
654
655 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(t) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
656 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(t, "text\n\n<i>text2</i>\n\n<b>text3</b>");
657 }
658 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(t) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().2]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
659 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(t, "text4\n\ntext5");
660 }
661 }
662
663 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
664 fn newline_in_blockquoterust-analyzer cargo html2pango 0.6.0 block/test/newline_in_blockquote().() {
665 let text = "<blockquote>html was a mistake<br />Indeed</blockquote>";
666 let matrix_text = "<blockquote>\n<p>a<br />\nb</p>\n<p>c</p>\nd</blockquote>\n";
667
668 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text);
669 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(blocks.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
670 let blocks = blocks.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
671 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
672
673 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Quoterust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Quote#(blk) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
674 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blk.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
675 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(h) = &blk[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). {
676 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(h, "html was a mistake\nIndeed");
677 }
678 }
679
680 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(matrix_text);
681 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(blocks.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
682 let blocks = blocks.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
683 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
684
685 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Quoterust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Quote#(blk) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
686 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blk.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
687 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(h) = &blk[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). {
688 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(h, "a\nb\n\nc\nd");
689 }
690 }
691 }
692
693 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
694 fn html_blocks_quote_multiplerust-analyzer cargo html2pango 0.6.0 block/test/html_blocks_quote_multiple().() {
695 let text = "<blockquote>\n<p>Some</p>\n</blockquote>\n<p>text</p>\n<blockquote>\n<p>No</p>\n</blockquote>\n<p><strong>u</strong></p>\n";
696
697 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text);
698 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(blocks.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
699 let blocks = blocks.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
700 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 4);
701
702 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Quoterust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Quote#(blk) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
703 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blk.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
704 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(h) = &blk[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). {
705 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(h, "Some");
706 }
707 }
708 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(t) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
709 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(t, "text");
710 }
711 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Quoterust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Quote#(blk) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().2]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
712 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blk.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
713 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(h) = &blk[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). {
714 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(h, "No");
715 }
716 }
717 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(t) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().3]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
718 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(t, "<b>u</b>");
719 }
720 }
721
722 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
723 fn html_url_and_textrust-analyzer cargo html2pango 0.6.0 block/test/html_url_and_text().() {
724 let text = "<a href=\"https://gnome.org\">GNOME</a>text";
725
726 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text);
727 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(blocks.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
728 let blocks = blocks.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
729 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
730 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(h) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
731 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(
732 h,
733 "<a href=\"https://gnome.org\" title=\"https://gnome.org\">GNOME</a>text"
734 );
735 }
736 }
737
738 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
739 fn html_font_spanrust-analyzer cargo html2pango 0.6.0 block/test/html_font_span().() {
740 let text = "GitLab labels: <span data-mx-color=\"#000000\"\n \
741 data-mx-bg-color=\"#ccc063\"\n \
742 >1. Enhancement</span>\n and \
743 <font data-mx-color=\"#ffffff\"\n \
744 data-mx-bg-color=\"#8574cc\"\n \
745 >4. Newcomers</span>";
746
747 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text);
748 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(blocks.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
749 let blocks = blocks.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
750 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
751 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(h) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
752 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(h, "GitLab labels: <span foreground=\"#000000\" background=\"#ccc063\">1. Enhancement</span> and <span foreground=\"#ffffff\" background=\"#8574cc\">4. Newcomers</span>");
753 }
754 }
755
756 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
757 fn html_non_block_tagsrust-analyzer cargo html2pango 0.6.0 block/test/html_non_block_tags().() {
758 let text =
759 "How about some <u>underlined</u> <del>deleted</del> or <s>strikethrough</s> text? \
760 Maybe <em>emphasized</em>, <i>italic</i>, <strong>strong</strong> or <b>bold</b> text? \
761 Possibly a newline<br>with some more <code>code</code>? \
762 Finally some <sub>sub</sub> or <sup>super</sup> par lines!";
763
764 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text);
765 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(blocks.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
766 let blocks = blocks.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
767 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
768 let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(h) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). else {
769 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("No text block found")
770 };
771 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(
772 h,
773 "How about some <u>underlined</u> <s>deleted</s> or <s>strikethrough</s> text? \
774 Maybe <i>emphasized</i>, <i>italic</i>, <b>strong</b> or <b>bold</b> text? \
775 Possibly a newline\nwith some more <tt>code</tt>? \
776 Finally some <sub>sub</sub> or <sup>super</sup> par lines!"
777 );
778 }
779
780 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
781 fn codeblock_empty_whitespacerust-analyzer cargo html2pango 0.6.0 block/test/codeblock_empty_whitespace().() {
782 let text = "
783 <pre><code>
784 Block text `a` <i>i</i>
785
786 space?
787 </code></pre>
788 ";
789
790 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text);
791 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(blocks.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
792 let blocks = blocks.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
793 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
794 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Coderust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Code#(t) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
795 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(t, "Block text `a` <i>i</i>\n\nspace?")
796 }
797 }
798
799 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
800 fn escape_amprust-analyzer cargo html2pango 0.6.0 block/test/escape_amp().() {
801 let text = "text: <code>&amp;</code> was not scaped as <code>&amp;amp;</code>";
802 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text);
803 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(blocks.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
804 let blocks = blocks.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
805 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
806
807 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(t) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
808 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(
809 t,
810 "text: <tt>&amp;</tt> was not scaped as <tt>&amp;amp;</tt>"
811 );
812 }
813 }
814
815 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
816 fn dont_escape_codeblocksrust-analyzer cargo html2pango 0.6.0 block/test/dont_escape_codeblocks().() {
817 let text = "
818 <pre><code>
819 &
820 </code></pre>
821 <code>&<code>
822 ";
823
824 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text);
825 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(blocks.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
826 let blocks = blocks.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
827 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2);
828 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Coderust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Code#(t) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
829 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(t, "&")
830 }
831 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Coderust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Code#(t) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
832 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(t, "&")
833 }
834 }
835
836 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
837 fn newlines_in_textrust-analyzer cargo html2pango 0.6.0 block/test/newlines_in_text().() {
838 let text = "
839 1
840 2
841 <span> 3</span>
842
843 <p> 4
844 5</p>
845 <p>6 </p>
846 ";
847 let text_matrix = "<p>a<br />\nb</p>\n<p>c</p>\nd";
848 let text_matrix_gitlab = "<strong>[<a href=\"https://gitlab.gnome.org/GNOME/fractal\">GNOME/fractal</a>]</strong> <a href=\"https://gitlab.gnome.org/user\">user</a>\n added <span title=\"This label is for the rewrite of Fractal, currently under the working name of fractal-next\"\n >&nbsp;Fractal-next&nbsp;</span>\n to\n\n <a href=\"https://gitlab.gnome.org/GNOME/fractal/-/issues/194\" >issue #194</a>: Replies support";
849
850 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text);
851 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(blocks.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
852 let blocks = blocks.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
853 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
854 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(t) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
855 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(t, "1 2 3\n4 5\n\n6")
856 }
857
858 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text_matrix);
859 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(blocks.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
860 let blocks = blocks.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
861 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
862 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(t) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
863 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(t, "a\nb\n\nc\nd")
864 }
865
866 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text_matrix_gitlab);
867 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(blocks.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
868 let blocks = blocks.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
869 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
870 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(t) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
871 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(t, "<b>[<a href=\"https://gitlab.gnome.org/GNOME/fractal\" title=\"https://gitlab.gnome.org/GNOME/fractal\">GNOME/fractal</a>]</b> <a href=\"https://gitlab.gnome.org/user\" title=\"https://gitlab.gnome.org/user\">user</a> added \u{a0}Fractal-next\u{a0} to <a href=\"https://gitlab.gnome.org/GNOME/fractal/-/issues/194\" title=\"https://gitlab.gnome.org/GNOME/fractal/-/issues/194\">issue #194</a>: Replies support");
872 }
873
874 let text_h1 = "<h1>foo \n bar</h1>";
875 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text_h1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
876 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Headingrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Heading#(1, t) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
877 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(t, "foo bar");
878 }
879
880 let text_ul = "<ul><li>first \n element</li><li>second<br/> element</li></ul>";
881 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text_ul).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
882 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::UListrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#UList#(ts) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
883 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(ts[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., "first element");
884 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(ts[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., "second\nelement");
885 }
886
887 let text_ol = "<ol><li>first \n element</li><li>second<br/> element</li></ol>";
888 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text_ol).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
889 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::OListrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#OList#(ts) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
890 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(ts[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., "first element");
891 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(ts[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., "second\nelement");
892 }
893
894 let text_bq = "<blockquote><p>Foo:\n <p><ul><li>First \n item</li></ul></blockquote>";
895 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text_bq).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
896 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Quoterust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Quote#(contents) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
897 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(contents[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("Foo:")));
898 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(
899 contents[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().,
900 HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::UListrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#UList#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("First item")])
901 );
902 }
903 }
904
905 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
906 fn links_inside_coderust-analyzer cargo html2pango 0.6.0 block/test/links_inside_code().() {
907 let text = "
908 <pre><code>https://gitlab.gnome.org/World/Fractal/</code></pre>\n
909 ";
910 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text);
911 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(blocks.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
912 let blocks = blocks.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
913 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
914
915 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Coderust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Code#(t) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
916 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(t, "https://gitlab.gnome.org/World/Fractal/");
917 }
918 }
919
920 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
921 fn ci_linksrust-analyzer cargo html2pango 0.6.0 block/test/ci_links().() {
922 let text = "
923 [<a href='https://gitlab.gnome.org/World/Fractal'>World/Fractal</a>]
924 ";
925 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text);
926 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(blocks.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
927 let blocks = blocks.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
928 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
929
930 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(s) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
931 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(s, "[<a href=\"https://gitlab.gnome.org/World/Fractal\" title=\"https://gitlab.gnome.org/World/Fractal\">World/Fractal</a>]");
932 }
933 }
934
935 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
936 fn newline_after_quotesrust-analyzer cargo html2pango 0.6.0 block/test/newline_after_quotes().() {
937 let text = "<mx-reply><blockquote><a href=\"https://matrix.org\">In reply to</a> <a href=\"https://matrix.org\">@okias:matrix.org</a><br>Text</blockquote></mx-reply>F";
938 let target = "<a href=\"https://matrix.org\" title=\"https://matrix.org\">In reply to</a> <a href=\"https://matrix.org\" title=\"https://matrix.org\">@okias:matrix.org</a>\nText";
939 let blocks = markup_htmlrust-analyzer cargo html2pango 0.6.0 block/markup_html().(text);
940 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(blocks.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
941 let blocks = blocks.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
942 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blocks.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2);
943
944 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Quoterust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Quote#(blk) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
945 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(blk.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
946 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(h) = &blk[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). {
947 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(h, target);
948 }
949 }
950
951 if let HtmlBlockrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#::Textrust-analyzer cargo html2pango 0.6.0 block/HtmlBlock#Text#(t) = &blocks[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
952 assert_eqrust-analyzer cargo pretty_assertions 1.4.1 assert_eq!!(t, "F");
953 }
954 }
955 }