Skip to content

Add language import specification to code snippet imports #1191

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

Open
qdot opened this issue Jan 14, 2019 · 0 comments
Open

Add language import specification to code snippet imports #1191

qdot opened this issue Jan 14, 2019 · 0 comments

Comments

@qdot
Copy link

qdot commented Jan 14, 2019

Feature request

What problem does this feature solve?

Importing code snippets currently uses the filename extension as the prism language. While this is fine for things like test.html and test.js, when you're using something like Makefile or Program.cs, the parser fails or prism gets a language specifier it doesn't understand. If prism language can be set specifically in an snippet import line, it'd be easier than trying to guess.

See #1189 for more info.

What does the proposed API look like?

A "lang=[prism language name]" token added to the import snippet line. Preferably before the file URI.

>>> lang=csharp @/test/Program.cs

"=" is used because ":" is already caught in the regex later for the path, not sure what the : is used for otherwise but didn't want to conflict.

How should this be implemented in your opinion?

Should be able to add it to vuepress/packages/@vuepress/markdown/lib/snippet.js. That's already just hand-parsing the line anyways.

Are you willing to work on this yourself?**

Yup. Shouldn't be too difficult, just want to make sure the format is acceptable before putting in a PR.

qdot added a commit to qdot/vuepress that referenced this issue Jan 14, 2019
Add "lang:[prism-lang-name]" to code snippet insertion line, so name
isn't dependant on file extension detection.

Fixes vuejs#1191, vuejs#1189
qdot added a commit to qdot/vuepress that referenced this issue Jan 14, 2019
Add "lang:[prism-lang-name]" to code snippet insertion line, so name
isn't dependant on file extension detection.

Fixes vuejs#1191, vuejs#1189
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

No branches or pull requests

1 participant