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

Import Code Snippets: specify the language #1189

Open
mbana opened this issue Jan 13, 2019 · 1 comment
Open

Import Code Snippets: specify the language #1189

mbana opened this issue Jan 13, 2019 · 1 comment
Labels
type: feature request Request to add a new feature

Comments

@mbana
Copy link

mbana commented Jan 13, 2019

https://vuepress.vuejs.org/guide/markdown.html#import-code-snippets

I've got this block of code in Markdown file:

<<< @/docs/.vuepress/public/examples/circleci-authorizing-the-google-cloud-sdk_examples/.circleci/config.yml
...
<<< @/docs/.vuepress/public/examples/circleci-authorizing-the-google-cloud-sdk_examples/Makefile

Both work but the code is not highlighted. How do I specify the language when I import a code snippet?

@qdot
Copy link

qdot commented Jan 14, 2019

I just had this same problem with a C# file. C# files usually end in .cs, if I do something like

<<< @/example/Program.cs

What's rendered isn't highlighted. However, if you change the extension to the language name prism expects, i.e.

<<< @/example/Program.csharp

Then things worked for me. So, for now, you may have to name your files config.yaml and Makefile.makefile. That's... not great.

It looks like

token.info = filename.split('.').pop() + meta
is just popping the file extension as the language name (which is why you can get away with appending {x,y} and having line highlights work, since that'll just come along as part of the extension).

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
@ulivz ulivz added the type: feature request Request to add a new feature label Jan 15, 2019
oskardudycz added a commit to EventStore/documentation that referenced this issue Feb 15, 2021
oskardudycz added a commit to EventStore/documentation that referenced this issue Feb 15, 2021
oskardudycz added a commit to EventStore/documentation that referenced this issue Feb 15, 2021
oskardudycz added a commit to EventStore/documentation that referenced this issue Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request Request to add a new feature
Projects
None yet
Development

No branches or pull requests

3 participants