loading... Pacem JS

Diff strings

Method that yields differences between two pieces of text.

Syntax

// method
Pacem.Utils.diff(a: string, b: string) : DiffToken[]

Transformer

Direct utilization in the markup, using the relevant transformer:

<!-- compare two strings -->
<pacem-span content="{{ $pacem.diff('Text with a typ0.', 'Text without a typo.') }}"></pacem-span>

That obtains the following output:

Cantami, o Diva, del pelide Achille l'ira funesta che infiniti addusse lutti agli Achei.

Canta, o dea, l'ira d'Achille Pelide, rovinosa, che infiniti dolori inflisse agli Achei.