use of org.htmlcleaner.TagNode in project iaf by ibissource.
the class XmlUtils method toXhtml.
public static String toXhtml(String htmlString) {
if (StringUtils.isNotEmpty(htmlString)) {
String xhtmlString = skipDocTypeDeclaration(htmlString.trim());
if (xhtmlString.startsWith("<html>") || xhtmlString.startsWith("<html ")) {
CleanerProperties props = new CleanerProperties();
HtmlCleaner cleaner = new HtmlCleaner(props);
TagNode tagNode = cleaner.clean(xhtmlString);
return new SimpleXmlSerializer(props).getAsString(tagNode);
}
}
return null;
}
use of org.htmlcleaner.TagNode in project FastHub by k0shk0sh.
the class DrawableHandler method handleTagNode.
@Override
public void handleTagNode(TagNode node, SpannableStringBuilder builder, int start, int end) {
String src = node.getAttributeByName("src");
if (!InputHelper.isEmpty(src)) {
if (!PrefGetter.isAutoImageDisabled()) {
builder.append("");
if (isNull())
return;
builder.append("\n");
DrawableGetter imageGetter = new DrawableGetter(textView, width);
builder.setSpan(new ImageSpan(imageGetter.getDrawable(src)), start, builder.length(), SPAN_EXCLUSIVE_EXCLUSIVE);
builder.setSpan(new CenterSpan(), start, builder.length(), SPAN_EXCLUSIVE_EXCLUSIVE);
builder.append("\n");
} else {
builder.append(SpannableBuilder.builder().clickable("Image", v -> SchemeParser.launchUri(v.getContext(), src)));
builder.append("\n");
}
}
}
use of org.htmlcleaner.TagNode in project FastHub by k0shk0sh.
the class ListsHandler method beforeChildren.
@Override
public void beforeChildren(TagNode node, SpannableStringBuilder builder) {
TodoItems todoItem = null;
if (node.getChildTags() != null && node.getChildTags().length > 0) {
for (TagNode tagNode : node.getChildTags()) {
Logger.e(tagNode.getName(), tagNode.getText());
if (tagNode.getName() != null && tagNode.getName().equals("input")) {
todoItem = new TodoItems();
todoItem.isChecked = tagNode.getAttributeByName("checked") != null;
break;
}
}
}
if ("ol".equals(getParentName(node))) {
builder.append(String.valueOf(getMyIndex(node))).append(". ");
} else if ("ul".equals(getParentName(node))) {
if (todoItem != null) {
if (checked == null || unchecked == null) {
builder.append(todoItem.isChecked ? "☑" : "☐");
} else {
builder.append(SpannableBuilder.builder().append(todoItem.isChecked ? checked : unchecked)).append(" ");
}
} else {
builder.append("\u2022 ");
}
}
}
use of org.htmlcleaner.TagNode in project FastHub by k0shk0sh.
the class PreTagHandler method getPlainText.
private void getPlainText(StringBuffer buffer, Object node) {
if (node instanceof ContentNode) {
ContentNode contentNode = (ContentNode) node;
String text = contentNode.getContent().toString();
buffer.append(text);
} else if (node instanceof TagNode) {
TagNode tagNode = (TagNode) node;
for (Object child : tagNode.getChildren()) {
this.getPlainText(buffer, child);
}
}
}
use of org.htmlcleaner.TagNode in project FastHub by k0shk0sh.
the class TableHandler method readNode.
private void readNode(Object node, Table table) {
if (node instanceof TagNode) {
TagNode tagNode = (TagNode) node;
if (tagNode.getName().equals("td") || tagNode.getName().equals("th")) {
Spanned result = this.getSpanner().fromTagNode(tagNode);
table.addCell(result);
return;
}
if (tagNode.getName().equals("tr")) {
table.addRow();
}
for (Object child : tagNode.getChildTags()) {
readNode(child, table);
}
}
}
Aggregations