mirror of https://github.com/adamdruppe/arsd.git
comment helper function
This commit is contained in:
parent
4964425cc3
commit
93be0d1d4f
18
dom.d
18
dom.d
|
@ -434,6 +434,24 @@ mixin template DomConvenienceFunctions() {
|
|||
}
|
||||
}
|
||||
|
||||
/// finds comments that match the given txt. Case insensitive, strips whitespace.
|
||||
Element[] findComments(Document document, string txt) {
|
||||
return findComments(document.root, txt);
|
||||
}
|
||||
|
||||
/// ditto
|
||||
Element[] findComments(Element element, string txt) {
|
||||
txt = txt.strip().toLower();
|
||||
Element[] ret;
|
||||
|
||||
foreach(comment; element.getElementsByTagName("#comment")) {
|
||||
string t = comment.nodeValue().strip().toLower();
|
||||
if(t == txt)
|
||||
ret ~= comment;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// I'm just dicking around with this
|
||||
struct ElementCollection {
|
||||
|
|
Loading…
Reference in New Issue