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

Support Janet's backtick strings #50

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

MaxGyver83
Copy link
Contributor

@MaxGyver83 MaxGyver83 commented Feb 25, 2024

Support Janet's backtick strings. This fixes #47 (together with #49).

I think the difficult part is that strings may be wrapped in any number of backticks:

For long-strings where you don't want to type a lot of escape characters,
you can use 1 or more backticks (`) to delimit a string.
To close this string, simply repeat the opening sequence of backticks.

Janet Documentation: Strings, Keywords, and Symbols

This pull request handles strings wrapped in up to three backticks (on each side). For testing, delete the second line in this example code with dd:

(print
  (string/replace-all ``"`` `\"` ```"1"```))

Out of scope

Multiline strings are not handled in this pull request.

Deleting the first or the last line with dd fails in both of these forms, no matter if double quote or backtick strings are used:

(print (string ```
               A ``test`` case
               ``` ``!``))

(print (string "hello
               world
               !"))

@MaxGyver83 MaxGyver83 changed the title [WIP] Support Janet's backtick strings Support Janet's backtick strings Feb 26, 2024
@MaxGyver83 MaxGyver83 marked this pull request as ready for review February 26, 2024 10:02
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.

Strange behavior in Janet files
1 participant