VSCode issues with syntax highlighting for yaml headers in markdown - visual-studio-code

I have been using VSCode and Pandoc for writing Markdown documents. VSCode recognizes and highlights some YAML header blocks just fine, but not others. I noticed the problem on HTML comments in Markdown.
If I use this style of YAML header (closed with dashes) at the very top of the document, VSCode seems to recognize the end of the block, and move back to normal highlighting mode after the close of the block(see screenshot "scratch1.md" document).
---
title: Best Article Ever
author: Great Writer
---
However, if I use another legal style (closed with ...) which seems to be legal according to the YAML specification, section 2.2 Structures:
---
title: Best Article Ever
author: Great Writer
...
VSCode does not seem to see the YAML block as closed, and so highlighting is messed up for the rest of the document (see screenshot below).
This problem (messed up highlighting) does not occur for either style if they are not at the very top of the document.
At this point, I'm not sure where the problem is and how I might go about changing it. Some pointers in the right direction would be appreciated.
Is it a problem with my understanding of the YAML syntax?
Is it a problem with the YAML language file in VSCode?
Is it a problem with the markdown language file in VSCode (i.e. problem with the embedded YAML)?
Is it something I have to/can correct with some kind of language extension?
etc.
It isn't hugely important to me, but I have a lot of legacy documents like this and if a correction is reasonably straightforward I'd like to try.
Thanks in advance for any help or explanations.

I work on markdown support for VSCode. Yes, right now you have to use --- to terminate your frontmatter.
I've opened https://github.com/Microsoft/vscode/issues/23178 to track support for using ... as a frontmatter terminator. Feel free to submit a PR for this. I've added some notes on what this would involve: https://github.com/Microsoft/vscode/issues/23178#issuecomment-289136137
Update
This should be fixed in VSCode 1.11+
Here was the fixing PR: https://github.com/Microsoft/vscode/pull/23195

Related

Is it my imagination or did footnote style links stop working in vscode preview mode?

I always use footnote style links in markdown because it makes the plain text more readable for me. E.g.:
This is [Stack Overflow][1].
[1]: https://stackoverflow.com
in most Markdown renderers will display as:
This is Stack Overflow.
I could have sworn I've been doing this all along in vscode. However, recently I notice that it in vscode renders as:
This is [Stack Overflow][1].
It knows there's something special about the footnote style link because it doesn't render the footnote at all. But the anchor text is not rendered as a link. This seems like a severe regression to me, but I can't find any bugs reported for it.
My specific questions that I am seeking definitive answers on:
Can anyone confirm that this either did or did not work in the past?
Has this been intentionally disabled?
Is this part of the new workspace security settings?
Thanks to those who commented that it works for them. Knowing that it works for other people really helped narrow down my search for what was wrong.
Turns out the Foam extension was causing this. After disabling it footnote links render properly now.

Getting github to syntax highlight my files

github automaticall syntax highlights any code files such as those with .c extensions. And there seems plenty of information about controlling highlighting from within 'markdown' or .md files.
But how can I get it to highlight code files that it doesn't know about?
I can't even get the tabbing right - if I say 4-spaces tabs while editing, it goes back to 8-space ones when I've finished.
I don't care what highlighting style it uses even if it's the wrong language; it must be better than the plain text appearance which looks really flat. Oddly, when editing it uses some sort of highlighting, which again disappears when I've finished.
The files aren't in any well-known language so the highlighting won't be perfect; I just want a bit of colour. But I'd rather not change file extensions as that could be confusing.
The tabbing is done through a ?t=4 parameter added to the GitHub url.
But the syntax highlighting (using Rouge on GitHub pages for instance) itself is either:
set in fenced code block (but only for .md markdown pages)
or by changing the file extension (which you don't want)
But how can I get it to highlight code files that it doesn't know about?
Update Feb. 2021 (5 years later)
Nat Friedman (CEO of GitHub) announces it on Twitter:
Another tiny but nice improvement we just shipped to GitHub – syntax highlighting now works on new files without the need to commit first.

Why is `&&` highlighted on Github

On Github, I realized that &&s are highlighted in this file but not in the other languages such as Java, JavaScript etc in the same repo. Does anyone know what the highlight actually means?
Thanks
Allen
Because it is an ASHX (WebHandler) file. The syntax highlighting on GitHub it language-specific:
What is ASHX:
http://www.c-sharpcorner.com/uploadfile/prathore/what-is-an-ashx-file-handler-or-web-handler/
Another example of GitHub syntax highlighting for ASHX:
https://github.com/JamesDunne/sql.ashx/blob/master/sql.ashx
This is a bug with GitHub Linguist, which is not selecting the right grammar for highlighting. The current grammar is expecting this kind of syntax and is unable to highlight your file.
My guess is we'd need to select a new grammar just for .ashx. If you know a TextMate, Sublime Text, or Atom grammar capable of highlighting correctly .ashx files, please open an issue or pull request at Linguist.

Issue with Markdown emphasis on characters within brackets (Gitlab.com)

I am not a coder, so consider myself a big rookie with Git tools and services like Gitlab.com, however I've noticed that when I read a .md file on Gitlab, it won't italicize chains of characters when they directly follow an opening bracket (, while it did work with Bitbucket and Github.
If I write (*e.g.*, the .md viewed on Gitlab will show (*e.g.* instead of (e.g., which is a big issue for me as I intend to use Markdown to write academic papers (and take advantage of the Gitlab versioning, among other things) and often need italics. Any ideas on how to solve that? Is HTML the only way to italicize first words in brackets on Gitlab.com? Closing brackets ) do not block the emphasis, only opening brackets ( do.
Thanks a lot!
This seems to be resolved in latest version. I created a playground repo, also tested on wiki.
https://gitlab.com/axil/playground/blob/master/README.md
https://gitlab.com/axil/playground/wikis/home

How to efficiently edit Markdown in the github issue tracker?

I like the fact that the github issue tracker supports Markdown. However, I find it relatively unpleasant to actually write Markdown in the github editor. It lacks many of the features of the Markdown editor on StackOverflow.
E.g., it lacks:
a button to indent multiple lines of code by four spaces
a button to add quote to the start of each line
real time markdown preview
fixed width font
ability to insert image using imgur
a confirmation dialog box when you close a browser window when you might otherwise lose your work
In particular, the inability to insert code blocks is probably the feature I miss the most.
Sure, I could write my markdown in a separate editor and then paste it into the github issue tracker, but this is not especially appealing. I could even use the StackOverflow editor if I was careful not to click "Ask Question", but that seems a bit silly.
Question
Is there anyway of altering the text box in github to incorporate the editing features in StackOverflow?
Or if it is better to type in another text editor, what's a particularly elegant way of doing that? (e.g., minimum steps, simple to move back and forward, good editor) Perhaps theres a way of clicking a text box and bringing up a Rich Markdown editor which when closed returns the contents to the original text box?
You should appeal to GitHub to add one. Your argument is sound. Stack Overflow demonstrates editors can be functional, non-intrusive and tasteful.
Meanwhile, there might be a browser extension that does some of this. https://chrome.google.com/webstore/detail/cpojebknccclkjabfngjlcknonpmhhol
If you are on Windows, you might want to check MarkPad: http://code52.org/DownmarkerWPF/
Disclaimer: I have never used it myself (being on Ubuntu), only read about it watching the code52 project. I know it can edit posts of several blog systems, but I'm not sure if Github is in the list of supported web sources. Its syntax however is supported, for sure.