@@ -3,6 +3,7 @@ import { module, test } from 'qunit';
3
3
import { stripIndent } from 'common-tags' ;
4
4
import { invocationOf , nameFor } from 'ember-repl' ;
5
5
import { parseMarkdown } from 'ember-repl/formats/markdown' ;
6
+ import { visit } from 'unist-util-visit' ;
6
7
7
8
/**
8
9
* NOTE: there is a problem(?) with remark-hbs where all extra newlines and
@@ -66,8 +67,68 @@ module('Unit | parseMarkdown()', function () {
66
67
assert . deepEqual ( result . blocks , [ ] ) ;
67
68
} ) ;
68
69
70
+ module ( 'plugin options' , function ( ) {
71
+ test ( 'remarkPlugins' , async function ( assert ) {
72
+ let result = await parseMarkdown ( `# Title` , {
73
+ remarkPlugins : [
74
+ function noH1 ( /* options */ ) {
75
+ return ( tree ) => {
76
+ return visit ( tree , [ 'heading' ] , function ( node ) {
77
+ if ( ! ( 'depth' in node ) ) return ;
78
+
79
+ if ( node . depth === 1 ) {
80
+ node . depth = 2 ;
81
+ }
82
+
83
+ return 'skip' ;
84
+ } ) ;
85
+ } ;
86
+ } ,
87
+ ] ,
88
+ } ) ;
89
+
90
+ assertOutput (
91
+ result . templateOnlyGlimdown ,
92
+ stripIndent `
93
+ <h2>Title</h2>
94
+ `
95
+ ) ;
96
+
97
+ assert . deepEqual ( result . blocks , [ ] ) ;
98
+ } ) ;
99
+
100
+ test ( 'rehypePlugins' , async function ( assert ) {
101
+ let result = await parseMarkdown ( `# Title` , {
102
+ rehypePlugins : [
103
+ function noH1 ( /* options */ ) {
104
+ return ( tree ) => {
105
+ return visit ( tree , [ 'element' ] , function ( node ) {
106
+ if ( ! ( 'tagName' in node ) ) return ;
107
+
108
+ if ( node . tagName === 'h1' ) {
109
+ node . tagName = 'h2' ;
110
+ }
111
+
112
+ return 'skip' ;
113
+ } ) ;
114
+ } ;
115
+ } ,
116
+ ] ,
117
+ } ) ;
118
+
119
+ assertOutput (
120
+ result . templateOnlyGlimdown ,
121
+ stripIndent `
122
+ <h2>Title</h2>
123
+ `
124
+ ) ;
125
+
126
+ assert . deepEqual ( result . blocks , [ ] ) ;
127
+ } ) ;
128
+ } ) ;
129
+
69
130
module ( 'hbs' , function ( ) {
70
- test ( 'Code fence is live' , async function ( assert ) {
131
+ test ( 'Codecontainer fence is live' , async function ( assert ) {
71
132
let snippet = `{{concat "hello" " " "there"}}` ;
72
133
let name = nameFor ( snippet ) ;
73
134
let result = await parseMarkdown (
0 commit comments