@@ -169,6 +169,8 @@ function pageEventEnd(event: PageEvent<DeclarationReflection>) {
169169class TauriThemeRenderContext extends MarkdownThemeContext {
170170 constructor ( theme : MarkdownTheme , page : MarkdownPageEvent < Reflection > , options : Options ) {
171171 super ( theme , page , options ) ;
172+ const originalCommentPartial = this . partials . comment ;
173+
172174 this . partials = {
173175 ...this . partials ,
174176 // Formats `@source` to be a single line
@@ -180,6 +182,37 @@ class TauriThemeRenderContext extends MarkdownThemeContext {
180182 const sources = model . sources . map ( ( source ) => `${ source . url } ` ) ;
181183 return label + sources . join ( ', ' ) ;
182184 } ,
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+ } ,
183216 } ;
184217 }
185218
0 commit comments