Files
gitea-pages/pages/mydoc/mydoc_syntax_highlighting.md

54 lines
1.2 KiB
Markdown

---
title: Syntax highlighting
tags: [formatting]
keywords: rouge, pygments, prettify, color coding,
last_updated: July 3, 2016
summary: "You can apply syntax highlighting to your code. This theme uses pygments and applies color coding based on the lexer you specify."
sidebar: mydoc_sidebar
permalink: mydoc_syntax_highlighting.html
folder: mydoc
---
## About syntax highlighting
For syntax highlighting, use fenced code blocks optionally followed by the language syntax you want:
<pre>
```java
import java.util.Scanner;
public class ScannerAndKeyboard
{
public static void main(String[] args)
{ Scanner s = new Scanner(System.in);
System.out.print( "Enter your name: " );
String name = s.nextLine();
System.out.println( "Hello " + name + "!" );
}
}
```
</pre>
This looks as follows:
```java
import java.util.Scanner;
public class ScannerAndKeyboard
{
public static void main(String[] args)
{ Scanner s = new Scanner(System.in);
System.out.print( "Enter your name: " );
String name = s.nextLine();
System.out.println( "Hello " + name + "!" );
}
}
```
Fenced code blocks require a blank line before and after.
If you're using an HTML file, you can also use the `highlight` command with Liquid markup.
{% include links.html %}