More detail: Syntax Highlighting | Hugo
JavaScript
function helloWorld () {
alert("Hello, World!")
}
Java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
package hello
fun main(args: Array<String>) {
println("Hello World!")
}
#include <stdio.h>
/* Hello */
int main(void){
printf("Hello, World!");
return 0;
}
// 'Hello World!' program
#include <iostream>
int main(){
std::cout << "Hello World!" << std::endl;
return 0;
}
using System;
class HelloWorld{
public static void Main(){
System.Console.WriteLine("Hello, World!");
}
}
HTML
<html>
<body>
Hello, World!
</body>
</html>
Go
package main
import fmt "fmt"
func main()
{
fmt.Printf("Hello, World!\n");
}
object HelloWorld with Application {
Console.println("Hello, World!");
}
PHP
<?php
echo 'Hello, World!';
?>
Python
print("Hello, World!")
no named code block
## this is a comment
$ echo this is a command
this is a command
## edit the file
$vi foo.md
+++
date = "2014-09-28"
title = "creating a new theme"
+++
bah and humbug
:wq
## show it
$ cat foo.md
+++
date = "2014-09-28"
title = "creating a new theme"
+++
bah and humbug
$
highlight shortcode
example:
{{</* highlight go "linenos=table,hl_lines=8 15-17,linenostart=199" */>}}
// ... code
{{</* /highlight */>}}
// GetTitleFunc returns a func that can be used to transform a string to
// title case.
//
// The supported styles are
//
// - "Go" (strings.Title)
// - "AP" (see <https://www.apstylebook.com/)>
// - "Chicago" (see <http://www.chicagomanualofstyle.org/home.html)>
//
// If an unknown or empty style is provided, AP style is what you get.
func GetTitleFunc(style string) func(s string) string {
switch strings.ToLower(style) {
case "go":
return strings.Title
case "chicago":
tc := transform.NewTitleConverter(transform.ChicagoStyle)
return tc.Title
default:
tc := transform.NewTitleConverter(transform.APStyle)
return tc.Title
}
}