@@ -206,7 +206,55 @@ document.getElementById('destination-elem-id').innerHTML = diffHtml;
206
206
207
207
### Diff2Html Examples
208
208
209
- #### Diff2Html Angular Example
209
+ #### Diff2Html Example using plain HTML/JS
210
+
211
+ ``` html
212
+ <!DOCTYPE html>
213
+ <html lang =" en-us" ><head >
214
+ <meta charset =" utf-8" >
215
+ <!-- Make sure to load the CSS file in that order-->
216
+ <link rel =" stylesheet" href =" https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.1/styles/github.min.css" />
217
+ <link rel =" stylesheet" type =" text/css" href =" https://cdn.jsdelivr.net/npm/diff2html/bundles/css/diff2html.min.css" />
218
+ <script type =" text/javascript" src =" https://cdn.jsdelivr.net/npm/diff2html/bundles/js/diff2html-ui.min.js" ></script >
219
+ </head >
220
+
221
+ <script >
222
+ const diffString = ` diff --git a/sample.js b/sample.js
223
+ index 0000001..0ddf2ba
224
+ --- a/sample.js
225
+ +++ b/sample.js
226
+ @@ -1 +1 @@
227
+ -console.log("Hello World!")
228
+ +console.log("Hello from Diff2Html!")` ;
229
+
230
+ document .addEventListener (' DOMContentLoaded' , function () {
231
+ var targetElement = document .getElementById (' myDiffElement' );
232
+ var configuration = {
233
+ inputFormat: ' json' ,
234
+ drawFileList: true ,
235
+ fileListToggle: false ,
236
+ fileListStartVisible: false ,
237
+ fileContentToggle: false ,
238
+ matching: ' lines' ,
239
+ outputFormat: ' side-by-side' ,
240
+ synchronisedScroll: true ,
241
+ highlight: true ,
242
+ renderNothingWhenEmpty: false };
243
+ var diff2htmlUi = new Diff2HtmlUI (targetElement, diffString, configuration);
244
+ diff2htmlUi .draw ();
245
+ diff2htmlUi .highlightCode ();
246
+ });
247
+ </script >
248
+
249
+ <body >
250
+
251
+ <div id =" myDiffElement" ></div >
252
+
253
+ </body >
254
+ </html >
255
+ ```
256
+
257
+ #### Diff2Html Example using Angular
210
258
211
259
- Typescript
212
260
@@ -253,7 +301,7 @@ export class AppDiffComponent implements OnInit {
253
301
]
254
302
```
255
303
256
- #### Diff2Html Vue.js Example
304
+ #### Diff2Html Example using Vue.js
257
305
258
306
``` vue
259
307
<template>
0 commit comments