forked from alemi/upub
fix(mdhtml): oops now really no attrs on closing tags
This commit is contained in:
parent
e1d1e3d470
commit
eba5a31a93
1 changed files with 10 additions and 4 deletions
|
@ -23,15 +23,14 @@ impl TokenSink for Sink {
|
||||||
) { return TokenSinkResult::Continue } // skip this tag
|
) { return TokenSinkResult::Continue } // skip this tag
|
||||||
|
|
||||||
self.0.push('<');
|
self.0.push('<');
|
||||||
|
|
||||||
if !tag.self_closing && matches!(tag.kind, TagKind::EndTag) {
|
if !tag.self_closing && matches!(tag.kind, TagKind::EndTag) {
|
||||||
self.0.push('/');
|
self.0.push('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
self.0.push_str(tag.name.as_ref());
|
self.0.push_str(tag.name.as_ref());
|
||||||
|
|
||||||
if tag.self_closing {
|
if !matches!(tag.kind, TagKind::EndTag) {
|
||||||
self.0.push('/');
|
|
||||||
} else {
|
|
||||||
match tag.name.as_ref() {
|
match tag.name.as_ref() {
|
||||||
"img" => for attr in tag.attrs {
|
"img" => for attr in tag.attrs {
|
||||||
match attr.name.local.as_ref() {
|
match attr.name.local.as_ref() {
|
||||||
|
@ -42,6 +41,7 @@ impl TokenSink for Sink {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"a" => {
|
"a" => {
|
||||||
|
let any_attr = !tag.attrs.is_empty();
|
||||||
for attr in tag.attrs {
|
for attr in tag.attrs {
|
||||||
match attr.name.local.as_ref() {
|
match attr.name.local.as_ref() {
|
||||||
"href" => self.0.push_str(&format!(" href=\"{}\"", attr.value.as_ref())),
|
"href" => self.0.push_str(&format!(" href=\"{}\"", attr.value.as_ref())),
|
||||||
|
@ -49,12 +49,18 @@ impl TokenSink for Sink {
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if any_attr {
|
||||||
self.0.push_str(" rel=\"nofollow noreferrer\" target=\"_blank\"");
|
self.0.push_str(" rel=\"nofollow noreferrer\" target=\"_blank\"");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if tag.self_closing {
|
||||||
|
self.0.push('/');
|
||||||
|
}
|
||||||
|
|
||||||
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