Add client side syntax highlighting support

Added client side syntax highlighting support in addition to existing
server side syntax highlighting support. Updated readme and sample to
reflect both types of highlighting.
This commit is contained in:
Michael Romero 2017-02-12 04:26:35 -08:00
commit 938766f54f
7 changed files with 36 additions and 4 deletions

View file

@ -1,17 +1,30 @@
---
title: Code Sample
subtitle: Using Pygments
subtitle: Using Pygments or Highlight.js
date: 2016-03-08
---
The following is a code sample using the "highlight" shortcode provided in Hugo.
The following are two code samples using syntax highlighting.
<!--more-->
The following is a code sample using the "highlight" shortcode provided in Hugo. This is server side highlighting and requires Python and Pygments to be installed.
{{< highlight javascript >}}
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
{{</ highlight >}}
{{</ highlight >}}
The following is a code sample using triple backticks (```) code fencing provided in Hugo. This is client side highlighting and does not require any special installation.
```javascript
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
```