stripFences opens a fence mid line, so some responses render nothing

Open
#1,440 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
backend

Research direction

Start with packages/lang-core/src/parser/parser.ts and compare stripFences with the fence rules in spec/language.md §1.2. Reproduce the cases using createParser(schema).parse(text) and the schema in spec/fixtures/1.0/library.json; check the streaming parser too. Done means each example produces a Stack with its Text child and no longer returns a blank response.

Written by the indexing model from the issue text.

Description

Describe the bug
stripFences in lang-core (packages/lang-core/src/parser/parser.ts) treats three backticks anywhere on a line as an opening fence, and skips over double quoted text even in prose outside fences... When that happens the program gets cut up and the whole response renders blank. No error is reported.

Spec 1.0 (spec/language.md, §1.2) says a fence opens only at the start of a line, and that quotes in prose outside fences don't shield anything.

To Reproduce
Parse either of these with createParser(schema).parse(text), using the schema from spec/fixtures/1.0/library.json:

  1. A stray " in prose before the fence:
Here is a 12" pizza card:
```
root = Stack([a])
a = Text("Pizza")
```
  1. Backticks mentioned mid-line in prose:
Tip: use ```js for code.
```
root = Stack([a])
a = Text("ok")
```

Two more cases that render nothing:

  • a = Text('Wrap code in ``` fences') with no fences
  • root = Stack([a]) // fenced with ``` with no fences (this one gives no-root)

Expected behavior
Each one renders Stack with its Text child, as the spec describes.

Actual behavior
root is null and errors is empty, so the user sees a blank response. The streaming parser gives the same result.

Environment

  • Package: @openuidev/lang-core 1.0.1 (main @ c0e6b0f9)
  • Node 22

Additional context
Happy to send a fix with tests if this direction sounds right

Dominant language
TypeScript
Stars
10k
Forks
698
Avg merge
1d 3h
Merged PRs (30d)
133

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from thesysdev/openui

All issues in thesysdev/openui

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.