@@ -16,6 +16,14 @@ interface AnimatedTerminalProps {
1616function dedentAndSplit ( text : string ) : string [ ] {
1717 const lines = text . split ( "\n" ) ;
1818
19+ // Trim leading and trailing empty lines
20+ while ( lines . length > 0 && lines [ 0 ] . trim ( ) . length === 0 ) {
21+ lines . shift ( ) ;
22+ }
23+ while ( lines . length > 0 && lines [ lines . length - 1 ] . trim ( ) . length === 0 ) {
24+ lines . pop ( ) ;
25+ }
26+
1927 // Find the minimum indentation (excluding empty lines)
2028 let minIndent = Infinity ;
2129 for ( const line of lines ) {
@@ -91,15 +99,14 @@ const getExamples = (version: string = "9.8.0"): TerminalExample[] => [
9199 $ ipython
92100 IPython ${ version } -- An enhanced Interactive Python
93101
94- # we will use await at top level !
95-
96- In [1]: import asyncio
102+ In [1]: # we will use await at top level !
103+ ...: import asyncio
97104
98105 In [2]: async def fetch_data():
99106 ...: await asyncio.sleep(0.1)
100107 ...: return "Data fetched!"
101108 ...:
102-
109+
103110 In [3]: await fetch_data()
104111 Out[3]: 'Data fetched!'
105112
@@ -109,7 +116,6 @@ const getExamples = (version: string = "9.8.0"): TerminalExample[] => [
109116 ...: await asyncio.sleep(0.05)
110117 ...: results.append(item * 2)
111118 ...: return results
112- ...:
113119
114120 In [5]: await process_items([1, 2, 3])
115121 Out[5]: [2, 4, 6]
@@ -263,9 +269,9 @@ export default function AnimatedTerminal({ version }: AnimatedTerminalProps) {
263269
264270 // Calculate max height based on the longest example
265271 const maxLines = Math . max ( ...examples . map ( ( ex ) => ex . lines . length ) ) ;
266- const lineHeight = 1.5 ; // rem (24px for text-sm)
267- const padding = 1.5 * 2 ; // rem (top + bottom padding)
268- const controlsHeight = 2.5 ; // rem (window controls height)
272+ const lineHeight = 1.25 ; // rem (20px for text-sm)
273+ const padding = 1 * 2 ; // rem (top + bottom padding)
274+ const controlsHeight = 2 ; // rem (window controls height)
269275 const minHeight = `${ maxLines * lineHeight + padding + controlsHeight } rem` ;
270276
271277 return (
@@ -282,7 +288,7 @@ export default function AnimatedTerminal({ version }: AnimatedTerminalProps) {
282288 </ div >
283289
284290 { /* Terminal Content */ }
285- < div className = "p-6 whitespace-pre" >
291+ < div className = "p-3 whitespace-pre" >
286292 { displayedLines . map ( ( line , index ) => {
287293 const { prefix, content, prefixColor } = getLinePrefix ( line ) ;
288294 const lineColor = getLineColor ( line ) ;
0 commit comments