@@ -169,6 +169,8 @@ function pageEventEnd(event: PageEvent<DeclarationReflection>) {
169
169
class TauriThemeRenderContext extends MarkdownThemeContext {
170
170
constructor ( theme : MarkdownTheme , page : MarkdownPageEvent < Reflection > , options : Options ) {
171
171
super ( theme , page , options ) ;
172
+ const originalCommentPartial = this . partials . comment ;
173
+
172
174
this . partials = {
173
175
...this . partials ,
174
176
// Formats `@source` to be a single line
@@ -180,6 +182,37 @@ class TauriThemeRenderContext extends MarkdownThemeContext {
180
182
const sources = model . sources . map ( ( source ) => `${ source . url } ` ) ;
181
183
return label + sources . join ( ', ' ) ;
182
184
} ,
185
+ // Remove heading markers from JSDoc comments to prevent accidental markdown headings
186
+ comment : function ( comment , options ) {
187
+ const headingStringsToReplace = [
188
+ // known to break
189
+ '#### Platform-specific' ,
190
+ // just to be sure
191
+ '### Platform-specific' ,
192
+ ] ;
193
+
194
+ if ( comment ?. summary ) {
195
+ comment . summary . forEach ( ( line ) => {
196
+ if ( line . kind === 'text' && typeof line . text === 'string' ) {
197
+ headingStringsToReplace . forEach ( ( headingString ) => {
198
+ line . text = line . text . replace ( headingString , headingString . replace ( / ^ # + \s * / , '' ) ) ;
199
+ } ) ;
200
+ }
201
+ } ) ;
202
+ }
203
+ if ( comment ?. blockTags ) {
204
+ comment . blockTags . forEach ( ( tag ) => {
205
+ tag . content . forEach ( ( line ) => {
206
+ if ( line . kind === 'text' && typeof line . text === 'string' ) {
207
+ headingStringsToReplace . forEach ( ( headingString ) => {
208
+ line . text = line . text . replace ( headingString , headingString . replace ( / ^ # + \s * / , '' ) ) ;
209
+ } ) ;
210
+ }
211
+ } ) ;
212
+ } ) ;
213
+ }
214
+ return originalCommentPartial . call ( this , comment , options ) ;
215
+ } ,
183
216
} ;
184
217
}
185
218
0 commit comments