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

Add tremor project DSL langauge definitions #3087

Merged
merged 8 commits into from Sep 21, 2021

Conversation

darach
Copy link
Contributor

@darach darach commented Sep 20, 2021

Adds support for the tremor project domain specific languages
to prism so that we can leverage prism-based syntax highlighting in our new docusaurus
based documentation system.

Please let us know if we've missed anything in the contribution guidelines - these were
great and the tooling for tests is very helpful and assistive. Tip of the hat!

Tremor is an ASL2 licensed CNCF sandbox project - an event processing system with its own
embedded languages for defining user defined logic, queries etc...

Signed-off-by: Darach Ennis darach@gmail.com

Signed-off-by: Darach Ennis <darach@gmail.com>
@github-actions
Copy link

@github-actions github-actions bot commented Sep 20, 2021

JS File Size Changes (gzipped)

A total of 3 files have changed, with a combined diff of +837 B (+17.7%).

file master pull size diff % diff
components/prism-tremor.min.js 0 Bytes 812 B +812 B +100.0%
plugins/autoloader/prism-autoloader.min.js 2.27 KB 2.29 KB +13 B +0.6%
plugins/show-language/prism-show-language.min.js 2.46 KB 2.47 KB +12 B +0.5%

Generated by 🚫 dangerJS against 5bb9ac9

Copy link
Member

@RunDevelopment RunDevelopment left a comment

Hello @darach!

I left you a few comments. Please make sure your tests and lints pass.

Regarding string interpolation: We can do it like this:

Prism.languages.tremor = {
	...
	'heredoc': ...,
	'interpolated-string': null,
	'function': ...
};

var string = {
	pattern: /(^|[^\\])"(?:[^"\\\r\n%]|\\(?:\r\n|[\s\S])|%(?!\{)|%\{(?:[^"{}]|\{[^{}]*\}|"(?:[^"\\\r\n]|\\(?:\r\n|[\s\S]))")*\})*"/,
	lookbehind: true,
	greedy: true,
	inside: {
		'interpolation': {
			pattern: /%\{(?:[^"{}]|\{[^{}]*\}|"(?:[^"\\\r\n]|\\(?:\r\n|[\s\S]))")*\}/,
			inside: {
				'punctuation': /^%\{|\}$/,
				'expression': {
					pattern: /[\s\S]+/,
					inside: Prism.languages.tremor 
				}
			}
		},
		'string': /[\s\S]+/
	}
}

Prism.languages.tremor['interpolated-string'] = string;

Not perfect (doesn't really support nested interpolated strings) but a good start.

components/prism-tremor.js Outdated Show resolved Hide resolved
components/prism-tremor.js Outdated Show resolved Hide resolved
components/prism-tremor.js Outdated Show resolved Hide resolved
components/prism-tremor.js Outdated Show resolved Hide resolved
components/prism-tremor.js Outdated Show resolved Hide resolved
components/prism-tremor.js Outdated Show resolved Hide resolved
components/prism-tremor.js Outdated Show resolved Hide resolved
darach and others added 5 commits Sep 20, 2021
Apply fix worst-case time complexity per @RunDevelopment's insight

Co-authored-by: Michael Schmidt <msrd0000@gmail.com>
Terser formulation of pattern

Co-authored-by: Michael Schmidt <msrd0000@gmail.com>
Terser formulation of pattern

Co-authored-by: Michael Schmidt <msrd0000@gmail.com>
Terser formulation of pattern

Co-authored-by: Michael Schmidt <msrd0000@gmail.com>
Signed-off-by: Darach Ennis <darach@gmail.com>
@darach
Copy link
Contributor Author

@darach darach commented Sep 20, 2021

I suspect i followed the contribution guide a little too closely, the following npm targets are ( super ) useful:

npm run lint
npm run lint:fix
npm run lint:ci

Lints and tests now all pass - apologies for missing these on the first round!

RunDevelopment and others added 2 commits Sep 21, 2021
Signed-off-by: Michael Schmidt <mitchi5000.ms@googlemail.com>
@RunDevelopment
Copy link
Member

@RunDevelopment RunDevelopment commented Sep 21, 2021

With my PR merged, I don't have anything to add.

@RunDevelopment RunDevelopment merged commit ec25ba6 into PrismJS:master Sep 21, 2021
11 checks passed
@RunDevelopment
Copy link
Member

@RunDevelopment RunDevelopment commented Sep 21, 2021

Thank you for contributing @darach!

@darach
Copy link
Contributor Author

@darach darach commented Sep 21, 2021

No - thank you for the contributor experience. You just won a few more fans in myself and the whole tremor community!

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.

None yet

2 participants