Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public Selectable smartContent() {
return select(smartContentSelector, getSourceTexts());
}

public Selectable smartContent(int threshold) {
SmartContentSelector smartContentSelector = Selectors.smartContent(threshold);
return select(smartContentSelector, getSourceTexts());
}

@Override
public Selectable links() {
return selectElements(new LinksSelector());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public static SmartContentSelector smartContent() {
return new SmartContentSelector();
}

public static SmartContentSelector smartContent(int threshold) {
return new SmartContentSelector(threshold);
}

public static CssSelector $(String expr) {
return new CssSelector(expr);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@
@Experimental
public class SmartContentSelector implements Selector {

private int threshold = 86;

public SmartContentSelector() {
}

public SmartContentSelector(int threshold) {
this.threshold = threshold;
}

@Override
public String select(String html) {
html = html.replaceAll("(?is)<!DOCTYPE.*?>", "");
Expand All @@ -29,7 +35,6 @@ public String select(String html) {
html = html.replaceAll("(?is)<.*?>", "");
List<String> lines;
int blocksWidth =3;
int threshold =86;
int start;
int end;
StringBuilder text = new StringBuilder();
Expand Down