-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
131 changed files
with
246 additions
and
4 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified
0
benchmark/files/039c4b966d1f2a0c589ac0aad211fe65500ad1cb58c7f45b34251db7056803ec.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/06ed0a833361190536a4f61888354e07dccaa501bd9a1c0f1c545533bde1650b.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/078cdb456d1beb698aeed86e0f2161e442e9431c4580295f1ba4ece22741068c.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/0a8c510c3691d8e68ccc749559680257a382fe792a3d4d8531fb285cd74c3492.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/0e55dcdbeb54c88ee87942b9fef7ea5398fa9a1e83493d55844b479506a80fd8.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/17ca85324662023ba21666b3ca5d5d37a92b2806bf7a88b906c28b90a635f82a.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/19fe8f574b7420277862728929d83dd74d7aa9c742688ca4c386b75693547bd3.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/1a2c2f9fe410c836bb94e85c85625dbe8174f6e57f0b0316644cefd30979f096.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/1bbc7f62e80e44afd533e896c0168c3b18f1e934530d05cb1f579ad3347d135c.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/1d43b4816bdba5825165dc21558d9eafb9f650c67ba048411b04dc77a745dc39.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/1de0efed4d661163ff8414e8ca69f45a49efd7edca19dc896ca0983a4bf41485.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/1e62a223bca12adda6410b1789072a2ad755566bd4a6bc17d10dc95a51d74d65.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/20f1955819dc2b50d2d10788f73adc72bceb491a03ed608debb72a90bce65c50.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/22c0f41ae560968de5e6b0ef9ecffffeae3f409aa73d9b82853f65535116f68f.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/22c3886e7116464c04c2332c20a013a5837992e7bcdb1f6cacd7d475f9784273.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/22c4be85802e9602a344fc2cc704093362b9193523c6e35cfb7dc086c8ef8648.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/26c3b98f33bb6902f32535235fd7d32792df87779bdf1f86c3b21e15fbf3161d.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/2dbf7cd4444617cc60f0e2d2c95b20a535979a32972f5005e2af577b37980e48.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/2fd71e2969106342bab6862bb212ae16ba592b426dd4141da8a383b183aa3a37.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/35f536ef8c8eba0616f2dc78e6653e1d7d68e3af927b09efad3dae7ce2080567.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/3b27831099c75b36d5978864ec89575c675c963e949cda52147a044bbfa77559.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/3f6413c32bffc73b64cb1a2adb237cd19ffc75494c9172755f1a961ba32e75dd.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/40d4e50472a8f0d30d68613051be510ed098087679df7e0e564d6dd32152d679.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/42b43887c6dd91353249924745e030eac3a6d818966d91c67b406431ff9bdf05.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/44b21071ae6feede3c36d2ab032cd422eb0c6a0fdfe4da79531931ad93dd4940.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/44f750fab67bb9f54f5b5cc90bc34d55cff06260a3e63245856a6e57fcda5906.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/45b6063ac2016db7b2fb1f995f0b54ee054fb561022e169c8fdbe321dcf672db.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/45efaba666da241d9d069b550890530b65f2a6b61a5e529e1d3664630d4897ee.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/46ab324348ca339dba58238e193f794c3309e52c018a8156ef9aedfedf0572e7.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/46ed10778ec7c1292e624e1a72a2a0899f8ab6d8d4db1aa57fa4418b8b7e0a5d.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/4b8debc51d3d9598ad4552cc7a591d200a6c7d545fed2454916bedbb0f666086.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/4bf8e536214f987f4a0bf6ca7d233619d30bde1e80a816c78d00358eb61e353c.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/4e0e399d24fe145def4817facccb0ff79e305dedb9ece5f8ec66396ea378f723.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/4f454cb97e9b77d94c10ed8a6a35cd2eff1671de9d3d27852a38abd76a95be83.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/4f83531b9fc91fd1e0062e43200669cd82cc36a518caa7f66fc6ba5be4ac545b.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/4fe5472ba89db38e20daef6025108310c52121fd382c06314d5b33d7f47c1e94.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/5a012f66c2bf0c70a0744c7483478aaa0c1a2b5b5920a72223f3a090e39df8be.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/5bc9df3a36efb57a22edf862cec6a28eb112e535559c194d7976fb664c922c13.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/5c83c2d71f97e2b5a979f197fbae6773dee6844e28889ae66ccb8d7458a9c5bb.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/5de3db78f95172797a51b3b3b2cdc4caeb63a4d7b709e4441510d2c1967e0e6f.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/5f081a0a9d1a1ce3b0e53603ecd8bde78947841c8fd1ff3c36efa95ee84681f6.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/5f8b89390d3fc01c6a80728ba2aee597fea1dbfc8399d61015956db71e5336c7.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/5f8c9f60be2250f694094ee1ca5deb9df10479e29fc92ff07c77c4cb9d2c3f21.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/5fbfe3905c71925b1b3a875a3111073e5d0996d3f250a697398477d3642db321.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/60b8aff17382f2fd02584645ef66e517b41f764d5b4ca404c1ceff3fe22bdda8.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/60bccec4069d54a6889bfcda785c0f3066a70cb5fadeea81f28d371681a2dee8.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/60cc80fb25f0b2ebdb2e6835ab7bfd3d26362971e39fe8838e7ac548ba323cf0.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/61adb9c208d9c67253b4413ef7ec2d010edae448b8c832bff2254125e4b51d5f.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/61d8052b19ed9885651ed1110ddcccc001f9ec2e3b7a77926d350762bcd02400.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/63c6d5256b8ce1098b5688eb5fafa747e9467692d099a3e9e42246e7af29748f.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/64bf40da8348d808ef103cc5529fd268fec46fbefa40b486d288d2a07871a527.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/6a59bd96489c98226c72f0245bac98a4b09aa0516ebfe4982233a6c33d129691.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/6b095375a53dfc7994a032e2efac70f43a4fac9303d549256d88b8f7cecadd50.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/6b817bedb8d6402bab160ed6d2b99256163bd3aef20deae3015f74e5bb253e55.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/6d30abed88489774017024b17cdb1928d9a2b45bb79767515383b8444e9601b2.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/71bf3c23c5d3fff9cec67606fde6547c8866ae8aa95f5991651d94c68df4ad1d.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/71cb773c42c94b75d41c059a27dd10b763443a71dbb6dd202402843de8a5e331.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/72e78dee157bdf3e8a9a9f07e54a98a3714ea2998e2c2e2a94c46dbe92176feb.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/72ecfb3f60f4e8a6103916f2041ce9a55c4ef1e31477f9a8ffb7f4d3bba8c559.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/73c175cdf9d5e065351ecf2220510088904adb77b49211cdd99e43e5870e06c2.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/74e8bc94abea7c60f022d8d3f672f80e59e3e126735fae0b5ee5914ff2fce48e.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/7a426de207434e419a65eead0f4b46c8a479429d8429c36dc03b033d7e4891df.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/7b7ffca82db8f721d6e5a8e4e65e60885af5eee4b9f28beb6b8363bb70c820f9.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/7e26f2e426fef3c1a370382e7827ef2e530a2ff0c2cea7641ebb596a4a1b8008.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/7e2d19ccbb3b4029dddf26557555278babdac18bb78a742052fd946001c28e4e.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/7e54e701ac39a9046d6eeb0ae75d2138733b66b30b5211e7f3245dd6dc3ca36c.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/7e91eb56692c91312a3dc3e7b769a2916029ef3d9e431d056d5f548c0f771d16.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/7fc58a2d32d5b8d5fa9b918453a284acc71703ccfa0f0c89ec292b4245fd0521.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/81d304541f62a6aaf29494766718ab8e58e95a8e784613e75f106cdef17868d6.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/83c362b1373f55d45fdad0edee4d2885cafd0da3f2afb146cf2822448c3c4104.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/84a7e7d5f61c90050a326bb74ac3a57899fdba4b755bd50df01a053c262d354e.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/8a1eb64f950f2f43097577c244fb38a35660f50a88c4305b23a8f24f254da8cb.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/8a701b6ec1c56e2c37357030da0b4b10af4187f069a988e12c2f91d2ba40cdc1.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/8a82ce22fec5e3656dad3d55e585727c88c94808ad92e37a0f6e99dcb3888800.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/8a9d17a1e5b1866abc7b9263fabbc428e5299c7443ecad6cc56c0076287fe11a.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/8bd6d9bcba689408767f770d69f12b59c3f092e73cffcc9332261fbab4aa16e1.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/8c0dd0456453aeff3f66d053710f18adc1a2fc0f1f3a0c95a3e166e41ffb737d.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/8c1a780dec8c1a5ea0344514524f53b2b580ce87083e0a756ade3d83627d5653.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/8cbf3b144736ffc4adda5fe7105e7fd1413dcc1955110829d849a658aa722bea.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/8cfa9d30e2b66b991461423012906121661cd9c8809f564eabb660149577864d.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/8d612a03fa42a2fb014b59534c46c9590da90fbeb91ac50938cdfa36dd274e23.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/8faa3156452fa9d0667617c406eb9b6458b48d7b8c36cf2bf804fba290b302f5.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/9c947bc9fbcb4e2eb0296d858fe193f580e869db7869358af822d7d2d4c0388e.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/9e04cb267a9b128369a11c7f6e5486d43644955dee7f73cc004b9cf1693a11c1.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/9e3c6d40690c1302613f203db178b23f9f18494d2653a1b547086a3973fff93c.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/9f2031ee45a11919452ca2efbc3498672324cda5f76314d7ea10913f63cf3545.html
100755 → 100644
Empty file.
Empty file modified
0
benchmark/files/9fba51a14308353194c537f494ded0ccb27d9f908f252690b083d48db64ea15a.html
100755 → 100644
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { NodeHtmlMarkdown } from '../src'; | ||
|
||
|
||
/* ****************************************************************************************************************** * | ||
* Tests | ||
* ****************************************************************************************************************** */ | ||
|
||
describe(`Table`, () => { | ||
let instance: NodeHtmlMarkdown; | ||
const translate = (html: string) => instance.translate(html); | ||
beforeAll(() => { | ||
instance = new NodeHtmlMarkdown(); | ||
}); | ||
|
||
test(`Single row, Single column table`, () => { | ||
const expected = `| col1 |\n| ---- |`; | ||
|
||
expect(translate(`<table><tr><th> col1 </th></tr></table>`)).toBe(expected); | ||
expect(translate(`<table><tr><td> col1 </td></tr></table>`)).toBe(expected); | ||
expect(translate(`<table><td> col1 </td></table>`)).toBe(expected); | ||
}); | ||
|
||
test(`Single row table`, () => { | ||
const expected = `| col1 | col2 |\n| ---- | ---- |`; | ||
|
||
expect(translate(`<table><tr><th> col1 </th><td>col2 </td></tr></table>`)).toBe(expected); | ||
expect(translate(`<table><tr><td> col1 </td><td>col2 </td></table>`)).toBe(expected); | ||
expect(translate(`<table><td> col1 </td><td>col2 </td></table>`)).toBe(expected); | ||
}); | ||
|
||
test(`Table with caption`, () => { | ||
const expected = | ||
`__Hello__\n` + | ||
`| col1 | col2 |\n` + | ||
`| ---- | ---- |`; | ||
|
||
expect(translate(`<table><caption>Hello</caption><tr><th> col1 </th><td>col2 </td></tr></table>`)).toBe(expected); | ||
expect(translate(`<table><th> col1 </th><td>col2 </td><caption>Hello</caption></table>`)).toBe(expected); | ||
}); | ||
|
||
describe(`Special Cases`, () => { | ||
test(`"|" is escaped`, () => { | ||
expect(translate(`<table><tr><td>A|B</td></tr></table>`)).toBe(`| A\\|B |\n| ---- |`); | ||
}); | ||
|
||
test(`Pads cells`, () => { | ||
const html = `<table> | ||
<tr><td>abc</td><td>def</td><td>ghi</td></tr> | ||
<tr><td>abc1</td><td>def123</td><td>ghi1234567</td></tr> | ||
<tr><td>a</td><td>def1234</td><td>c</td></tr> | ||
</table>`; | ||
const expected = | ||
`| abc | def | ghi |\n` + | ||
`| ---- | ------- | ---------- |\n` + | ||
`| abc1 | def123 | ghi1234567 |\n` + | ||
`| a | def1234 | c |`; | ||
|
||
expect(translate(html)).toBe(expected); | ||
}); | ||
|
||
test(`Nested tables are not supported`, () => { | ||
const html = `<table><tr><td><table><tr><td>nested</td></tr></table></td><td>abc</td></tr></table>`; | ||
expect(translate(html)).toBe(`| nested | abc |\n| ------ | --- |`); | ||
}); | ||
|
||
test(`Supports inline tags + mismatched rows`, () => { | ||
const html = ` | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>COL1</th> | ||
<th>C | ||
O | ||
L2</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<th><b>b</b></th> | ||
<td><i>i</i></td> | ||
<td><a href="link">a</a></td> | ||
<td><img src="file"></td> | ||
</tr> | ||
<tr> | ||
<th><ul><li>list</li><li></li></ul></th> | ||
<td><hr></td> | ||
<td><h1>h1</h1></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
`; | ||
|
||
const expected = | ||
`| COL1 | C O L2 | | |\n` + | ||
`| ----- | ------ | --------- | --------- |\n` + | ||
`| **b** | _i_ | [a](link) | ![](file) |\n` + | ||
`| list | | h1 | |`; | ||
|
||
expect(translate(html)).toBe(expected); | ||
}); | ||
}); | ||
}); |
Empty file.
Empty file.
Empty file.
Empty file.
faaebe8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit solved my problem. 😊👍
faaebe8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nhj7 Glad to hear it! Thanks goes to @otolab for the help on this.