ridilculous
ridilculous

Reputation: 792

How to preview asciidoc in vscode with a file with a yaml extension

I have a file which contains YAML at the top and asciidoc at the bottom. The yaml is surrounded by two lines of ---. The file extension is yaml which is required by the application where it's used.

The only way i know to get a preview out of vscode is to manually rename the file every time i need one and rename it back afterwards.

Is there a way to open the asciidoc preview in vscode while ignoring its extension, e.g. giving a hint, add a configuration or something similar? The docs only describe that

The extension activates automatically when opening an AsciiDoc file (.adoc, .ad, .asc, .asciidoc).

Here's a example file:

---
# yaml here
---
asciidoc here

Upvotes: 2

Views: 6902

Answers (2)

Stanislav Berkov
Stanislav Berkov

Reputation: 6287

Not to mess with language switching I extract embedded code into separate file and then include it into adoc like this:

.CLE Product organization
[plantuml]
----
include::cle-product.puml[]
----

This allows having proper preview and syntax highlighting.

Upvotes: 1

ridilculous
ridilculous

Reputation: 792

This is surprisingly simple: https://code.visualstudio.com/docs/languages/overview#_changing-the-language-for-the-selected-file

In VS Code, we default the language support for a file based on its filename extension. However, at times you may want to change language modes, to do this click on the language indicator - which is located on the right hand of the Status Bar. This will bring up the Select Language Mode dropdown where you can select another language for the current file.

Tip: You can get the same dropdown by running the Change Language Mode command (Ctrl+K M).

Upvotes: 4

Related Questions