File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ import test from 'node:test' ;
2+ import assert from 'node:assert/strict' ;
3+
4+ import { transformContent } from '../transform.mjs' ;
5+
6+ const stripFrontmatter = ( content ) => content . replace ( / ^ - - - [ \s \S ] * ?- - - \n \n / , '' ) ;
7+
8+ test ( 'compare callout preserves inline markup' , ( ) => {
9+ const input = `# Title\n\n<p><span class="compare-better">Better —</span> Keep <code>foo</code> and <a href="https://example.com">link</a>.</p>` ;
10+ const output = stripFrontmatter ( transformContent ( input ) ) ;
11+
12+ assert . ok ( output . includes ( '<Callout type="success" title="Better">' ) ) ;
13+ assert . ok ( output . includes ( '`foo`' ) ) ;
14+ assert . ok ( output . includes ( '[link](https://example.com)' ) ) ;
15+ assert . ok ( output . includes ( '</Callout>' ) ) ;
16+ } ) ;
17+
18+ test ( 'compare list items retain trailing content' , ( ) => {
19+ const input = `# Title\n\n<ul><li><span class="compare-worse">Worse</span> <em>still works</em></li></ul>` ;
20+ const output = stripFrontmatter ( transformContent ( input ) ) ;
21+
22+ assert . ok ( output . includes ( '- ⚠️ Worse: ' ) ) ;
23+ assert . ok ( output . includes ( '*still works*' ) ) ;
24+ } ) ;
25+
26+ test ( 'braces are readable and escaped for MDX' , ( ) => {
27+ const input = '# Title\n\nExample {\'cpu\': \'ppc\'}' ;
28+ const output = stripFrontmatter ( transformContent ( input ) ) ;
29+
30+ assert . ok ( output . includes ( "Example \\{'cpu': 'ppc'\\}" ) ) ;
31+ } ) ;
You can’t perform that action at this time.
0 commit comments