benjamn / benjamn/recast

prettyPrint renders HTML entities in JSX

Open
#213 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
5.3k
Forks
364
Avg merge
3d 8h
Merged PRs (30d)
3

Description

When pretty printing JSX with HTML entities, the entities are rendered as their display character instead of the source.

`print` works as expected -

``` javascript
recast.print(recast.parse('<'));
// <'
```

`prettyPrint` breaks the output -

``` javascript
recast.prettyPrint(recast.parse('<'));
// '<;'
```

We are using recast to make AST transforms and convert back to code using prettyPrint. Having `lt;` transformed to `<` breaks the subsequent JSX parsing.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the issue with the provided recast.parse, print, and prettyPrint JSX examples, then start at the prettyPrint entry point and trace how the HTML entity is handled. Done means prettyPrint preserves the source entity so the generated JSX can be parsed again without changing it to its display character.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.