File tree Expand file tree Collapse file tree 3 files changed +83
-1
lines changed Expand file tree Collapse file tree 3 files changed +83
-1
lines changed Original file line number Diff line number Diff line change @@ -143,6 +143,19 @@ const CODE_SPAN_MARKDOWN = `
143
143
This has some \`inline code\` to see.
144
144
` ;
145
145
146
+ const CODE_SPAN_ADVANCED_MARKDOWN = `
147
+ This has some \`inline code that "contains" html 'entities' and <other></other>\`
148
+
149
+ Some other html entities:
150
+
151
+ - \`¢\` cent
152
+ - \`£\` pound
153
+ - \`¥\` yen
154
+ - \`€\` euro
155
+ - \`©\` copyright
156
+ - \`®\` registered trademark
157
+ ` ;
158
+
146
159
const UNORDERED_LIST_MARKDOWN = `
147
160
- Item 1
148
161
- Item 2
@@ -450,6 +463,17 @@ describe("Markdown", () => {
450
463
expect ( container ) . toMatchSnapshot ( ) ;
451
464
} ) ;
452
465
466
+ it ( "should be able to render inline code that has html entities" , ( ) => {
467
+ const { container } = render (
468
+ < Markdown markdown = { CODE_SPAN_ADVANCED_MARKDOWN } />
469
+ ) ;
470
+
471
+ expect ( container . textContent ) . not . toMatch (
472
+ / & ( q u o t | l t | g t | a m p | c e n t | p o u n d | y e n | e u r o | c o p y | r e g ) ; /
473
+ ) ;
474
+ expect ( container ) . toMatchSnapshot ( ) ;
475
+ } ) ;
476
+
453
477
it ( "should be able to highlight code with the highlightCode option" , ( ) => {
454
478
const getLanguage : GetCodeLanguage = ( lang ) => {
455
479
lang = lang === "sh" ? "bash" : lang ;
Original file line number Diff line number Diff line change @@ -296,6 +296,60 @@ exports[`Markdown should be able to render inline code 1`] = `
296
296
</div >
297
297
`;
298
298
299
+ exports[`Markdown should be able to render inline code that has html entities 1`] = `
300
+ <div >
301
+ <p >
302
+ This has some
303
+ <code >
304
+ inline code that "contains" html 'entities' and < other>< /other>
305
+ </code >
306
+ </p >
307
+
308
+ <p >
309
+ Some other html entities:
310
+ </p >
311
+
312
+ <ul >
313
+ <li >
314
+ <code >
315
+ ¢
316
+ </code >
317
+ cent
318
+ </li >
319
+ <li >
320
+ <code >
321
+ £
322
+ </code >
323
+ pound
324
+ </li >
325
+ <li >
326
+ <code >
327
+ ¥
328
+ </code >
329
+ yen
330
+ </li >
331
+ <li >
332
+ <code >
333
+ €
334
+ </code >
335
+ euro
336
+ </li >
337
+ <li >
338
+ <code >
339
+ ©
340
+ </code >
341
+ copyright
342
+ </li >
343
+ <li >
344
+ <code >
345
+ ®
346
+ </code >
347
+ registered trademark
348
+ </li >
349
+ </ul >
350
+ </div >
351
+ `;
352
+
299
353
exports[`Markdown should be able to render links that reference specific ids 1`] = `
300
354
<div >
301
355
<p >
Original file line number Diff line number Diff line change @@ -120,7 +120,11 @@ export function TokenRenderer({
120
120
</ Code >
121
121
) ;
122
122
case "codespan" :
123
- return < Codespan { ...token } > { token . text } </ Codespan > ;
123
+ return (
124
+ < Codespan { ...token } >
125
+ { token . raw . substring ( 1 , token . raw . length - 1 ) }
126
+ </ Codespan >
127
+ ) ;
124
128
case "heading" : {
125
129
const { depth, ...props } = token ;
126
130
return (
You can’t perform that action at this time.
0 commit comments