One Sentence

Hugo theme OneSentence, using one sentence to describe your article, ported from hugo-ivy of YihuiXie.

Syntax Highlighting

Hugo · 2011-08-30 · Words: 291


More detail: Syntax Highlighting | Hugo

function helloWorld () {
  alert("Hello, World!")
}
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>
<body>
  Hello, World!
</body>
</html>
package main
import fmt "fmt"

func main()
{
   fmt.Printf("Hello, World!\n");
}
object HelloWorld with Application {
  Console.println("Hello, World!");
}
<?php
  echo 'Hello, World!';
?>
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 >}}

result:

199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
// 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
  }
}