Highlight the differences between two strings in
terms of substitutions, insertions and deletions calculated by
the generalized Levenshtein (edit) distance (using adist()
)
hl_diff(
x,
y,
coerce = "default",
fill = NULL,
text = NULL,
opts = hl_opts(),
sep = NULL,
...
)
each argument is a single string. vectors of strings not currently supported.
How should non-character arguments be coerced to character strings?
- the given object x
must already be a character string
- performs the matching after first calling
as.character(x)
- performs the matching against the default
print(x)
output
- performs the matching after first calling
deparse1(x)
- performs the matching on the output of calling
str(x)
named list of colours for substitutions, insertions and deletions with names 'sub', 'ins' and 'del'. If set to NULL (the default) then default colours will be used.
named list of colours for the text for 'sub', 'ins' and 'del'
operations. If NULL
, then colours which contrast with fill
will
be chosen automatically
create options list
character string of the line separating the two objects. Default: NULL
for no separation. Use the empty string to insert an empty line.
further arguments passed to adist()
list of 'emphatic' objects which could be rendered to ANSI or HTML
This works character-by-character, so the displayed difference for multiline strings can be quite busy if there are a lot of changes.
hl_diff('hello', 'there')
#> [1] " hello"
#> [1] "there "