summaryrefslogtreecommitdiff
path: root/themes/beautifulhugo/exampleSite/content/post/2016-03-08-code-sample.md
diff options
context:
space:
mode:
Diffstat (limited to 'themes/beautifulhugo/exampleSite/content/post/2016-03-08-code-sample.md')
-rw-r--r--themes/beautifulhugo/exampleSite/content/post/2016-03-08-code-sample.md42
1 files changed, 42 insertions, 0 deletions
diff --git a/themes/beautifulhugo/exampleSite/content/post/2016-03-08-code-sample.md b/themes/beautifulhugo/exampleSite/content/post/2016-03-08-code-sample.md
new file mode 100644
index 0000000..af4514a
--- /dev/null
+++ b/themes/beautifulhugo/exampleSite/content/post/2016-03-08-code-sample.md
@@ -0,0 +1,42 @@
+---
+title: Code Sample
+subtitle: Using Hugo or Pygments
+date: 2016-03-08
+tags: ["example", "code"]
+---
+
+The following are two code samples using syntax highlighting.
+
+<!--more-->
+
+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
+```
+
+
+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 >}}
+
+
+And here is the same code with line numbers:
+
+{{< highlight javascript "linenos=inline">}}
+ 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 >}}