@@ -2,30 +2,29 @@ import { describe, expect, it } from "vitest";
22import { htmlToMarkdown } from "./htmlToMarkdown" ;
33
44describe ( "htmlToMarkdown" , ( ) => {
5- it ( "converts headings, emphasis and links" , ( ) => {
6- const html =
7- "<h1>Title</h1><p>Some <strong>bold</strong> and <em>italic</em> with a <a href='https://posthog.com'>link</a>.</p>" ;
8- expect ( htmlToMarkdown ( html ) ) . toBe (
5+ it . each ( [
6+ [
7+ "headings, emphasis and links" ,
8+ "<h1>Title</h1><p>Some <strong>bold</strong> and <em>italic</em> with a <a href='https://posthog.com'>link</a>.</p>" ,
99 "# Title\n\nSome **bold** and *italic* with a [link](https://posthog.com)." ,
10- ) ;
11- } ) ;
12-
13- it ( "converts unordered lists" , ( ) => {
14- const html = "<ul><li>one</li><li>two</li></ul>" ;
15- expect ( htmlToMarkdown ( html ) ) . toBe ( "- one\n- two" ) ;
16- } ) ;
17-
18- it ( "converts tables via the gfm plugin" , ( ) => {
19- const html =
20- "<table><thead><tr><th>a</th><th>b</th></tr></thead><tbody><tr><td>1</td><td>2</td></tr></tbody></table>" ;
21- expect ( htmlToMarkdown ( html ) ) . toBe (
10+ ] ,
11+ [
12+ "unordered lists" ,
13+ "<ul><li>one</li><li>two</li></ul>" ,
14+ "- one\n- two" ,
15+ ] ,
16+ [
17+ "tables via the gfm plugin" ,
18+ "<table><thead><tr><th>a</th><th>b</th></tr></thead><tbody><tr><td>1</td><td>2</td></tr></tbody></table>" ,
2219 "| a | b |\n| --- | --- |\n| 1 | 2 |" ,
23- ) ;
24- } ) ;
25-
26- it ( "converts fenced code blocks" , ( ) => {
27- const html = "<pre><code>const x = 1;</code></pre>" ;
28- expect ( htmlToMarkdown ( html ) ) . toBe ( "```\nconst x = 1;\n```" ) ;
20+ ] ,
21+ [
22+ "fenced code blocks" ,
23+ "<pre><code>const x = 1;</code></pre>" ,
24+ "```\nconst x = 1;\n```" ,
25+ ] ,
26+ ] ) ( "converts %s" , ( _ , html , expected ) => {
27+ expect ( htmlToMarkdown ( html ) ) . toBe ( expected ) ;
2928 } ) ;
3029
3130 it ( "returns null when there is no formatting beyond the plain-text fallback" , ( ) => {
0 commit comments