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

Added Robot Framework plain text format #2034

Merged
merged 3 commits into from
Sep 3, 2019

Conversation

RunDevelopment
Copy link
Member

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

image

extendecInside['comment'] = comment;

return {
pattern: RegExp(/^ ?\*{3}[ \t]*<name>[ \t]*\*{3}(?:.|[\r\n](?!\*{3}))*/.source.replace(/<name>/g, name), 'im'),
Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

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.

@RunDevelopment RunDevelopment merged commit f7eaa61 into PrismJS:master Sep 3, 2019
@RunDevelopment RunDevelopment deleted the robot-framework branch September 3, 2019 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Robot Framework
2 participants