@@ -57,14 +57,16 @@ Deno.test(
57
57
58
58
Deno . test ( "bug #61 generate a tag" , ( ) => {
59
59
const markdown = "[link](https://example.com)" ;
60
- const expected = `<p><a href="https://example.com" rel="noopener noreferrer">link</a></p>\n` ;
60
+ const expected =
61
+ `<p><a href="https://example.com" rel="noopener noreferrer">link</a></p>\n` ;
61
62
const html = render ( markdown ) ;
62
63
assertEquals ( html , expected ) ;
63
64
} ) ;
64
65
65
66
Deno . test ( "bug #61 generate a tag with disableHtmlSanitization" , ( ) => {
66
67
const markdown = "[link](https://example.com)" ;
67
- const expected = `<p><a href="https://example.com" rel="noopener noreferrer">link</a></p>\n` ;
68
+ const expected =
69
+ `<p><a href="https://example.com" rel="noopener noreferrer">link</a></p>\n` ;
68
70
const html = render ( markdown , { disableHtmlSanitization : true } ) ;
69
71
assertEquals ( html , expected ) ;
70
72
} ) ;
@@ -112,7 +114,8 @@ Deno.test("alerts rendering", async () => {
112
114
Deno . test ( "Iframe rendering" , ( ) => {
113
115
const markdown =
114
116
'Here is an iframe:\n\n<iframe src="https://example.com" width="300" height="200"></iframe>' ;
115
- const expected = `<p>Here is an iframe:</p>\n<iframe src="https://example.com" width="300" height="200"></iframe>` ;
117
+ const expected =
118
+ `<p>Here is an iframe:</p>\n<iframe src="https://example.com" width="300" height="200"></iframe>` ;
116
119
117
120
const html = render ( markdown , { allowIframes : true } ) ;
118
121
assertEquals ( html , expected ) ;
@@ -130,15 +133,17 @@ Deno.test("Iframe rendering disabled", () => {
130
133
Deno . test ( "Media URL transformation" , ( ) => {
131
134
const markdown = "\n\n" ;
132
135
const mediaBaseUrl = "https://cdn.example.com/" ;
133
- const expected = `<p><img src="https://cdn.example.com/image.jpg" alt="Image" /></p>\n<p><img src="https://cdn.example.com/video.mp4" alt="Video" /></p>\n` ;
136
+ const expected =
137
+ `<p><img src="https://cdn.example.com/image.jpg" alt="Image" /></p>\n<p><img src="https://cdn.example.com/video.mp4" alt="Video" /></p>\n` ;
134
138
135
139
const html = render ( markdown , { mediaBaseUrl : mediaBaseUrl } ) ;
136
140
assertEquals ( html , expected ) ;
137
141
} ) ;
138
142
139
143
Deno . test ( "Media URL transformation without base URL" , ( ) => {
140
144
const markdown = "\n\n" ;
141
- const expectedWithoutTransformation = `<p><img src="image.jpg" alt="Image" /></p>\n<p><img src="video.mp4" alt="Video" /></p>\n` ;
145
+ const expectedWithoutTransformation =
146
+ `<p><img src="image.jpg" alt="Image" /></p>\n<p><img src="video.mp4" alt="Video" /></p>\n` ;
142
147
143
148
const html = render ( markdown ) ;
144
149
assertEquals ( html , expectedWithoutTransformation ) ;
@@ -163,15 +168,17 @@ Deno.test("Media URL transformation with invalid URL", () => {
163
168
164
169
Deno . test ( "Inline rendering" , ( ) => {
165
170
const markdown = "My [Deno](https://deno.land) Blog" ;
166
- const expected = `My <a href="https://deno.land" rel="noopener noreferrer">Deno</a> Blog` ;
171
+ const expected =
172
+ `My <a href="https://deno.land" rel="noopener noreferrer">Deno</a> Blog` ;
167
173
168
174
const html = render ( markdown , { inline : true } ) ;
169
175
assertEquals ( html , expected ) ;
170
176
} ) ;
171
177
172
178
Deno . test ( "Inline rendering false" , ( ) => {
173
179
const markdown = "My [Deno](https://deno.land) Blog" ;
174
- const expected = `<p>My <a href="https://deno.land" rel="noopener noreferrer">Deno</a> Blog</p>\n` ;
180
+ const expected =
181
+ `<p>My <a href="https://deno.land" rel="noopener noreferrer">Deno</a> Blog</p>\n` ;
175
182
176
183
const html = render ( markdown , { inline : false } ) ;
177
184
assertEquals ( html , expected ) ;
@@ -180,15 +187,17 @@ Deno.test("Inline rendering false", () => {
180
187
Deno . test ( "Link URL resolution with base URL" , ( ) => {
181
188
const markdown = "[Test Link](/path/to/resource)" ;
182
189
const baseUrl = "https://example.com/" ;
183
- const expected = `<p><a href="https://example.com/path/to/resource" rel="noopener noreferrer">Test Link</a></p>\n` ;
190
+ const expected =
191
+ `<p><a href="https://example.com/path/to/resource" rel="noopener noreferrer">Test Link</a></p>\n` ;
184
192
185
193
const html = render ( markdown , { baseUrl : baseUrl } ) ;
186
194
assertEquals ( html , expected ) ;
187
195
} ) ;
188
196
189
197
Deno . test ( "Link URL resolution without base URL" , ( ) => {
190
198
const markdown = "[Test Link](/path/to/resource)" ;
191
- const expected = `<p><a href="/path/to/resource" rel="noopener noreferrer">Test Link</a></p>\n` ;
199
+ const expected =
200
+ `<p><a href="/path/to/resource" rel="noopener noreferrer">Test Link</a></p>\n` ;
192
201
193
202
const html = render ( markdown ) ;
194
203
assertEquals ( html , expected ) ;
@@ -197,7 +206,8 @@ Deno.test("Link URL resolution without base URL", () => {
197
206
Deno . test ( "Link URL resolution with invalid URL and base URL" , ( ) => {
198
207
const markdown = "[Test Link](/path/to/resource)" ;
199
208
const baseUrl = "this is an invalid url" ;
200
- const expected = `<p><a href="/path/to/resource" rel="noopener noreferrer">Test Link</a></p>\n` ;
209
+ const expected =
210
+ `<p><a href="/path/to/resource" rel="noopener noreferrer">Test Link</a></p>\n` ;
201
211
202
212
const html = render ( markdown , { baseUrl : baseUrl } ) ;
203
213
assertEquals ( html , expected ) ;
@@ -242,15 +252,17 @@ Deno.test("image title and no alt", () => {
242
252
243
253
Deno . test ( "js language" , ( ) => {
244
254
const markdown = "```js\nconst foo = 'bar';\n```" ;
245
- const expected = `<div class="highlight highlight-source-js notranslate"><pre><span class="token keyword">const</span> foo <span class="token operator">=</span> <span class="token string">'bar'</span><span class="token punctuation">;</span></pre></div>` ;
255
+ const expected =
256
+ `<div class="highlight highlight-source-js notranslate"><pre><span class="token keyword">const</span> foo <span class="token operator">=</span> <span class="token string">'bar'</span><span class="token punctuation">;</span></pre></div>` ;
246
257
247
258
const html = render ( markdown ) ;
248
259
assertEquals ( html , expected ) ;
249
260
} ) ;
250
261
251
262
Deno . test ( "code fence with a title" , ( ) => {
252
263
const markdown = "```js title=\"index.ts\"\nconst foo = 'bar';\n```" ;
253
- const expected = `<div class="highlight highlight-source-js notranslate"><div class="markdown-code-title">index.ts</div><pre><span class="token keyword">const</span> foo <span class="token operator">=</span> <span class="token string">'bar'</span><span class="token punctuation">;</span></pre></div>` ;
264
+ const expected =
265
+ `<div class="highlight highlight-source-js notranslate"><div class="markdown-code-title">index.ts</div><pre><span class="token keyword">const</span> foo <span class="token operator">=</span> <span class="token string">'bar'</span><span class="token punctuation">;</span></pre></div>` ;
254
266
255
267
const html = render ( markdown ) ;
256
268
assertEquals ( html , expected ) ;
@@ -292,7 +304,8 @@ Deno.test("code containing mermaid", () => {
292
304
293
305
Deno . test ( "link with title" , ( ) => {
294
306
const markdown = `[link](https://example.com "asdf")` ;
295
- const expected = `<p><a href="https://example.com" title="asdf" rel="noopener noreferrer">link</a></p>\n` ;
307
+ const expected =
308
+ `<p><a href="https://example.com" title="asdf" rel="noopener noreferrer">link</a></p>\n` ;
296
309
const html = render ( markdown ) ;
297
310
assertEquals ( html , expected ) ;
298
311
} ) ;
@@ -305,7 +318,8 @@ Deno.test("expect console warning from invalid math", () => {
305
318
} ;
306
319
307
320
const html = render ( "$$ +& $$" , { allowMath : true } ) ;
308
- const expected = `<p>$$ +& <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow></mrow><annotation encoding="application/x-tex"></annotation></semantics></math></span><span class="katex-html" aria-hidden="true"></span></span></p>\n` ;
321
+ const expected =
322
+ `<p>$$ +& <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow></mrow><annotation encoding="application/x-tex"></annotation></semantics></math></span><span class="katex-html" aria-hidden="true"></span></span></p>\n` ;
309
323
assertEquals ( html , expected ) ;
310
324
assertStringIncludes (
311
325
warnCalls [ 0 ] ,
@@ -326,7 +340,8 @@ Deno.test("expect console warning from invalid math", () => {
326
340
Deno . test ( "render github-slugger not reused" , function ( ) {
327
341
for ( let i = 0 ; i < 2 ; i ++ ) {
328
342
const html = render ( "## Hello" ) ;
329
- const expected = `<h2 id="hello"><a class="anchor" aria-hidden="true" tabindex="-1" href="#hello"><svg class="octicon octicon-link" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Hello</h2>\n` ;
343
+ const expected =
344
+ `<h2 id="hello"><a class="anchor" aria-hidden="true" tabindex="-1" href="#hello"><svg class="octicon octicon-link" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Hello</h2>\n` ;
330
345
assertEquals ( html , expected ) ;
331
346
}
332
347
} ) ;
@@ -398,7 +413,8 @@ Deno.test("del tag test", () => {
398
413
399
414
Deno . test ( "h1 test" , ( ) => {
400
415
const markdown = "# Hello" ;
401
- const result = `<h1 id="hello"><a class="anchor" aria-hidden="true" tabindex="-1" href="#hello"><svg class="octicon octicon-link" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Hello</h1>\n` ;
416
+ const result =
417
+ `<h1 id="hello"><a class="anchor" aria-hidden="true" tabindex="-1" href="#hello"><svg class="octicon octicon-link" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Hello</h1>\n` ;
402
418
403
419
const html = render ( markdown ) ;
404
420
assertEquals ( html , result ) ;
@@ -427,8 +443,10 @@ Deno.test("task list", () => {
427
443
} ) ;
428
444
429
445
Deno . test ( "anchor test raw" , ( ) => {
430
- const markdown = `<a class="anchor" aria-hidden="true" tabindex="-1" href="#hello">foo</a>` ;
431
- const result = `<p><a class="anchor" aria-hidden="true" tabindex="-1" href="#hello">foo</a></p>\n` ;
446
+ const markdown =
447
+ `<a class="anchor" aria-hidden="true" tabindex="-1" href="#hello">foo</a>` ;
448
+ const result =
449
+ `<p><a class="anchor" aria-hidden="true" tabindex="-1" href="#hello">foo</a></p>\n` ;
432
450
433
451
const html = render ( markdown ) ;
434
452
assertEquals ( html , result ) ;
0 commit comments