@@ -78,3 +78,41 @@ renderFile(
7878
7979// all-anchors.adoc uses include:: directives — resolved automatically in Node.js
8080renderFile ( path . join ( ROOT , 'docs/all-anchors.adoc' ) , path . join ( WEB_DOCS , 'all-anchors.html' ) )
81+
82+ // Pre-rendered HTML docs (no .adoc source available) — copy with link rewriting
83+ function copyHtmlDoc ( srcPath , destPath ) {
84+ if ( ! fs . existsSync ( srcPath ) ) return
85+ try {
86+ fs . mkdirSync ( path . dirname ( destPath ) , { recursive : true } )
87+ let html = fs . readFileSync ( srcPath , 'utf-8' )
88+ // Extract content from full HTML page (between <div id="content"> and <div id="footer">)
89+ const contentStart = html . indexOf ( '<div id="content">' )
90+ const contentEnd = html . indexOf ( '<div id="footer">' )
91+ if ( contentStart !== - 1 ) {
92+ const titleMatch = html . match ( / < h 1 > ( .* ?) < \/ h 1 > / )
93+ const title = titleMatch ? titleMatch [ 1 ] : ''
94+ const content = html . slice ( contentStart , contentEnd !== - 1 ? contentEnd : undefined ) . trim ( )
95+ html = `<h1>${ title } </h1>\n${ content } `
96+ }
97+ // Convert absolute Semantic Anchors links to relative hash links
98+ html = html . replace (
99+ / h t t p s : \/ \/ l l m - c o d i n g \. g i t h u b \. i o \/ S e m a n t i c - A n c h o r s \/ # \/ a n c h o r \/ / g,
100+ '#/anchor/'
101+ )
102+ html = html . replace ( / h t t p s : \/ \/ l l m - c o d i n g \. g i t h u b \. i o \/ S e m a n t i c - A n c h o r s \/ / g, '#/' )
103+ fs . writeFileSync ( destPath , html , 'utf-8' )
104+ console . log ( `Copied: ${ path . relative ( ROOT , destPath ) } ` )
105+ } catch ( err ) {
106+ console . error ( `Failed to copy ${ path . relative ( ROOT , srcPath ) } :` , err . message )
107+ process . exit ( 1 )
108+ }
109+ }
110+
111+ copyHtmlDoc (
112+ path . join ( ROOT , 'docs/spec-driven-workflow.html' ) ,
113+ path . join ( WEB_DOCS , 'spec-driven-workflow.html' )
114+ )
115+ copyHtmlDoc (
116+ path . join ( ROOT , 'docs/spec-driven-workflow.de.html' ) ,
117+ path . join ( WEB_DOCS , 'spec-driven-workflow.de.html' )
118+ )
0 commit comments