forked from alemi/upub
fix(mdhtml): dont add stuff on closing tags
This commit is contained in:
parent
b097e4a725
commit
b4bd7c845f
1 changed files with 23 additions and 22 deletions
|
@ -29,31 +29,32 @@ impl TokenSink for Sink {
|
||||||
|
|
||||||
self.0.push_str(tag.name.as_ref());
|
self.0.push_str(tag.name.as_ref());
|
||||||
|
|
||||||
match tag.name.as_ref() {
|
|
||||||
"img" => for attr in tag.attrs {
|
|
||||||
match attr.name.local.as_ref() {
|
|
||||||
"src" => self.0.push_str(&format!(" src=\"{}\"", attr.value.as_ref())),
|
|
||||||
"title" => self.0.push_str(&format!(" title=\"{}\"", attr.value.as_ref())),
|
|
||||||
"alt" => self.0.push_str(&format!(" alt=\"{}\"", attr.value.as_ref())),
|
|
||||||
_ => {},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"a" => {
|
|
||||||
for attr in tag.attrs {
|
|
||||||
match attr.name.local.as_ref() {
|
|
||||||
"href" => self.0.push_str(&format!(" href=\"{}\"", attr.value.as_ref())),
|
|
||||||
"title" => self.0.push_str(&format!(" title=\"{}\"", attr.value.as_ref())),
|
|
||||||
_ => {},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.0.push_str(" rel=\"nofollow noreferrer\" target=\"_blank\"");
|
|
||||||
},
|
|
||||||
_ => {},
|
|
||||||
}
|
|
||||||
|
|
||||||
if tag.self_closing {
|
if tag.self_closing {
|
||||||
self.0.push('/');
|
self.0.push('/');
|
||||||
|
} else {
|
||||||
|
match tag.name.as_ref() {
|
||||||
|
"img" => for attr in tag.attrs {
|
||||||
|
match attr.name.local.as_ref() {
|
||||||
|
"src" => self.0.push_str(&format!(" src=\"{}\"", attr.value.as_ref())),
|
||||||
|
"title" => self.0.push_str(&format!(" title=\"{}\"", attr.value.as_ref())),
|
||||||
|
"alt" => self.0.push_str(&format!(" alt=\"{}\"", attr.value.as_ref())),
|
||||||
|
_ => {},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"a" => {
|
||||||
|
for attr in tag.attrs {
|
||||||
|
match attr.name.local.as_ref() {
|
||||||
|
"href" => self.0.push_str(&format!(" href=\"{}\"", attr.value.as_ref())),
|
||||||
|
"title" => self.0.push_str(&format!(" title=\"{}\"", attr.value.as_ref())),
|
||||||
|
_ => {},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.0.push_str(" rel=\"nofollow noreferrer\" target=\"_blank\"");
|
||||||
|
},
|
||||||
|
_ => {},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.0.push('>');
|
self.0.push('>');
|
||||||
},
|
},
|
||||||
Token::CharacterTokens(txt) => self.0.push_str(txt.as_ref()),
|
Token::CharacterTokens(txt) => self.0.push_str(txt.as_ref()),
|
||||||
|
|
Loading…
Reference in a new issue