0 branches
Tree
Top files
Clone with HTTPS:
README.md
net: fix net.html parser ignoring inner tags in tag.content (fixes #14138)
last Apr 21
826 bytes
data_structures.v
fmt: remove the prefixed module name of const names, that are in the same module (related #22183) (#22185)
1 year ago
1.71 KB
dom.v
net: fix net.html parser ignoring inner tags in tag.content (fixes #14138)
last Apr 21
6.95 KB
html_test.v
net: fix net.html parser ignoring inner tags in tag.content (fixes #14138)
last Apr 21
1.37 KB
parser_test.v
net.html: fix parsing of nested quoted strings in code tags (#18123)
3 years ago
1.86 KB
tag.v
net: fix net.html parser ignoring inner tags in tag.content (fixes #14138)
last Apr 21
4.85 KB
net/html is an HTML Parser written in pure V.
Usage
import net.html
fn main() {
doc := html.parse('</body></html>')
tag := doc.get_tags(name: 'h1')[0] // <h1>Hello world!</h1>
println(tag.name) // h1
println(tag.content) // Hello world!
println(tag.attributes) // {'class':'title'}
println(tag.str()) // <h1 >Hello world!</h1>
}
For tags with nested markup, tag.content preserves the inner HTML:
import net.html
fn main() {
doc := html.parse('<p>before <span>in between</span> after</p>')
tag := doc.get_tags(name: 'p')[0]
println(tag.content) // before <span>in between</span> after
println(tag.text()) // before in between after
}
More examples found on parser_test.v and html_test.v