This resource implements the diff tool in the REST API, which can be used to calculate the diff between html contents.
Annotates a newer HTML document with differences to an older HTML document.
The annotations will be done by the DaisyDiff Algorithm. Please see the DaisyDiff project site for more information and examples.
The resulting HTML will need some CSS and (optionally) some Javascript includes from version 1.1 of the DaisyDiff distribution.
The CSS file in "css/diff.css" of the DaisyDiff distribution archive provides basic styles for inserted/deleted/changed elements and is sufficient by itself to provide basic visualization of changes.
The following JavaScript files need to be included to get an extended interface that allows navigation between changes and provides more information about a change when it is clicked:
The included JavaScript must be explicitly initialized: <script type='text/javascript'>htmlDiffInit();</script>
The DaisyDiff algorithm differs from the standard diff algorithm in that it tries to preserve the HTML tree structure, while the standard HTML diff alogrithm may break it.
If the given HTML documents contain <body> tags, only content inside the tags will be diffed. Differences outside the body tags will be ignored. The resulting HTML document will contain the same header (substring from start of document until and including the body tag) as the newer document.
Please note that the HTML diff will not reflect the changes exactly. The HTML will be cleaned up and some content may be lost in this process. The result is meant for human consumption, not to generate exact differences between HTML documents.
media type | data type | description |
---|---|---|
application/json | DaisyDiffRequest (JSON) | contains the parameters for the DaisyDiff algorithm |
media type | data type | description |
---|---|---|
application/json | DiffResponse (JSON) | a response containing the diff for the two HTML documents |
application/xml;charset=UTF-8 | object |
POST /diff/daisyDiff
Content-Type: application/json
Accept: application/json
{
"older" : "...",
"newer" : "...",
"ignoreRegex" : "..."
}
HTTP/1.1 201 Created
Content-Type: application/json
{
"diff" : "..."
}
Method to calculate the diff in HTML
media type | data type | description |
---|---|---|
application/json | DiffRequest (JSON) | request containing the HTML contents to be diffed |
media type | data type | description |
---|---|---|
application/json | DiffResponse (JSON) | response containing the diff |
application/xml;charset=UTF-8 | object |
POST /diff/html
Content-Type: application/json
Accept: application/json
{
"content1" : "...",
"content2" : "...",
"ignoreRegex" : "...",
"changeTemplate" : "...",
"insertTemplate" : "...",
"removeTemplate" : "...",
"wordsBefore" : 12345,
"wordsAfter" : 12345
}
HTTP/1.1 201 Created
Content-Type: application/json
{
"diff" : "..."
}
Method to calculate the diff between two HTML contents in source
media type | data type | description |
---|---|---|
application/json | DiffRequest (JSON) | request containing the HTML contents to be diffed |
media type | data type | description |
---|---|---|
application/json | DiffResponse (JSON) | response containing the diff |
application/xml;charset=UTF-8 | object |
POST /diff/source
Content-Type: application/json
Accept: application/json
{
"content1" : "...",
"content2" : "...",
"ignoreRegex" : "...",
"changeTemplate" : "...",
"insertTemplate" : "...",
"removeTemplate" : "...",
"wordsBefore" : 12345,
"wordsAfter" : 12345
}
HTTP/1.1 201 Created
Content-Type: application/json
{
"diff" : "..."
}