Skip to content

Commit

Permalink
fix(html): don't remove p's in li's (#19)
Browse files Browse the repository at this point in the history
depends on mdn/yari#11930
  • Loading branch information
fiji-flo authored Oct 9, 2024
1 parent 5071426 commit 6cf911a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 34 deletions.
4 changes: 0 additions & 4 deletions crates/rari-doc/src/html/rewriter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,6 @@ pub fn post_process_html<T: PageLike>(
el.set_attribute("loading", "lazy")?;
Ok(())
}),
element!("li > p", |el| {
el.remove_and_keep_content();
Ok(())
}),
element!("a[href]", |el| {
let original_href = el.get_attribute("href").expect("href was required");
if original_href.starts_with('/')
Expand Down
21 changes: 0 additions & 21 deletions crates/rari-md/src/li.rs

This file was deleted.

13 changes: 4 additions & 9 deletions crates/rari-md/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@ pub(crate) mod dl;
pub mod error;
pub(crate) mod ext;
pub(crate) mod html;
pub(crate) mod li;
pub mod node_card;
pub(crate) mod p;

use dl::{convert_dl, is_dl};
use html::format_document;

use self::li::remove_p;

fn iter_nodes<'a, F>(node: &'a AstNode<'a>, f: &F)
where
F: Fn(&'a AstNode<'a>),
Expand All @@ -45,15 +42,13 @@ pub fn m2h(input: &str, locale: Locale) -> Result<String, MarkdownError> {
let root = parse_document(&arena, input, &options);

iter_nodes(root, &|node| {
let (dl, li, templs_p, empty_p) = match node.data.borrow().value {
NodeValue::List(_) => (is_dl(node), true, false, false),
NodeValue::Paragraph => (false, false, is_escaped_templ_p(node), is_empty_p(node)),
_ => (false, false, false, false),
let (dl, templs_p, empty_p) = match node.data.borrow().value {
NodeValue::List(_) => (is_dl(node), false, false),
NodeValue::Paragraph => (false, is_escaped_templ_p(node), is_empty_p(node)),
_ => (false, false, false),
};
if dl {
convert_dl(node);
} else if li {
remove_p(node);
}
if templs_p || empty_p {
fix_p(node)
Expand Down

0 comments on commit 6cf911a

Please sign in to comment.