How to highlight embedded code block on github? - github

Documentation clearly states that code block inside sentence marked using `backticks`.
```Language_Name_Here
For for multi-line block we can use triple backticks
```
But how I can specify language name for embedded block of code? Like <XmlNode Prop="Value" />? I just want to prettify my readme.md to look like this inside sentence:
<XmlNode Prop="Value" />
Looks like the same question related to stackowerflow itself. "language-all" comment is not working for embedded code blocks.

It does not appear to me that this is possible. The spec refers to this as an info string for the code fence (aka fenced code block). The spec for code spans (inline code like you are asking about) does not support info strings.

Related

Where does VSCode store files related to markdown codeblock syntax highlighting?

I'm trying to find the files necessary to add my own syntax highlighting to fenced code blocks in a markdown document within Visual Studio Code. e.g.
```Python
# Comment
print("hello world")
```
will provide syntax highlighting for Python. I'm trying to add syntax highlighting for an unsupported language.
I have tried to find these on my own, but it's been all guesswork. I've found what looks like related files under C:\Users<user>\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions. There's a markdown-basics folder within there that contains a syntaxes\markdown.tmLanguage.json that appears to contain fenced code block references, but not the actual syntax definitions. There's also folders for a variety of languages. Trying to create a new definition based on these doesn't seem to work though.
I would appreciate any help figuring out how fenced code block syntax is defined.

What does ${plugin::command} mean in NSIS?

I'm trying to figure out how to modify an XML file with NSIS. So I'm trying to learn how to use the XML plugin. The examples on the forum page often use the format ${plugin::command} like:
${xml::LoadFile}
The documentation gives no indication that you need the dollar sign and curly braces. As I understand it, just plugin::command will do. So I've been trying to figure out what that syntax means.
The documentation says a $ is for variables and the {} are for code blocks, but I can't find anything about what it means when they're used together. My Internet searches have revealed that it's used for something called template literals in JavaScript. But what does it mean in NSIS?
EDIT: I should mention that the NSIS documentation does show examples of this syntax, especially in the Predefines section, but it still doesn't explain what the syntax means in general.
EDIT: Okay, now I see that the syntax is for the compiler to replace things using !define and !macro. But... what about this specific case? Is it valid to use colons in such a symbol? Why are some people writing ${xml::LoadFile}and some people just writing xml::LoadFile?
It's a !define. There is a header file for this plugin that defines it. The plugin probably needs to do more than one thing, so they wrapped a few lines together with a define that inserts a macro. Either that or it has some default parameters for the plugin call. Either way, it's trying to save you some typing with this syntax.

Adding support for language on a code fence block

doxygen has support for code fence blocks that also have syntax highlighting in the output.
Here is the documentation:
http://www.doxygen.nl/manual/markdown.html#md_fenced
It looks like this:
~~~{.c}
int somefunc(int somevar);
~~~
I want to support .sql; I tried it, but it did not highlight.
My two questions are:
How do I determine what code types doxygen supports for code fence blocks?
Is there some way to define a new one? I am quite happy with just a keyword highlighter; it does not need to be a full parse.
Since my comment, I have looked into adding SQL syntax highlighting to fenced code blocks and \code blocks.
It should now be available if you build from source at https://github.com/doxygen/doxygen or it will be available in the next version (1.8.13).
Here is an example of the syntax highlighting:
If you could test it before the next release, that would be nice, as well.

Make backticks and links overlap work with GitHub Markdown

We are trying to implement an automatic markdown generator for an easily maintainable documentation.
When mentioning a variable's type, we would like to prefix it with ? when it is nullable, use backticks around it and add a link to its description. For example: `?[Article](#article)`.
However, the backticks break the link syntax because of the overlap. We use `?`[`Article`](#article) instead to make the link works but it creates a space between ? and Article as follow: ?Article.
Is it possible to make it look like ?Article with a link on Article only?
I just tested this out and discovered that there is no space between ? and Article. What appears to be a space is simply GitHub's styling of two <code> blocks up against each other.
Wrapping the whole thing in backticks won't work because backticks indicate code, and Markdown treats the contents as if they are a code sample where you want to show the source.
The best workaround I can find is to use <code> tags directly:
<code>?[Article](https://stackoverflow.com/)</code>
On both GitHub and Stack Overflow this renders like so:
?Article
(I have used a link to Stack Overflow as the link target here simply so we get a rendered link as an example. I expect that #article will work equally well in your environment.)
In my opinion this is even a reasonable way of doing what you want. Markdown's backticks compile to <code> tags, and inline HTML code is expressly permitted by Markdown:
For any markup that is not covered by Markdown’s syntax, you simply use HTML itself. There’s no need to preface it or delimit it to indicate that you’re switching from Markdown to HTML; you just use the tags.

Doxygen expands environment variable inside mainpage

I have a mainpage.dox file which is invoked in the configuration file as:
USE_MDFILE_AS_MAINPAGE = ../mainpage.dox
Inside the document I provide instructions on compiling. I would like to list the compiler option as -L/$(MKLROOT)/lib/intel64 -lmkl_rt, however the $(MKLROOT) part is expanded. Is there a way to prevent this from happening?
When I put the following in mainpage.md
1 Test with backticks `-L$(MKLROOT)/lib/intel64 -lmkl_rt`
2 Test without backticks -L\$(MKLROOT)/lib/intel64 -lmkl_rt
3 Test with code <code>-L\$(MKLROOT)/lib/intel64 -lmkl_rt</code>
#verbatim
4 Test with verbatim -L$(MKLROOT)/lib/intel64 -lmkl_rt
#endverbatim
The $(MKLROOT) in the first example gets (incorrectly) expanded.
The other three examples work as expected (using doxygen 1.8.5)
Note that USE_MDFILE_AS_MAINPAGE expects a pure markdown file, not something with a /*! .. */ comment block.
FWIW the latest version of Doxygen as of this writing (1.8.15) still behave in the same way and escaping the backslash still doesn't work. I'm using the following workaround for now:
`-L$``$(MKLROOT)`
which, while ugly, works and doesn't require adding the <code> tags everywhere.
I've also created an issue in Doxygen asking for this to be changed.