-
-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
fix links like <a href="#f-sound.source">SoundSource</a>
| // TODO: fix links like `<a href="#f-sound.source">SoundSource</a>` |
Source of this issue
fn walk(handle: &Handle, results: &mut DocsMap) {
let node = handle;
let mut found = None;
if let NodeData::Element { ref name, ref attrs, .. } = node.data {
found = if name.local == *"div" {
let attrs = attrs.borrow();
let attr = attrs.iter()
.find(|attr| attr.name.local == *"id" && attr.value.starts_with("f-"));
attr.map(|attr| {
attr.value
.strip_prefix("f-")
.expect("prefix 'f-' must be there")
.to_string()
})
} else {
None
};
if let Some(_key) = found.as_ref() {
// Changing: this-div . div_class="title" is a cpp-code fn-path+definition
// to `<code data-lang="c">`
// TODO: fix links like `<a href="#f-sound.source">SoundSource</a>`
let mut children = node.children.borrow_mut();
let title = children.iter_mut().find(|child| {
match &child.data {
NodeData::Element { name, attrs, .. } => {
name.local.eq("div") &&
attrs.borrow().iter().any(|attr| {
attr.name.local.eq("class") &&
attr.value.contains("title")
})
},
_ => false,
}
});
if let Some(title) = title {
let mut data = {
match &title.data {
NodeData::Element { name,
attrs,
template_contents,
mathml_annotation_xml_integration_point, } => {
let mut code = name.clone();
code.borrow_mut().local = html5ever::LocalName::from("code");
NodeData::Element { name: code,
attrs: attrs.clone(),
template_contents: template_contents.clone(),
mathml_annotation_xml_integration_point:
*mathml_annotation_xml_integration_point }.into()
},
_ => None,
}
};
if let Some(data) = data.take() {
unsafe {
std::rc::Rc::get_mut_unchecked(title).data = data;
}
}
}
}
}
for child in
node.children
.borrow()
.iter()
.filter(|child| matches!(child.data, NodeData::Text { .. } | NodeData::Element { .. }))
{
walk(child, results);
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Projects
Status
No status