File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ export function showSidebarContent(d, fromHover = false) {
4949 // Helper to render tab content
5050 function renderSidebarTabContent ( tabName , d , children ) {
5151 if ( tabName === 'Code' ) {
52- return `<pre class="sidebar-code-pre">${ d . code } </pre>` ;
52+ return `<pre class="sidebar-code-pre">${ escapeHtml ( d . code ) } </pre>` ;
5353 }
5454 if ( tabName === 'Prompts' ) {
5555 // Prompt select logic
@@ -328,4 +328,15 @@ export function openInNewTab(event, d) {
328328
329329export function setSidebarSticky ( val ) {
330330 sidebarSticky = val ;
331+ }
332+
333+ // Helper to escape HTML so code can be shown verbatim inside <pre>
334+ function escapeHtml ( str ) {
335+ if ( str === undefined || str === null ) return '' ;
336+ return String ( str )
337+ . replace ( / & / g, '&' )
338+ . replace ( / < / g, '<' )
339+ . replace ( / > / g, '>' )
340+ . replace ( / " / g, '"' )
341+ . replace ( / ' / g, ''' ) ;
331342}
You can’t perform that action at this time.
0 commit comments