@@ -54,7 +54,8 @@ function shouldRegeneratePDF(markdownPath: string, pdfPath: string): boolean {
5454async function generatePDFForFile (
5555 markdownPath : string ,
5656 browser : Browser ,
57- template : string
57+ template : string ,
58+ forceRegenerate : string [ ] = [ ]
5859) : Promise < void > {
5960 const fileName = path . basename ( markdownPath , ".md" ) ;
6061 const dirPath = path . dirname ( markdownPath ) ;
@@ -63,7 +64,8 @@ async function generatePDFForFile(
6364 log ( `Processing: ${ fileName } .md` ) ;
6465
6566 // Check if regeneration is needed
66- if ( ! shouldRegeneratePDF ( markdownPath , pdfPath ) ) {
67+ const shouldForce = forceRegenerate . includes ( fileName ) ;
68+ if ( ! shouldForce && ! shouldRegeneratePDF ( markdownPath , pdfPath ) ) {
6769 log ( `✓ Skipped (no changes): ${ fileName } .pdf` ) ;
6870 return ;
6971 }
@@ -77,9 +79,11 @@ async function generatePDFForFile(
7779
7880 // Process HTML with custom transformations
7981 const styledHtmlContent = processHtml ( htmlContent ) ;
82+ const guideName = markdownContent . split ( "\n" ) [ 0 ] . replace ( "# " , "" ) ;
8083
8184 // Create the complete HTML document with fixed date for determinism
8285 const completeHtml = template
86+ . replace ( "{{guideName}}" , guideName )
8387 . replace ( "{{content}}" , styledHtmlContent )
8488 . replace ( "{{date}}" , "2024-01-01" ) ; // Fixed date for deterministic output
8589
@@ -127,6 +131,7 @@ async function generatePDFForFile(
127131}
128132
129133const main = async ( ) => {
134+ const forceRegenerate = [ "agile" ] ;
130135 try {
131136 log ( "Starting PDF generation for all markdown files..." ) ;
132137
@@ -189,8 +194,16 @@ const main = async () => {
189194 const markdownPath = path . join ( languagePath , markdownFile ) ;
190195 const pdfPath = markdownPath . replace ( ".md" , ".pdf" ) ;
191196
192- if ( shouldRegeneratePDF ( markdownPath , pdfPath ) ) {
193- await generatePDFForFile ( markdownPath , browser , template ) ;
197+ const fileName = path . basename ( markdownFile , ".md" ) ;
198+ const shouldForce = forceRegenerate . includes ( fileName ) ;
199+
200+ if ( shouldForce || shouldRegeneratePDF ( markdownPath , pdfPath ) ) {
201+ await generatePDFForFile (
202+ markdownPath ,
203+ browser ,
204+ template ,
205+ forceRegenerate
206+ ) ;
194207 totalProcessed ++ ;
195208 } else {
196209 totalSkipped ++ ;
0 commit comments