Skip to content

Commit

Permalink
Implemented copy code button feature (alshedivat#1267)
Browse files Browse the repository at this point in the history
  • Loading branch information
Demi-wlw authored Mar 19, 2023
1 parent 7c87717 commit 9bed0d8
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion _posts/2015-07-15-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,33 @@ published: false
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 a liquid tag:
All you have to do is wrap your code in markdown code tags:

````markdown
```c++
code code code
```
````

```c++
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:
{% raw %}
{% highlight c++ linenos %} <br/> code code code <br/> {% endhighlight %}
Expand Down

0 comments on commit 9bed0d8

Please sign in to comment.