A student in another class coloured their code in their word document, I asked my teacher if he knew how and he suggested he coloured it all by hand... I'm very sure he didn't colour hundreds of lines of code by hand.
I've also seen many websites that colour the code snippets to help with readability - including StackOverflow!
Here's a print screen of the code contained in the word document.
as you can see they're not print-screens as not only can I highlight the text, word has underlined what it thinks are errors in spelling / grammar.
When you copy-paste into a Word document, it (by default) retains the formatting of the text copied into it. IDEs (e.g., Visual Studio, Eclipse, IntelliJ, etc.) usually perform syntax highlighting (i.e., color different elements of the code differently in order to highlight their purpose) for you. If you copy and paste from the IDE you've used to create the code, it will probably retain this formatting.
Related
I'm looking for a reference as to what each color of syntax highlighting in Visual Studio Code actually means. I'm currently using the dark default theme Dark+. I've gotten used to recognizing a few of the highlight colors and I get the gist of what I'm looking at, but I'm looking for a more detailed reference of what each color means.
I've searched for a while for this and can not find any reference guide or glossary/index listing the colors and meanings. Not sure if it matters, but I am solely writing in JavaScript.
Thank you in advance.
edit: I have included a screenshot of the type of syntax highlighting I am referring to.
The meaning of the syntax highlight colors comes in two parts:
How are the characters in the file organized into meaningful tokens?
How are those tokens assigned a particular color and font style?
Partitioning text to tokens
The first part is determined by a grammar description built in to VSCode. VSCode uses a system based on TextMate grammars. The grammars are defined in the VSCode sources (e.g., JavaScript.tmLanguage.json), but in that form have gone through a couple stages of postprocessing, making them nearly unreadable. There is no documentation of the intent of these grammar files. They tend to at least roughly follow the relevant language specification, but with plenty of ad-hoc deviations.
The most practical way to understand what tokens are defined is to use the "Developer: Inspect TM Scopes" tool available in the Command Palette (Ctrl+Shift+P). When you put your cursor on a token, it will show you the "scope labels" that describe that token. These labels are more or less human-readable.
Edit 2020-07-24: As of VSCode 1.47 (and possibly a little earlier) the command is called "Developer: Inspect Editor Tokens and Scopes".
Example:
Above, we can see that the return keyword is most specifically classified as keyword.control.flow.js. It is within a brace-enclosed code block (meta.block.js), within a function definition (meta.function.js), within Javascript source code (source.js).
That sequence of scope labels is the closest thing there is to a "meaning" for a token in VSCode.
Assigning colors to tokens
Next, there is the process of mapping that sequence of scope labels to a color and font style. That is done by the theme. In my case I am using Visual Studio Light, defined in the VSCode sources in light_vs.json. In the case of the return keyword, this is the applicable fragment:
{
"scope": "keyword.control",
"settings": {
"foreground": "#0000ff"
}
},
This says, basically, that anything with a scope label beginning with "keyword.control" shall have a blue color. But other fragments may override this one; the rules are somewhat complex. Why blue? It's an arbitrary aesthetic choice.
Why do function and NaN have the same color? The grammar assigns them different scope labels (storage.type.function.js versus constant.language.nan.js), but it just happens that the theme you are using (Dark+) assigns them the same color (as does mine). I find that an odd choice, but can only speculate about the reason.
Customizing the colors
You didn't ask, but an obvious follow-on question would be how to customize these colors, for example giving function and NaN different colors. See this answer.
Within a Markdown editor I want to support text highlight, not in the sense of code highlighting, but the type of highlighting people do on books.
In code oriented sites people can use backquotes for a grey background, normally inline code within a paragraph. However on books there is the marker pen for normal text within a paragraph. That is the classical black text on yellow background.
Is there any syntax within Markdown (or its variants) to specify that the user want that type of highlight? I want to preserve the backquotes syntax for code related marking, but also want a way to enable highlighted user text
My first thought is just using double backquotes, since triple backquotes are reserved for code blocks. I am just wondering if other implementations have already decided a syntax for it... I would also appreciate if someone could justify if this is a very bad idea.
As the markdown documentation states, it is fine to use HTML if you need a feature that is not part of Markdown.
HTML5 supports
<mark>Marked text</mark>
Else you can use span as suggested by Rad Lexus
<span style="background-color: #FFFF00">Marked text</span>
I'm late to the party but it seems like a couple of markdown platforms (Quilt & iA Writer) are using a double equal to show highlighting.
==highlight==
Typora is also using double equal for highlighting. It would be nice it that becomes a CommonMark standard, as mentioned by DirtyF. It would be nice for those who use it frequently, since it is only 4 repeated chars: ==highlight==
If you want the option to use multiple editors, it may be best to stick with <mark>highlight</mark> for now, as answered by Matthias.
Here is the latest spec from CommonMark, "which attempts to specify Markdown syntax unambiguously". Currently "highlighting" is not included.
Editors using ==highlight== from comments mentioned previously:
Typora
Obsidian
Quilt
IA Writer
Feel free to add to this list.
You can use the Grave accent (backtick) ` to highlight text in markdown
Highlighted text
Also works with VS Code extension markdownlint
Grey-colored Higlighting Solution
A possible solution is to use the <code> element:
This solution works really well on git/github, because git/github doesn't allow css styling.
OBS!:
Using the code-element for highlighting is not semantic.
However, it is a possible solution for adding grey-colored highlighting to text in markdown.
Markdown/HTML
<code> <i>This text will be italic</i> <b>this text will be bold</b> </code>
Output
This text will be italic this text will be bold
Roam markdown uses double-caret: ^^highlight^^. Andrew Shell's answer mentions double-equals.
The accepted and clearly correct answer is <mark> from Matthias above, but I thought I had seen carets in some other flavor of markdown. Maybe not. I want to transform my ^^highlights^^ to <mark>highlights</mark> in pandoc conversion to html, and somehow ended up here...
Probably best bet is just use html e.g
<pre><b>Hello</b> is higlighted</pre>
Hello is higlighted
Remember nearly all html is valid in markdown too.
Matlab cannot display Arabic/Persian labels of the figure. Also I cannot see my installed fonts and I don't want to add the labels by another program. How can I fix this problem?
What you're looking for is a way to display unicode characters in axes labels.
It seems that this problem was encountered before, but there's no simple solution for it. See workarounds here and here.
One important thing though - do not edit .m files containing unicode\utf-8 characters (such as Arabic, Farsi, Hebrew, Chinese, etc...) in MATLAB, because it messes up the characters upon saving. Use an external editor (like Notepad++) to edit and save the files (as UTF-8 without BOM), and only run in MATLAB.
I am a great fan of syntax highlighting in any form. But i am missing something similar for plain text files. Imagine different colors for indented lines or lines preceded by special chars. Does anything like that already exist? I'd especially appreciate a plugin for Sublime Text.
The closest thing I know of is the PlainTasks plugin:
It's a plugin to make styled TODO lists, but what you see in the screenshot is basically it.
You could modify the Markdown or reStructuredText files to actually color the text.
I just imported new fonts and colors for Visual Studio 2008. I want to change the color on the ref keyword on a parameter to stand out a little more. Anyone know what option that is in the Display Items under Fonts and Colors?
That's not how syntax highlighting works in VS2008. It is done by 'lexical analysis', not a language parser. In other words, it tokenizes the text in the source code file and classifies them by lexical type. Keyword, identifier, number, string literal, comment, whitespace. And gives them their associated color.
It is important that it works that way because lexical analysis is fast, parsing is slow. Getting text to repaint in a text editor needs to be fast. Accordingly, it has no option to classify individual keywords, the only option you got is the "Keyword" color in the dialog. Which changes the color of all keywords, not just ref.