(html)
| 674 | |
| 675 | //excel表格处理 |
| 676 | function pasteClipboardHtml(html) { |
| 677 | const startFramgmentStr = '<!--StartFragment-->'; |
| 678 | const endFragmentStr = '<!--EndFragment-->'; |
| 679 | const startFragmentIndex = html.indexOf(startFramgmentStr); |
| 680 | const endFragmentIndex = html.lastIndexOf(endFragmentStr); |
| 681 | |
| 682 | if (startFragmentIndex > -1 && endFragmentIndex > -1) { |
| 683 | html = html.slice(startFragmentIndex + startFramgmentStr.length, endFragmentIndex); |
| 684 | } |
| 685 | |
| 686 | // Wrap with <tr> if html contains dangling <td> tags |
| 687 | // Dangling <td> tag is that tag does not have <tr> as parent node. |
| 688 | if (/<\/td>((?!<\/tr>)[\s\S])*$/i.test(html)) { |
| 689 | html = '<tr>' + html + '</tr>'; |
| 690 | } |
| 691 | // Wrap with <table> if html contains dangling <tr> tags |
| 692 | // Dangling <tr> tag is that tag does not have <table> as parent node. |
| 693 | if (/<\/tr>((?!<\/table>)[\s\S])*$/i.test(html)) { |
| 694 | html = '<table>' + html + '</table>'; |
| 695 | } |
| 696 | |
| 697 | return html; |
| 698 | } |
| 699 | |
| 700 | //将html转换为markdown |
| 701 | function html2md(str) { |
nothing calls this directly
no outgoing calls
no test coverage detected