Skip to content

fix: emit valid JSX for footprint text with quotes and entities - #551

Open
Flame119052 wants to merge 1 commit into
tscircuit:mainfrom
Flame119052:fix/jsx-text-escaping
Open

fix: emit valid JSX for footprint text with quotes and entities#551
Flame119052 wants to merge 1 commit into
tscircuit:mainfrom
Flame119052:fix/jsx-text-escaping

Conversation

@Flame119052

Copy link
Copy Markdown

Fixes #550.

generateFootprintTsx put JSON.stringify into quoted JSX attributes. That is invalid when the text contains ", and it HTML-decodes & / A instead of keeping the original characters.

Quoted attributes are kept for ordinary text (including {NAME}). Values that need JavaScript escaping or contain & are emitted as a JSX string expression, e.g. text={"Connector 1/4\""}.

Covered for silkscreen, fabrication-note, PCB-note, and dimension labels. Regression compiles the generated footprint with runTscircuitCode and checks the resulting text props.

JSON.stringify inside quoted JSX attributes produced invalid quotes and HTML-decoded entities. Use a JSX string expression when the value needs JS escaping or contains &.
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.

Footprint text with quotes generates invalid TSX; escapes and HTML entities change text

1 participant