Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

…lines 1–335 unchanged (335 lines)
336 }
337
338 private boolean testValidProtocol(Element el, Attribute attr, Set<Protocol> protocols) {
339 // try to resolve relative urls to abs, and optionally update the attribute so output html has abs.
340 // rels without a baseuri get removed
341 String value = el.absUrl(attr.getKey());
342 if (!preserveRelativeLinks)
343 attr.setValue(value);
344
345 for (Protocol protocol : protocols) {
346 String prot = protocol.toString() + ":";
347 if (value.toLowerCase().startsWith(prot)) {
348 return true;
…lines 349–443 unchanged (95 lines)

After

…lines 1–335 unchanged (335 lines)
336 }
337
338 private boolean testValidProtocol(Element el, Attribute attr, Set<Protocol> protocols) {
339 // try to resolve relative urls to abs, and optionally update the attribute so output html has abs.
340 // rels without a baseuri get removed
341 String value = el.absUrl(attr.getKey());
342 if (value.length() == 0)
343 value = attr.getValue(); // if it could not be made abs, run as-is to allow custom unknown protocols
344 if (!preserveRelativeLinks)
345 attr.setValue(value);
346
347 for (Protocol protocol : protocols) {
348 String prot = protocol.toString() + ":";
349 if (value.toLowerCase().startsWith(prot)) {
…lines 350–445 unchanged (96 lines)

Before

program
package_declaration
package "package"
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "safety"
; ";"
block_comment "/*\n Thank you to Ryan Grove (wonko.com) for the Ruby HTML"...
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "helper"
. "."
identifier "Validate"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "nodes"
. "."
identifier "Attribute"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "nodes"
. "."
identifier "Attributes"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "nodes"
. "."
identifier "Element"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "HashMap"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "HashSet"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Map"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Set"
; ";"
block_comment "/**\n Whitelists define what HTML (elements and attributes) t"...
class_declaration
modifiers
public "public"
class "class"
identifier "Whitelist"
class_body
{ "{"
field_declaration
modifiers
private "private"
generic_type
type_identifier "Set"
type_arguments
< "<"
type_identifier "TagName"
> ">"
variable_declarator
identifier "tagNames"
; ";"
line_comment "// tags allowed, lower case. e.g. [p, br, span]"
field_declaration
modifiers
private "private"
generic_type
type_identifier "Map"
type_arguments
< "<"
type_identifier "TagName"
, ","
generic_type
type_identifier "Set"
type_arguments
< "<"
type_identifier "AttributeKey"
> ">"
> ">"
variable_declarator
identifier "attributes"
; ";"
line_comment "// tag -> attribute[]. allowed attributes [href] for a tag."
field_declaration (+21 nodes collapsed)
line_comment "// always set these attribute values"
field_declaration (+26 nodes collapsed)
line_comment "// allowed URL protocols for attributes"
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "preserveRelativeLinks"
; ";"
line_comment "// option to preserve relative links"
block_comment "/**\n This whitelist allows only text nodes: all HTML wil"...
method_declaration (+21 nodes collapsed)
block_comment "/**\n This whitelist allows only simple text formatting: "...
method_declaration (+51 nodes collapsed)
block_comment "/**\n This whitelist allows a fuller range of text nodes:"...
method_declaration (+291 nodes collapsed)
block_comment "/**\n This whitelist allows the same text tags as {@link "...
method_declaration (+95 nodes collapsed)
block_comment "/**\n This whitelist allows a full range of text and stru"...
method_declaration (+601 nodes collapsed)
block_comment "/**\n Create a new, empty whitelist. Generally it will be"...
constructor_declaration (+110 nodes collapsed)
block_comment "/**\n Add a list of allowed elements to a whitelist. (If "...
method_declaration (+68 nodes collapsed)
block_comment "/**\n Add a list of allowed attributes to a tag. (If an a"...
method_declaration (+179 nodes collapsed)
block_comment "/**\n Add an enforced attribute to a tag. An enforced att"...
method_declaration (+187 nodes collapsed)
block_comment "/**\n * Configure this Whitelist to preserve relative lin"...
method_declaration (+24 nodes collapsed)
block_comment "/**\n Add allowed URL protocols for an element's URL attr"...
method_declaration (+296 nodes collapsed)
method_declaration (+30 nodes collapsed)
method_declaration (+217 nodes collapsed)
method_declaration
modifiers
private "private"
boolean_type "boolean"
identifier "testValidProtocol"
formal_parameters
( "("
formal_parameter
type_identifier "Element"
identifier "el"
, ","
formal_parameter
type_identifier "Attribute"
identifier "attr"
, ","
formal_parameter
generic_type
type_identifier "Set"
type_arguments
< "<"
type_identifier "Protocol"
> ">"
identifier "protocols"
) ")"
block
{ "{"
line_comment "// try to resolve relative urls to abs, and optionally updat"...
line_comment "// rels without a baseuri get removed"
local_variable_declaration
type_identifier "String"
variable_declarator
identifier "value"
= "="
method_invocation
identifier "el"
. "."
identifier "absUrl"
argument_list
( "("
method_invocation
identifier "attr"
. "."
identifier "getKey"
argument_list
( "("
) ")"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
unary_expression
! "!"
identifier "preserveRelativeLinks"
) ")"
expression_statement
method_invocation
identifier "attr"
. "."
identifier "setValue"
argument_list
( "("
identifier "value"
) ")"
; ";"
enhanced_for_statement (+56 nodes collapsed)
return_statement
return "return"
false "false"
; ";"
} "}"
method_declaration (+142 nodes collapsed)
line_comment "// named types for config. All just hold strings, but here f"...
class_declaration (+53 nodes collapsed)
class_declaration (+53 nodes collapsed)
class_declaration (+53 nodes collapsed)
class_declaration (+53 nodes collapsed)
class_declaration (+265 nodes collapsed)
} "}"

After

program
package_declaration
package "package"
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "safety"
; ";"
block_comment "/*\n Thank you to Ryan Grove (wonko.com) for the Ruby HTML"...
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "helper"
. "."
identifier "Validate"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "nodes"
. "."
identifier "Attribute"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "nodes"
. "."
identifier "Attributes"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "nodes"
. "."
identifier "Element"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "HashMap"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "HashSet"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Map"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Set"
; ";"
block_comment "/**\n Whitelists define what HTML (elements and attributes) t"...
class_declaration
modifiers
public "public"
class "class"
identifier "Whitelist"
class_body
{ "{"
field_declaration
modifiers
private "private"
generic_type
type_identifier "Set"
type_arguments
< "<"
type_identifier "TagName"
> ">"
variable_declarator
identifier "tagNames"
; ";"
line_comment "// tags allowed, lower case. e.g. [p, br, span]"
field_declaration
modifiers
private "private"
generic_type
type_identifier "Map"
type_arguments
< "<"
type_identifier "TagName"
, ","
generic_type
type_identifier "Set"
type_arguments
< "<"
type_identifier "AttributeKey"
> ">"
> ">"
variable_declarator
identifier "attributes"
; ";"
line_comment "// tag -> attribute[]. allowed attributes [href] for a tag."
field_declaration (+21 nodes collapsed)
line_comment "// always set these attribute values"
field_declaration (+26 nodes collapsed)
line_comment "// allowed URL protocols for attributes"
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "preserveRelativeLinks"
; ";"
line_comment "// option to preserve relative links"
block_comment "/**\n This whitelist allows only text nodes: all HTML wil"...
method_declaration (+21 nodes collapsed)
block_comment "/**\n This whitelist allows only simple text formatting: "...
method_declaration (+51 nodes collapsed)
block_comment "/**\n This whitelist allows a fuller range of text nodes:"...
method_declaration (+291 nodes collapsed)
block_comment "/**\n This whitelist allows the same text tags as {@link "...
method_declaration (+95 nodes collapsed)
block_comment "/**\n This whitelist allows a full range of text and stru"...
method_declaration (+601 nodes collapsed)
block_comment "/**\n Create a new, empty whitelist. Generally it will be"...
constructor_declaration (+110 nodes collapsed)
block_comment "/**\n Add a list of allowed elements to a whitelist. (If "...
method_declaration (+68 nodes collapsed)
block_comment "/**\n Add a list of allowed attributes to a tag. (If an a"...
method_declaration (+179 nodes collapsed)
block_comment "/**\n Add an enforced attribute to a tag. An enforced att"...
method_declaration (+187 nodes collapsed)
block_comment "/**\n * Configure this Whitelist to preserve relative lin"...
method_declaration (+24 nodes collapsed)
block_comment "/**\n Add allowed URL protocols for an element's URL attr"...
method_declaration (+296 nodes collapsed)
method_declaration (+30 nodes collapsed)
method_declaration (+217 nodes collapsed)
method_declaration
modifiers
private "private"
boolean_type "boolean"
identifier "testValidProtocol"
formal_parameters
( "("
formal_parameter
type_identifier "Element"
identifier "el"
, ","
formal_parameter
type_identifier "Attribute"
identifier "attr"
, ","
formal_parameter
generic_type
type_identifier "Set"
type_arguments
< "<"
type_identifier "Protocol"
> ">"
identifier "protocols"
) ")"
block
{ "{"
line_comment "// try to resolve relative urls to abs, and optionally updat"...
line_comment "// rels without a baseuri get removed"
local_variable_declaration
type_identifier "String"
variable_declarator
identifier "value"
= "="
method_invocation
identifier "el"
. "."
identifier "absUrl"
argument_list
( "("
method_invocation
identifier "attr"
. "."
identifier "getKey"
argument_list
( "("
) ")"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
method_invocation
identifier "value"
. "."
identifier "length"
argument_list
( "("
) ")"
== "=="
decimal_integer_literal "0"
) ")"
expression_statement
assignment_expression
identifier "value"
= "="
method_invocation
identifier "attr"
. "."
identifier "getValue"
argument_list
( "("
) ")"
; ";"
line_comment "// if it could not be made abs, run as-is to allow custom un"...
if_statement
if "if"
parenthesized_expression
( "("
unary_expression
! "!"
identifier "preserveRelativeLinks"
) ")"
expression_statement
method_invocation
identifier "attr"
. "."
identifier "setValue"
argument_list
( "("
identifier "value"
) ")"
; ";"
enhanced_for_statement (+56 nodes collapsed)
return_statement
return "return"
false "false"
; ";"
} "}"
method_declaration (+142 nodes collapsed)
line_comment "// named types for config. All just hold strings, but here f"...
class_declaration (+53 nodes collapsed)
class_declaration (+53 nodes collapsed)
class_declaration (+53 nodes collapsed)
class_declaration (+53 nodes collapsed)
class_declaration (+265 nodes collapsed)
} "}"