
com.greenpepper.runner.dialect.AbstractOpenDocumentDialect Maven / Gradle / Ivy
The newest version!
package com.greenpepper.runner.dialect;
import com.greenpepper.dialect.SpecificationDialect;
import com.greenpepper.shaded.org.jsoup.Jsoup;
import com.greenpepper.shaded.org.jsoup.nodes.Document;
import com.greenpepper.shaded.org.slf4j.Logger;
import com.greenpepper.shaded.org.slf4j.LoggerFactory;
abstract class AbstractOpenDocumentDialect implements SpecificationDialect {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractOpenDocumentDialect.class);
String cleanUpTheHtml(String source) {
Document jsoup = Jsoup.parse(source);
removeParagraphesInLi(jsoup);
unwrapTheTitlesFromLi(jsoup);
String newResult = jsoup.toString();
LOGGER.debug("result of conversion: \n{}", newResult);
return newResult;
}
private void removeParagraphesInLi(final Document jsoup) {
// the conversion puts breakings inside the
s
jsoup.body().select("li>p").unwrap();
}
private void unwrapTheTitlesFromLi(final Document jsoup){
jsoup.select("ul>li>h1, ul>li>h2, ul>li>h3, ul>li>h4, ul>li>h5, ul>li>h6")
.parents().unwrap();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy