GeezerVison is showing github.com — DiffRowGenerator should be able to deliver DiffRow list wwithout HTML tags in oldLine and newLine · Issue #11 · java-diff-utils/java-diff-utils
DiffRowGenerator should be able to deliver DiffRow list wwithout HTML tags in oldLine and newLine #11
Description
By default DiffRowGenerator.generateDiffRows delivers a List of DiffRow where the oldLine and the newLine property are polluted with HTML tags like
and HTML-escaping sequences like >.
It should be possible to get the unmodified text lines back for use in projects where HTML enrichment/escaping is not necessary or useful.
My proposal is to introduce a new property reportLinesUnWrapped which can be set by the DiffRowGenerator.Builder. If this property is set to true the DiffRowGenerator delivers back the original text lines.
Please see the attached source.
DiffRowGenerator.zip
Activity
wumpz commented on Aug 17, 2017
The tags included can be modified using the builder.
wumpz commented on Aug 17, 2017
If you look at the examples for markup presentation you will see.
wumpz commented on Aug 18, 2017
The DiffRowGenerator is exactly for this purpose. If you only want to get a changeset you should got for DiffUtils. Look at the first example (ComputeDifference.java).
ADiex commented on Aug 18, 2017
The only way to achieve approximatle what diffRowGenerator.generateDiffRows does is DiffUtils.diff (List original, List revised). But my tests with this method and also your example have shown that it only provides the deltas change, insert, delete, and not the unchanged lines. And it also does not provide the the very good line-wise depiction of original and revised as pointed out in DiffRowGenerator. The initial author of DiffRowGenerator unfortunately mixed HTML presentation issues into the generation of a DiffRow list. The DiffRowGenerator could cover not only the requirement to generate HTML-capable code, but also the output of the pure differences of texts. The few lines of code that I inserted in my suggestion there would reach that goal.
Unittest.zip
wumpz commented on Aug 18, 2017
Ah. Sorry. I missed your point. Sure your flag does make thing easier. At the moment you could simulate it using:
DiffRowGenerator generator = DiffRowGenerator.create()
.columnWidth(Integer.MAX_VALUE)
.oldTag(f -> "")
.newTag(f -> "")
.build();
I will integrate your change request, but the method name will be reportLinesUnchanged since you are more than wrap skipping.
added a commit that references this issue
on Aug 18, 2017This issue will close once commit 5d5218b is merged into the 'master' branch.5d5218b rosta commented on Jul 27, 2019
There is a use case where the raw value would be useful as well as the formatted value:
I need to filter out certain differences by matching them against a set of regular expressions. These expressions are much easier to specify for the raw text than for the html/markdown formatted text. As such it would be nice to have the possibility to hold the raw texts in the DiffRow
wumpz commented on Jul 27, 2019
@rosta Could you make a separate issue with an example. I M not sure if I understand your problem.
Metadata
Metadata
Development
No branches or pull requestsIssue actions