Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape { in user supplied html #408

Merged
merged 10 commits into from
Sep 26, 2023
Merged

Escape { in user supplied html #408

merged 10 commits into from
Sep 26, 2023

Conversation

mishig25
Copy link
Contributor

@mishig25 mishig25 commented Sep 25, 2023

Problem

When there { is within a user supplied html string, it was causing svelte compiler error since { is a reserved character.

Solution

Escape { with {

Description of steps:

  1. When there a html string inside mdsvex files, marked AST parses the outer most tag without without further parsing. For example, <div><p>test</p></div> will be parsed as single node without children. AST playground
  2. Therefore, when there is a html node, parse it further with cheerio and replace { with &#123; within texts
  3. Problem solved

Should fix https://github.com/xenova/transformers.js/actions/runs/6300637437/job/17103917897?pr=320

todos:

@mishig25 mishig25 force-pushed the fix_escaping_inside_html branch from e8c837a to 031eef1 Compare September 25, 2023 21:02
mishig25 added a commit to huggingface/transformers that referenced this pull request Sep 25, 2023
mishig25 pushed a commit to mishig25/transformers.js that referenced this pull request Sep 25, 2023
mishig25 added a commit to huggingface/course that referenced this pull request Sep 26, 2023
@mishig25 mishig25 merged commit ed0bce7 into main Sep 26, 2023
4 checks passed
@mishig25 mishig25 deleted the fix_escaping_inside_html branch September 26, 2023 14:42
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.

1 participant