unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.75k stars 269 forks source link

Single backtick syntax for monospace does not render inside parenthesis #4777

Closed rlmark closed 2 months ago

rlmark commented 6 months ago

When the first word inside a parenthetical statement is monospaced with the single backtick syntax:

test = {{

  `hi` hi

  (this is a parenthesis `hi` blah)

  (`now` it starts with a backtick, which is not treated as monospace)
}}

The local, share, and website UI does not render the monospace syntax as monospace.

Screenshot 2024-03-
[backticksInParens.md](https://github.com/unisonweb/unison/files/14564295/backticksInParens.md)
11 at 1 29 54 PM

A transcript is attached, but you will need to open the UI to see the issue. backticksInParens.md

pchiusano commented 6 months ago

Yeah looks like a parser issue

    2 | > {{ (`hello` there ) }}
          ⧩
          Paragraph [Word "(`hello`", Word "there", Word ")"]

Notice it's just parsing the opening paren and the subsequent backticked word as a single token.

pchiusano commented 6 months ago

This part of Lexer.hs seems like the culprit. It gobbles up a word until reaching a non-space character, but it should probably stop if encountering a backtick or double quote.

CleanShot 2024-03-11 at 15 50 44@2x
sellout commented 3 months ago

I think this is the same issue as #4633.

wordy needs to lookAhead for any potential leafy opening sequences (here it says docOpen, but that is just coincidentally the same symbol as the opening for transcludes, but really, a single { suffices, as well as backtick, '', *, ~, @source, etc.). It might need to P.try leafy character by character, as a [ is only the end of wordy if there are later ]( and ), for example.

sellout commented 2 months ago

Duplicate of #2483.