-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
docs: mention usage of regexp literal in text expressions #5640
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
docs: mention usage of regexp literal in text expressions #5640
Conversation
Featuring this alongside other much more important and generally useful documentation still feels odd to me. As I mentioned in the original issue, I don't really have an answer where this should appear. I also don't know how many times this has come up in practice, or whether the original issue was @tanhauhau specifically looking for bugs. |
i raised the issue as a bug, but i'm not sure whether it should be documented as an intended behavior rather than fixing it |
When this came up in the maintainers chat - https://discord.com/channels/457912077277855764/571775594002513921/749639227444297759 - pngwn and I talked about how it seems there's not really a reasonable way to handle this. If someone does |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem like the worst place in the docs to put it, but I'd probably put it in an aside box instead of the main text
@@ -141,6 +141,13 @@ Text can also contain JavaScript expressions: | |||
<p>{a} + {b} = {a + b}.</p> | |||
``` | |||
|
|||
--- | |||
|
|||
However, if you're using a regular expression (`RegExp`) [literal notation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#literal_notation_and_constructor), you'll need to wrap it in parentheses. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, if you're using a regular expression (`RegExp`) [literal notation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#literal_notation_and_constructor), you'll need to wrap it in parentheses. | |
> If you're using a regular expression (`RegExp`) [literal notation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#literal_notation_and_constructor), you'll need to wrap it in parentheses. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Placing it in an aside box seems nice. I haven't seen what it'll look like on the page if we do that, but I see in the current docs that blockquotes are always placed after a main text first. Should we also remove the separator above? What about the example code after it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This blue box is an example: https://svelte.dev/docs#get
Yes, I think we could remove the separator in that case. Can we put the code example in the box? (maybe if you prefix each line with >
it will do that. you can test by running the site locally, which I think is cd site; npm install; npm run update; npm run dev
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed and merged it to the previous row, I think this is clearer and follows the style (like https://svelte.dev/docs#get) better |
Closes #5318
Before submitting the PR, please make sure you do the following
Tests
npm test
and lint the project withnpm run lint