Skip to content

Commit c4b3b68

Browse files
committed
feat: classNames config
1 parent 37745b5 commit c4b3b68

File tree

13 files changed

+224
-143
lines changed

13 files changed

+224
-143
lines changed

.github/workflows/github-ci.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ jobs:
1919
steps:
2020

2121
- name: Checkout
22-
uses: actions/checkout@v3
22+
uses: actions/checkout@v4
2323

2424
- name: Set up pnpm
25-
uses: pnpm/action-setup@v2
25+
uses: pnpm/action-setup@v4
2626
with:
2727
version: 9
2828

2929
- name: Set up node
30-
uses: actions/setup-node@v3
30+
uses: actions/setup-node@v4
3131
with:
3232
node-version: 20
3333
cache: 'pnpm'
@@ -42,13 +42,13 @@ jobs:
4242
run: pnpm run build
4343

4444
- name: Build example
45-
run: cd examples/basic && pnpm run build
45+
run: cd examples/basic && pnpm run build --base=/html-diff/
4646

4747
- name: Upload artifact
48-
uses: actions/upload-pages-artifact@v1
48+
uses: actions/upload-pages-artifact@v3
4949
with:
5050
path: 'examples/basic/dist'
5151

5252
- name: Deploy to GitHub Pages
5353
id: deployment
54-
uses: actions/deploy-pages@v1
54+
uses: actions/deploy-pages@v4

README.md

+23-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Html Diff
22

3-
Generate HTML content with unified or side-by-side differences.
3+
Compare HTML and generate the differences in either a unified view or a side-by-side comparison.
44

55
## Install
66

@@ -22,13 +22,30 @@ const unifiedContent = diff.getUnifiedContent()
2222
const sideBySideContents = diff.getSideBySideContents()
2323
```
2424

25-
## Preview
25+
You can use your own styles without import the css file
2626

27-
### unified differences
27+
```js
28+
import HtmlDiff from '@armantang/html-diff'
2829

29-
![home](https://arman19941113.github.io/html-diff/unified.png)
30+
const oldHtml = `<div>hello</div>`
31+
const newHtml = `<div>hello world</div>`
32+
const diff = new HtmlDiff(oldHtml, newHtml, {
33+
minMatchedSize: 3,
34+
classNames: {
35+
createText: 'cra-txt',
36+
deleteText: 'del-txt',
37+
createInline: 'cra-inl',
38+
deleteInline: 'del-inl',
39+
createBlock: 'cra-blo',
40+
deleteBlock: 'del-blo',
41+
},
42+
})
43+
const unifiedContent = diff.getUnifiedContent()
44+
const sideBySideContents = diff.getSideBySideContents()
45+
```
3046

31-
### side-by-side differences
47+
## Preview
3248

33-
![home](https://arman19941113.github.io/html-diff/sidebyside.png)
49+
[See online demo...](https://arman19941113.github.io/html-diff/)
3450

51+
![home](https://arman19941113.github.io/html-diff/demo.png)

doc/sidebyside.png

-1.59 MB
Binary file not shown.

doc/unified.png

-1.63 MB
Binary file not shown.
File renamed without changes.

examples/basic/public/demo.png

391 KB
Loading
File renamed without changes.

examples/basic/public/vite.svg

-1
This file was deleted.

examples/basic/src/hooks/useInputData.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default function useInputData() {
1616
<p>今天和明天已经由昨天决定,你还可以决定后天。</p>
1717
<p>只有当你离开自己的舒适区时,你才会挑战自己的极限。</p>
1818
<p>一本有价值的书就是一盏智慧之灯,总有人不断从中提取光明。</p>
19-
<img src="src/assets/dog.jpg" alt="dog">
19+
<img src="dog.jpg" alt="dog">
2020
<h2>Try video</h2>
2121
<video style="width: 100%;" controls>
2222
<source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
@@ -36,7 +36,7 @@ export default function useInputData() {
3636
<p>无休止的欲望像个黑洞,浸染了我们原本澄澈而简单的心</p>
3737
<p>只有当你离开自己的舒适区时,你才会挑战自己的极限。</p>
3838
<p>一本有价值的书就是一盏智慧之灯,总有人不断从中提取光明。</p>
39-
<img src="src/assets/cat.jpg" alt="cat">
39+
<img src="cat.jpg" alt="cat">
4040
<h2>Try video</h2>
4141
<h2>Set the bird's wings with gold and it will never again soar in the sky.</h2>
4242
<video style="width: 100%;" controls src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4"></video>`)

packages/html-diff/src/dress-up.ts

-65
This file was deleted.

0 commit comments

Comments
 (0)