@@ -202,6 +202,24 @@ export function translateParagraphNode(params) {
202202 return result ;
203203}
204204
205+ /**
206+ * Normalize line height values
207+ * This function converts line height values from strings with percentage to a decimal value.
208+ * For example, "150%" becomes 1.5.
209+ * If the value is not a valid number, it returns null.
210+ * @param {string|number } value The line height value to normalize
211+ * @return {number|null } The normalized line height value or null if invalid
212+ */
213+ function normalizeLineHeight ( value ) {
214+ if ( typeof value === 'string' && value . trim ( ) . endsWith ( '%' ) ) {
215+ const parsed = parseFloat ( value ) ;
216+ return Number . isFinite ( parsed ) ? parsed / 100 : null ;
217+ }
218+
219+ const parsed = parseFloat ( value ) ;
220+ return Number . isFinite ( parsed ) ? parsed : null ;
221+ }
222+
205223/**
206224 * Generate the w:pPr props for a paragraph node
207225 *
@@ -226,9 +244,13 @@ function generateParagraphProperties(node) {
226244 if ( lineSpaceBefore >= 0 ) attributes [ 'w:before' ] = pixelsToTwips ( lineSpaceBefore ) ;
227245 if ( lineSpaceAfter >= 0 ) attributes [ 'w:after' ] = pixelsToTwips ( lineSpaceAfter ) ;
228246
229- if ( lineHeight && ! Number . isNaN ( parseFloat ( lineHeight ) ) ) {
230- if ( lineRule === 'exact' ) attributes [ 'w:line' ] = ptToTwips ( parseFloat ( lineHeight ) ) ;
231- else attributes [ 'w:line' ] = linesToTwips ( lineHeight ) ;
247+ const normalized = normalizeLineHeight ( lineHeight ) ;
248+ if ( normalized !== null ) {
249+ if ( lineRule === 'exact' ) {
250+ attributes [ 'w:line' ] = ptToTwips ( normalized ) ;
251+ } else {
252+ attributes [ 'w:line' ] = linesToTwips ( normalized ) ;
253+ }
232254 }
233255
234256 attributes [ 'w:lineRule' ] = lineRule || 'auto' ;
0 commit comments