-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Added Robot Framework plain text format #2034
Conversation
extendecInside['comment'] = comment; | ||
|
||
return { | ||
pattern: RegExp(/^ ?\*{3}[ \t]*<name>[ \t]*\*{3}(?:.|[\r\n](?!\*{3}))*/.source.replace(/<name>/g, name), 'im'), |
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.
Will this work with the gulp task we have in the build that does the .source
replace?
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.
Yes. Here's the minified version of that line (pulled from components/prism-robot-framework.min.js
):
pattern:RegExp("^ ?\\*{3}[ \t]*<name>[ \t]*\\*{3}(?:.|[\r\\n](?!\\*{3}))*".replace(/<name>/g,t),"im")
What made you think it wouldn't work?
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 didn't remember how it worked and I was wondering if the dynamic rewrite was an issue.
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 didn't remember how it worked
Barely. I used a regex to find all RegExp literals which end with /.source
and replace those with the optimized source value. I say optimized but it's really just a few things like replace \\t
with \t
to save a few characters. It's technically incorrect as it's not the real source value but it works well for Prism where we never leave the world of regex patterns.
I'm planning to drop this as soon as our minifier supports this. With regard to #1578, I opened an issue at Terser which can minify ES6+ code.
This resolves #1990.
I only added support for the space-separated format because the pipe-separated format is even harder to parse than the space-separated one. Both are very flexible and context depended which makes parsing them using regexes a nightmare (maybe there's an obvious and simple way to do it but I at least couldn't find it).
Example