fix: escape pipe in enum member value table cell#141
Open
greymoth-jp wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The
Memberstable generated for an enum prints each member's initializervalue straight from
initializerExcerpt.textwithout escaping it:When the initializer contains a pipe, that raw
|adds an extra column to therow. For a flags enum such as:
the
ReadWriterow becomes| ReadWrite | Read | Write | ... |, which has fourcells against a three-column header. GitHub-Flavored Markdown then splits the
value (
Read/Write) and pushes the Description out of the row, so thetable loses data.
Fix
The parameters table already escapes its excerpt before putting it in a cell.
The
Typecolumn runsp.parameterTypeExcerpt.textthroughescapeTextForTablefor exactly this reason (union types contain pipes too).This change routes the enum value column through the same helper so both
columns escape consistently.
escapeTextForTablemaps|to|, whichrenders as a literal pipe and keeps the row at three cells.
Tests
test/enum-pipe.test.tswith a fixture whose member initializer isRead | Write, asserting the value stays in one cell and the descriptionsurvives.
way the
Typecolumn already does, so"%"becomes"%"(thesame treatment as
DumbType<T>).npm run lintand the unit tests pass.