You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Integrate automatic line-breaking into presentation generation
Changes:
- Apply line-breaking post-processing after Claude generation
- Update prompt to rely on post-processing instead of manual breaks
- Add code source validation to prevent fabricated examples
- Change CSS from pre to pre-wrap for better wrapping behavior
- Log statistics on lines fixed during generation
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
CRITICAL: Add strategic line breaks to prevent horizontal clipping on slides.
150
+
✓ Include natural line breaks in code and text (use \\n for newlines in JSON strings)
151
+
✓ Use standard formatting - post-processing will optimize line lengths automatically
152
+
✓ Preserve semantic meaning and don't break mid-identifier or mid-word
153
+
✓ DO NOT output literal newlines in JSON strings - always use the \\n escape sequence
150
154
151
-
For ALL code examples and prompt text in slides:
152
-
✓ Keep lines under 60 characters for readability in presentation view
153
-
✓ Break at logical points:
154
-
- After commas in parameter lists
155
-
- After operators (&&, ||, =, etc.)
156
-
- After colons in object literals
157
-
- Between method chains (one per line)
158
-
- After opening statements before conditions
159
-
✓ Maintain proper indentation for wrapped lines (2-4 spaces)
160
-
✓ Preserve semantic meaning - don't break mid-identifier or mid-word
161
-
✓ Use \\n escape sequence for line breaks in JSON strings (NOT literal newlines)
155
+
NOTE: Line length optimization (60-char limit) is handled automatically by post-processing.
156
+
Focus on preserving the exact content and structure from the source material.
162
157
163
-
IMPORTANT: Since you're generating JSON output, use \\n for line breaks.
158
+
<CRITICAL_CONSTRAINT>
159
+
SOURCE MATERIAL VERIFICATION
164
160
165
-
When you write the JSON output, use \\n in string literals (escaped backslash-n).
166
-
This will be parsed as a newline character (\n) when the JSON is read.
161
+
Before generating any slide containing code:
162
+
1. Read the source material carefully to locate the code
163
+
2. Verify all code examples exist verbatim in the source markdown
164
+
3. Copy code exactly as it appears - character for character
167
165
168
-
Examples showing what to OUTPUT in your generated JSON:
166
+
ABSOLUTE PROHIBITIONS:
167
+
✗ DO NOT generate hypothetical code examples that aren't in the source
168
+
✗ DO NOT fabricate implementations that "would result" from prompts shown in the lesson
169
+
✗ DO NOT create code to demonstrate "what the AI would produce"
170
+
✗ DO NOT show resulting code unless it explicitly exists in the source markdown
169
171
170
-
BEFORE (too long):
171
-
"Write a TypeScript function that validates email addresses per RFC 5322"
172
+
CORRECT BEHAVIOR:
173
+
✓ If the lesson shows ONLY a prompt example (text describing what to ask AI):
174
+
→ Show the prompt as-is using code/codeComparison type with language: "text"
175
+
→ DO NOT generate the code that would result from that prompt
176
+
→ The prompt itself IS the educational example
172
177
173
-
AFTER (with \\n breaks in the output):
174
-
"Write a TypeScript function that validates\\nemail addresses per RFC 5322"
178
+
✓ If the lesson shows BOTH a prompt AND its resulting code:
179
+
→ Show both exactly as they appear in the source
180
+
→ Verify both exist in the source before including
175
181
176
-
BEFORE (code too long):
177
-
"const result = validateEmail(userInput) && checkDomain(domain) && verifyMX(server);"
182
+
✓ If the lesson shows code WITHOUT a preceding prompt:
183
+
→ Show the code exactly as it appears in the source
184
+
→ Verify it exists before including
178
185
179
-
AFTER (with \\n breaks in the output):
180
-
"const result = validateEmail(userInput) &&\\n checkDomain(domain) &&\\n verifyMX(server);"
186
+
EXAMPLES:
181
187
182
-
Apply strategic line breaks using \\n to:
183
-
- Prompt examples in codeComparison slides (both leftCode and rightCode)
184
-
- Code snippets in code slides
185
-
- Command examples
186
-
- Text content in comparison slides if lines exceed 60 characters
188
+
❌ WRONG - Fabricating implementation:
189
+
Source contains: "Write a TypeScript function that validates email addresses per RFC 5322..."
190
+
Slide shows: Complete validateEmail() function with regex and edge case handling
191
+
Problem: The implementation was FABRICATED - it doesn't exist in the source
187
192
188
-
TECHNICAL NOTE: When you output \\n in a JSON string, it represents an escaped newline.
189
-
After JSON parsing, it becomes a single \n (newline character in the string value).
190
-
DO NOT output literal newlines in JSON strings - always use the \\n escape sequence.
191
-
This prevents horizontal scrolling and ensures all content is visible without clipping.
193
+
✅ CORRECT - Showing only what exists:
194
+
Source contains: "Write a TypeScript function that validates email addresses per RFC 5322..."
195
+
Slide shows: The prompt text only (type: "code", language: "text")
196
+
Result: Authentic prompt example preserved, no fabrication
197
+
198
+
Remember: You are extracting and organizing existing content, NOT generating new examples.
199
+
</CRITICAL_CONSTRAINT>
192
200
193
201
<MANDATORY_RULES>
194
202
CRITICAL: PRESERVING PROMPT EXAMPLES
@@ -262,6 +270,35 @@ COMMON MISTAKE - DO NOT DO THIS:
262
270
263
271
If you see prompt examples in the source (text showing what to write to an AI), you MUST use "code" or "codeComparison" slide types. NEVER use "concept" with bullet points for prompts.
264
272
273
+
<VERIFICATION_PROTOCOL>
274
+
CHAIN-OF-THOUGHT FOR CODE SLIDES
275
+
276
+
For each code example you consider including in a slide, follow this verification process:
277
+
278
+
Step 1: LOCATE - Where does this code appear in the source material?
279
+
→ Identify the section and approximate line range
280
+
→ If you cannot find it, STOP - do not include this code
281
+
282
+
Step 2: EXTRACT - Copy the exact text from the source
283
+
→ Character-by-character match
284
+
→ Preserve all whitespace, formatting, and syntax
285
+
286
+
Step 3: VERIFY - Does your extracted code match what you're about to include?
287
+
→ Compare character by character
288
+
→ If there's any mismatch, re-extract from source
289
+
290
+
Step 4: CONFIRM - Is this code explicitly in the source, or did you generate it?
291
+
→ If you generated it (even to "demonstrate" something), DELETE IT
292
+
→ Only include code that passed Steps 1-3
293
+
294
+
Apply this process to:
295
+
- Every "code" slide
296
+
- Every "codeComparison" leftCode and rightCode
297
+
- Every "codeExecution" step that contains code
298
+
299
+
This verification prevents fabrication and ensures educational integrity.
300
+
</VERIFICATION_PROTOCOL>
301
+
265
302
COMPONENT DETECTION (CRITICAL):
266
303
267
304
The source content contains markers for visual React components in the format:
@@ -376,11 +413,21 @@ SPEAKER NOTES GUIDELINES:
376
413
377
414
For each slide, provide speaker notes with:
378
415
1. **Talking points**: What to say (2-4 sentences)
416
+
✓ Explain what IS shown on the slide
417
+
✗ Do NOT describe "what the model would generate" for prompts
418
+
✗ Do NOT fabricate hypothetical outcomes or implementations
379
419
2. **Timing**: Estimated time to spend (e.g., "2 minutes")
380
420
3. **Discussion prompts**: Questions to engage students
381
421
4. **Real-world context**: Production scenarios to reference
382
422
5. **Transition**: How to move to next slide
383
423
424
+
CRITICAL CONSTRAINTS FOR SPEAKER NOTES:
425
+
✗ NEVER say "Notice what the model generated" when showing prompt examples alone
426
+
✗ NEVER describe hypothetical code that would result from a prompt (unless that code exists in the source)
427
+
✗ NEVER fabricate examples or scenarios not present in the source material
428
+
✓ Focus on explaining the content that IS on the slide
429
+
✓ Reference only examples and code that exist in the source
430
+
384
431
Example speaker notes:
385
432
\`\`\`
386
433
Talking points: This slide shows the difference between vague and specific prompts. The vague version gives no context, forcing the AI to guess. The specific version provides language, standard, edge cases, and return type.
@@ -674,7 +721,22 @@ async function generatePresentationWithClaude(prompt, outputPath) {
0 commit comments