Skip to content

Instantly share code, notes, and snippets.

@sne11ius
Forked from keki/gist:9261886
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sne11ius/24fc40ed24f5ad55193c to your computer and use it in GitHub Desktop.
Save sne11ius/24fc40ed24f5ad55193c to your computer and use it in GitHub Desktop.
//Scala xml -- this is supposed to return a collection of the elements to be modified
(e \ "_").find { child =>
(child \\ "_")
.filter { c =>
!isMedia(c.label)
}
.exists { c =>
c.child.exists { c =>
(singleParagraphs && isMedia(c.label)) || (c.label == "#PCDATA" && isEmpty(c.text))
}
}
}
//Jsoup -- this modifies the elements when it finds them
element.children foreach { child =>
if (!found && !mediaElements.contains(child.tagName)) {
child.getAllElements foreach { subelement =>
if (!found && ((singleParagraph && mediaElements.contains(subelement.tagName)) || (isEmpty(subelement.text)))) {
child.addClass("first-text")
found = true
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment