@@ -722,21 +722,11 @@ async function generatePresentationWithClaude(prompt, outputPath) {
722722
723723 console . log ( ` ✅ Valid presentation JSON (${ presentation . slides . length } slides)` ) ;
724724
725- // Apply deterministic line breaking
726- console . log ( ' 🔧 Applying line breaking...' ) ;
727- const { presentation : processedPresentation , stats } = processPresentation ( presentation ) ;
728-
729- // Log statistics
730- if ( stats . linesShortened > 0 ) {
731- console . log ( ` ✂️ Fixed ${ stats . linesShortened } long lines (max reduction: ${ stats . maxReduction } chars)` ) ;
732- } else {
733- console . log ( ' ✅ No lines exceeded 60 characters' ) ;
734- }
735-
736- // Write back the processed presentation
737- writeFileSync ( outputPath , JSON . stringify ( processedPresentation , null , 2 ) , 'utf-8' ) ;
725+ // Write the unmodified presentation to file for validation
726+ // Line breaking will happen after validation passes
727+ writeFileSync ( outputPath , JSON . stringify ( presentation , null , 2 ) , 'utf-8' ) ;
738728
739- resolve ( processedPresentation ) ;
729+ resolve ( presentation ) ;
740730 } catch ( parseError ) {
741731 reject ( new Error ( `Failed to parse JSON: ${ parseError . message } \nContent preview: ${ fileContent ?. slice ( 0 , 200 ) } ` ) ) ;
742732 return ;
@@ -1181,8 +1171,8 @@ async function generatePresentation(filePath, manifest, config) {
11811171 console . log ( `\n📄 Generating presentation: ${ relativePath } ` ) ;
11821172
11831173 try {
1184- // Parse content
1185- const content = parseMarkdownContent ( filePath ) ;
1174+ // Parse content (preserve code blocks for visual presentation)
1175+ const content = parseMarkdownContent ( filePath , true ) ;
11861176
11871177 if ( content . length < 100 ) {
11881178 console . log ( ` ⚠️ Skipping - content too short` ) ;
@@ -1297,24 +1287,38 @@ async function generatePresentation(filePath, manifest, config) {
12971287 console . log ( ` ✅ All ${ codeSourceValidation . codeSlidesChecked } code slide(s) verified against source` ) ;
12981288 }
12991289
1290+ // Apply deterministic line breaking (AFTER validation passes)
1291+ console . log ( ' 🔧 Applying line breaking...' ) ;
1292+ const { presentation : processedPresentation , stats } = processPresentation ( presentation ) ;
1293+
1294+ // Log statistics
1295+ if ( stats . linesShortened > 0 ) {
1296+ console . log ( ` ✂️ Fixed ${ stats . linesShortened } long lines (max reduction: ${ stats . maxReduction } chars)` ) ;
1297+ } else {
1298+ console . log ( ' ✅ No lines exceeded 60 characters' ) ;
1299+ }
1300+
1301+ // Write the line-broken version back to output file
1302+ writeFileSync ( outputPath , JSON . stringify ( processedPresentation , null , 2 ) , 'utf-8' ) ;
1303+
13001304 // Copy to static directory for deployment
13011305 const staticPath = join ( STATIC_OUTPUT_DIR , dirname ( relativePath ) , outputFileName ) ;
13021306 mkdirSync ( dirname ( staticPath ) , { recursive : true } ) ;
1303- writeFileSync ( staticPath , JSON . stringify ( presentation , null , 2 ) , 'utf-8' ) ;
1307+ writeFileSync ( staticPath , JSON . stringify ( processedPresentation , null , 2 ) , 'utf-8' ) ;
13041308
13051309 // Update manifest
13061310 const presentationUrl = `/presentations/${ join ( dirname ( relativePath ) , outputFileName ) } ` ;
13071311 manifest [ relativePath ] = {
13081312 presentationUrl,
1309- slideCount : presentation . slides . length ,
1310- estimatedDuration : presentation . metadata . estimatedDuration ,
1311- title : presentation . metadata . title ,
1313+ slideCount : processedPresentation . slides . length ,
1314+ estimatedDuration : processedPresentation . metadata . estimatedDuration ,
1315+ title : processedPresentation . metadata . title ,
13121316 generatedAt : new Date ( ) . toISOString ( )
13131317 } ;
13141318
13151319 console . log ( ` ✅ Generated: ${ presentationUrl } ` ) ;
1316- console . log ( ` 📊 Slides: ${ presentation . slides . length } ` ) ;
1317- console . log ( ` ⏱️ Duration: ${ presentation . metadata . estimatedDuration } ` ) ;
1320+ console . log ( ` 📊 Slides: ${ processedPresentation . slides . length } ` ) ;
1321+ console . log ( ` ⏱️ Duration: ${ processedPresentation . metadata . estimatedDuration } ` ) ;
13181322
13191323 return outputPath ;
13201324
0 commit comments