@@ -49,15 +49,18 @@ export function markdowntoHTML(
4949 . use ( removeComments )
5050 . use ( convertFileEmbeds )
5151 . use ( remarkRehype , { allowDangerousHtml : options . allowDangerousHtml } )
52- . use ( escapeCode , { encodeHtmlEntities : options . encodeHtmlEntities } )
52+ . use ( escapeCode )
5353 . use ( fixChecklistClasses )
5454 . use ( liftLanguageToPreFromCode )
5555 . use ( collapseMultilineParagraphs )
5656 . use ( rehypeStringify , {
5757 allowDangerousHtml : options . allowDangerousHtml ,
5858 tightSelfClosing : true ,
5959 closeSelfClosing : true ,
60- closeEmptyElements : true
60+ closeEmptyElements : true ,
61+ characterReferences : {
62+ useShortestReferences : true
63+ }
6164 } )
6265 . processSync ( src ) ;
6366 return result . value as string ;
@@ -188,32 +191,31 @@ const remarkHighlight: () => Transformer = () => (tree) => {
188191 const children : Node < Data > [ ] = values . map ( ( str , i ) =>
189192 i % 2 === 0
190193 ? {
191- type : "text" ,
192- value : str
193- }
194+ type : "text" ,
195+ value : str
196+ }
194197 : {
195- type : "highlight" ,
196- data : {
197- hName : "span" ,
198- hProperties : {
199- style : `background-color: rgb(255, 255, 0);`
200- }
201- } ,
202- children : [
203- {
204- type : "text" ,
205- value : str
206- }
207- ]
208- }
198+ type : "highlight" ,
199+ data : {
200+ hName : "span" ,
201+ hProperties : {
202+ style : `background-color: rgb(255, 255, 0);`
203+ }
204+ } ,
205+ children : [
206+ {
207+ type : "text" ,
208+ value : str
209+ }
210+ ]
211+ }
209212 ) ;
210213 ( parent as Parent ) . children . splice ( index ! , 1 , ...children ) ;
211214 return [ "skip" , index ] ;
212215 } ) ;
213216} ;
214217
215- const escapeCode : Plugin < [ { encodeHtmlEntities ?: boolean } ?] , HastRoot , HastRoot > = function ( options = { } ) {
216- const { encodeHtmlEntities = true } = options ;
218+ const escapeCode : Plugin < [ ] , HastRoot , HastRoot > = function ( ) {
217219 return ( tree : HastRoot ) => {
218220 visit ( tree , "element" , ( node ) => {
219221 if ( ! isElement ( node , "code" ) ) return ;
@@ -224,7 +226,7 @@ const escapeCode: Plugin<[{ encodeHtmlEntities?: boolean }?], HastRoot, HastRoot
224226 lines . forEach ( ( line , i ) => {
225227 children . push ( {
226228 type : "text" ,
227- value : encodeHtmlEntities ? encodeNonAsciiHTML ( line ) : line
229+ value : line
228230 } ) ;
229231 if ( i !== lines . length - 1 )
230232 children . push ( {
0 commit comments