Alright, let's get some serious code right done right now.
I'm going to try to make this dynamic!
$letter = ''
$("//p[not(contains(@class,'starts-with'))][1]") {
# get the first p that doesn't have the class
$add_header = "false"
text() {
capture(/\A(\w)/) {
# get the first letter and set it to a variable
match($letter) {
with($1) {
#do nothing
}
else() {
$letter = $1
$add_header = "true"
}
}
}
}
match($add_header) {
with(/true/) {
insert_before("h1", "Starts With: "+$letter)
$("self::*|following-sibling::p[contains(text(), '"+$letter+"')]") {
add_class("starts-with-" + $letter)
}
}
}
}