Code Sample

 Posted March 8, 2016 (Updated November 26, 2022)  |  1 minutes  |  137 words  |  Some Person
Code Sample https://caleb-vincent.gitlab.io/lessbeautifulhugo/post/2016-03-08-code-sample/

To get syntax highlighting set either the individual page’s Frontmatter with highlight: true or set highlight = true in config.toml. This will include the CSS needed for colors.

The following are two code samples using syntax highlighting.

The following is a code sample using triple backticks ( ``` ) code fencing provided in Hugo.

    var num1, num2, sum
    num1 = prompt("Enter first number")
    num2 = prompt("Enter second number")
    sum = parseInt(num1) + parseInt(num2) // "+" means "add"
    alert("Sum = " + sum)  // "+" means combine into a string

The following is a code sample using the highlight shortcode provided in Hugo.

    var num1, num2, sum
    num1 = prompt("Enter first number")
    num2 = prompt("Enter second number")
    sum = parseInt(num1) + parseInt(num2) // "+" means "add"
    alert("Sum = " + sum)  // "+" means combine into a string