Move rustdoc-related code to rustdoc crate (#12945)

This PR moves the rustdoc-related code out of `html_to_markdown` and
into the `rustdoc` crate.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-06-12 15:53:05 -04:00 committed by GitHub
parent c3df9b79c6
commit 6fa347dff7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 741 additions and 720 deletions

View file

@ -46,7 +46,7 @@ impl MarkdownWriter {
pub fn is_inside(&self, tag: &str) -> bool {
self.current_element_stack
.iter()
.any(|parent_element| parent_element.tag == tag)
.any(|parent_element| parent_element.tag() == tag)
}
/// Appends the given string slice onto the end of the Markdown output.
@ -94,10 +94,7 @@ impl MarkdownWriter {
} => {
let tag_name = name.local.to_string();
if !tag_name.is_empty() {
current_element = Some(HtmlElement {
tag: tag_name,
attrs: attrs.clone(),
});
current_element = Some(HtmlElement::new(tag_name, attrs.clone()));
}
}
NodeData::Text { ref contents } => {
@ -130,7 +127,7 @@ impl MarkdownWriter {
fn start_tag(&mut self, tag: &HtmlElement, handlers: &mut [TagHandler]) -> StartTagOutcome {
for handler in handlers {
if handler.borrow().should_handle(tag.tag.as_str()) {
if handler.borrow().should_handle(tag.tag()) {
match handler.borrow_mut().handle_tag_start(tag, self) {
StartTagOutcome::Continue => {}
StartTagOutcome::Skip => return StartTagOutcome::Skip,
@ -143,7 +140,7 @@ impl MarkdownWriter {
fn end_tag(&mut self, tag: &HtmlElement, handlers: &mut [TagHandler]) {
for handler in handlers {
if handler.borrow().should_handle(tag.tag.as_str()) {
if handler.borrow().should_handle(tag.tag()) {
handler.borrow_mut().handle_tag_end(tag, self);
}
}