|
1 | | -ECHO start parcing... |
2 | | - |
3 | | -::add top part of template |
4 | | -TYPE %parent%template_top_report.html> niceDiff-report.html |
5 | | - |
6 | | -SET parent=%~dp0 |
7 | | - |
8 | | -::CONSTANTS |
9 | | -SET sOpenFile=^</div^>^<button class="section"^> |
10 | | -SET sCloseFile=^</button^>^<div class="section-content"^>^<div^> |
11 | | -SET sOpenCodeBlock=^</div^>^<div^> |
12 | | -SET sOpenCodeLine=^<pre^> |
13 | | -SET sCloseCodeLine=^</pre^> |
14 | | -SET sOpenAddCodeLine=^<pre class="add"^> |
15 | | -SET sOpenRemoveCodeLine=^<pre class="remove"^> |
16 | | - |
17 | | -::init code block |
18 | | -ECHO ^<div^>>> niceDiff-report.html |
19 | | -::init file section |
20 | | -ECHO ^<div^>>> niceDiff-report.html |
21 | | - |
22 | | -SETLOCAL enabledelayedexpansion |
23 | | -FOR /F "usebackq tokens=*" %%A IN ("%parent%/diff.txt") DO ( |
24 | | - SET line1=%%A |
25 | | - SET line2=!line1:^<=^<! |
26 | | - SET line=!line2:^>=^>! |
27 | | - IF "!line:~0,10!"=="diff --git" ( |
28 | | - rem close last code block in previous file |
29 | | - ECHO ^</div^>>> niceDiff-report.html |
30 | | - rem new file |
31 | | - ECHO !sOpenFile! >> niceDiff-report.html |
32 | | - ) ELSE IF "!line:~0,5!"=="--- a" ( |
33 | | - rem get file name |
34 | | - ECHO !line:~5!!sCloseFile! >> niceDiff-report.html |
35 | | - ) ELSE IF "!line:~0,5!"=="+++ b" ( |
36 | | - rem skip line |
37 | | - ) ELSE IF "!line:~0,6!"=="index " ( |
38 | | - rem skip line |
39 | | - ) ELSE IF "!line:~0,3!"=="@@ " ( |
40 | | - rem start diff block |
41 | | - ECHO !sOpenCodeBlock!!sOpenCodeLine!!line!!sCloseCodeLine! >> niceDiff-report.html |
42 | | - ) ELSE IF "!line:~0,1!"=="-" ( |
43 | | - rem start remove line |
44 | | - ECHO !sOpenRemoveCodeLine!!line:~1!!sCloseCodeLine! >> niceDiff-report.html |
45 | | - ) ELSE IF "!line:~0,1!"=="+" ( |
46 | | - rem start add line |
47 | | - ECHO !sOpenAddCodeLine!!line:~1!!sCloseCodeLine! >> niceDiff-report.html |
48 | | - ) ELSE ( |
49 | | - rem default add line |
50 | | - ECHO !sOpenCodeLine!!line!!sCloseCodeLine! >> niceDiff-report.html |
51 | | - ) |
52 | | -) |
53 | | -::close last code block |
54 | | -ECHO ^</div^>>> niceDiff-report.html |
55 | | -::close file section |
56 | | -ECHO ^</div^>>> niceDiff-report.html |
57 | | - |
58 | | -::add bottom part of template |
59 | | -TYPE %parent%template_bottom_report.html>> niceDiff-report.html |
60 | | - |
61 | | -ECHO complited |
62 | | - |
| 1 | +ECHO start parcing... |
| 2 | + |
| 3 | +SET parent=%~dp0 |
| 4 | + |
| 5 | +:: CONSTANTS |
| 6 | +SET sOpenFile=^</div^>^<button class="section"^> |
| 7 | +SET sCloseFile=^</button^>^<div class="section-content"^>^<div^> |
| 8 | +SET sOpenCodeBlock=^</div^>^<div^> |
| 9 | +SET sOpenCodeLine=^<pre^> |
| 10 | +SET sCloseCodeLine=^</pre^> |
| 11 | +SET sOpenAddCodeLine=^<pre class="add"^> |
| 12 | +SET sOpenRemoveCodeLine=^<pre class="remove"^> |
| 13 | + |
| 14 | +:: open tag for main cotent |
| 15 | +ECHO ^<main^>>>niceDiff-report.html |
| 16 | + |
| 17 | +:: init code block |
| 18 | +ECHO ^<div^>>> niceDiff-report.html |
| 19 | +:: init file section |
| 20 | +ECHO ^<div^>>> niceDiff-report.html |
| 21 | + |
| 22 | +SETLOCAL enabledelayedexpansion |
| 23 | +FOR /F "usebackq tokens=*" %%A IN ("%parent%/diff.txt") DO ( |
| 24 | + SET line1=%%A |
| 25 | + SET line2=!line1:^<=^<! |
| 26 | + SET line=!line2:^>=^>! |
| 27 | + IF "!line:~0,10!"=="diff --git" ( |
| 28 | + rem close last code block in previous file |
| 29 | + ECHO ^</div^>>> niceDiff-report.html |
| 30 | + rem new file |
| 31 | + ECHO !sOpenFile! >> niceDiff-report.html |
| 32 | + ) ELSE IF "!line:~0,5!"=="--- a" ( |
| 33 | + rem get file name |
| 34 | + ECHO !line:~5!!sCloseFile! >> niceDiff-report.html |
| 35 | + ) ELSE IF "!line:~0,5!"=="+++ b" ( |
| 36 | + rem skip line |
| 37 | + ) ELSE IF "!line:~0,6!"=="index " ( |
| 38 | + rem skip line |
| 39 | + ) ELSE IF "!line:~0,3!"=="@@ " ( |
| 40 | + rem start diff block |
| 41 | + ECHO !sOpenCodeBlock!!sOpenCodeLine!!line!!sCloseCodeLine! >> niceDiff-report.html |
| 42 | + ) ELSE IF "!line:~0,1!"=="-" ( |
| 43 | + rem start remove line |
| 44 | + ECHO !sOpenRemoveCodeLine!!line:~1!!sCloseCodeLine! >> niceDiff-report.html |
| 45 | + ) ELSE IF "!line:~0,1!"=="+" ( |
| 46 | + rem start add line |
| 47 | + ECHO !sOpenAddCodeLine!!line:~1!!sCloseCodeLine! >> niceDiff-report.html |
| 48 | + ) ELSE ( |
| 49 | + rem default add line |
| 50 | + ECHO !sOpenCodeLine!!line!!sCloseCodeLine! >> niceDiff-report.html |
| 51 | + ) |
| 52 | +) |
| 53 | +:: close last code block |
| 54 | +ECHO ^</div^>>> niceDiff-report.html |
| 55 | +:: close file section |
| 56 | +ECHO ^</div^>>> niceDiff-report.html |
| 57 | + |
| 58 | +:: add bottom part of template |
| 59 | +TYPE %parent%template_bottom_report.html>> niceDiff-report.html |
| 60 | + |
| 61 | +ECHO complited |
| 62 | + |
0 commit comments