Another Test
This theme implements a built-in Jekyll feature, the use of Rouge, for syntax highlighting. It supports more than 100 languages. This example is in C++. All you have to do is wrap your code in markdown code tags:
```c++
code code code
```
int main(int argc, char const \*argv[])
{
string myString;
cout << "input a string: ";
getline(cin, myString);
int length = myString.length();
char charArray = new char * [length];
charArray = myString;
for(int i = 0; i < length; ++i){
cout << charArray[i] << " ";
}
return 0;
}
By default, it does not display line numbers. If you want to display line numbers for every code block, you can set kramdown.syntax_highlighter_opts.block.line_numbers
to true in your _config.yml
file.
If you want to display line numbers for a specific code block, all you have to do is wrap your code in a liquid tag:
{% highlight c++ linenos %}
code code code
{% endhighlight %}
The keyword linenos
triggers display of line numbers.
Produces something like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int main(int argc, char const \*argv[])
{
string myString;
cout << "input a string: ";
getline(cin, myString);
int length = myString.length();
char charArray = new char * [length];
charArray = myString;
for(int i = 0; i < length; ++i){
cout << charArray[i] << " ";
}
return 0;
}
Enjoy Reading This Article?
Here are some more articles you might like to read next: