-
-
Save sne11ius/24fc40ed24f5ad55193c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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