Skip to content

Fix undefined variable in README example code#62

Closed
hobostay wants to merge 1 commit intochenglou:mainfrom
hobostay:fix-readme-textwidth-variable
Closed

Fix undefined variable in README example code#62
hobostay wants to merge 1 commit intochenglou:mainfrom
hobostay:fix-readme-textwidth-variable

Conversation

@hobostay
Copy link
Copy Markdown
Contributor

Problem

The example code in the "Measure a paragraph's height" section (line 28) used an undefined variable textWidth:

const { height, lineCount } = layout(prepared, textWidth, 20)

This would cause a ReferenceError: textWidth is not defined if someone tries to run this code directly.

Solution

Changed the undefined variable to a concrete value (320) to match the other examples in the documentation that use 320px as the max width:

const { height, lineCount } = layout(prepared, 320, 20)

This makes the example code immediately runnable without modification.

Testing

The fix is purely documentation-only. No code changes were made.

The example code in the "Measure a paragraph's height" section used an
undefined variable `textWidth` which would cause a ReferenceError if run.
Changed it to a concrete value (320) matching the other examples in the doc.
chenglou added a commit that referenced this pull request Apr 18, 2026
Refs #28, #30, #62, #91, #95, #107, #125, #128.

Co-authored-by: Wen-Wei Feng <wen-wei.feng@hp.com>
Co-authored-by: 陈家名 <chenjiaming@kezaihui.com>
Co-authored-by: Qiaochu Hu <110hqc@gmail.com>
Co-authored-by: Nipun Sujesh <198955998+Luc0-0@users.noreply.github.com>
Co-authored-by: Ben George <bengeorge1001@gmail.com>
@chenglou
Copy link
Copy Markdown
Owner

Thanks! I folded this into cca3f1d and credited you as co-author.

@chenglou chenglou closed this Apr 18, 2026
nice-hang pushed a commit to nice-hang/pretext that referenced this pull request Apr 18, 2026
Refs chenglou#28, chenglou#30, chenglou#62, chenglou#91, chenglou#95, chenglou#107, chenglou#125, chenglou#128.

Co-authored-by: Wen-Wei Feng <wen-wei.feng@hp.com>
Co-authored-by: 陈家名 <chenjiaming@kezaihui.com>
Co-authored-by: Qiaochu Hu <110hqc@gmail.com>
Co-authored-by: Nipun Sujesh <198955998+Luc0-0@users.noreply.github.com>
Co-authored-by: Ben George <bengeorge1001@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants