.Kind (page): .Type (posts) / .Layout ()
Bundle: n/a (regular page)
[ categories | projects | tags | search ]
Hugo Sandbox

This is an unofficial Hugo sandbox site to try to replicate possible bugs in hugo.

It is updated automatically after each commit to the hugo-sandbox repo. It was last updated on Oct 09, 2018 14:48 UTC.


This page was created/modified in commit 669d193 "Copy ox-hugo test site" on 2017-11-02.
Markdown source of this page

Source blocks with highlighting

tags: src-block


Description/Summary

Without line numbers Org source #+BEGIN_SRC emacs-lisp:hl_lines 1,3-5 (message "This is line 1") (message "This is line 2") (message "This is line 3") (message "This is line 4") (message "This is line 5") (message "This is line 6") #+END_SRC Output (message "This is line 1") (message "This is line 2") (message "This is line 3") (message "This is line 4") (message "This is line 5") (message "This is line 6") Above highlighting might look weird as the highlighting spans the full page/container width.


Content

Without line numbers

Org source

#+BEGIN_SRC emacs-lisp :hl_lines 1,3-5
(message "This is line 1")
(message "This is line 2")
(message "This is line 3")
(message "This is line 4")
(message "This is line 5")
(message "This is line 6")
#+END_SRC

Output

(message "This is line 1")
(message "This is line 2")
(message "This is line 3")
(message "This is line 4")
(message "This is line 5")
(message "This is line 6")

Above highlighting might look weird as the highlighting spans the full page/container width. This could be either called a bug in Hugo, or the HTML limitation.

A workaround is below.. use line numbers too!.

With line numbers not starting from 1

With line numbers enabled, the highlighting is limited to the width of the HTML table rows (because ox-hugo sets the linenos=table option in the highlight shortcode when line numbers are enabled).

Org source

#+BEGIN_SRC emacs-lisp -n 7 :hl_lines 1,3-5
(message "This is line 7 in code, but line 1 for highlighting reference")
(message "This is line 8 in code, but line 2 for highlighting reference")
(message "This is line 9 in code, but line 3 for highlighting reference")
(message "This is line 10 in code, but line 4 for highlighting reference")
(message "This is line 11 in code, but line 5 for highlighting reference")
(message "This is line 12 in code, but line 6 for highlighting reference")
#+END_SRC

Output

7
8
9
10
11
12
(message "This is line 7 in code, but line 1 for highlighting reference")
(message "This is line 8 in code, but line 2 for highlighting reference")
(message "This is line 9 in code, but line 3 for highlighting reference")
(message "This is line 10 in code, but line 4 for highlighting reference")
(message "This is line 11 in code, but line 5 for highlighting reference")
(message "This is line 12 in code, but line 6 for highlighting reference")

With line numbers

Org source

#+BEGIN_SRC emacs-lisp -n :hl_lines 1,3-5
(message "This is line 1")
(message "This is line 2")
(message "This is line 3")
(message "This is line 4")
(message "This is line 5")
(message "This is line 6")
#+END_SRC

Output

1
2
3
4
5
6
(message "This is line 1")
(message "This is line 2")
(message "This is line 3")
(message "This is line 4")
(message "This is line 5")
(message "This is line 6")

Page (Debug)

Page VariableValue
Name "Source blocks with highlighting"
Title "Source blocks with highlighting"
ResourceType "page"
Kind "page"
Section "posts"
Draft false
Type "posts"
Layout ""
Permalink "https://hugo-sandbox.netlify.com/posts/source-block-with-highlighting/"
RelPermalink "/posts/source-block-with-highlighting/"
RSSLink ""
Data
KeyTypeValue
Pageshugolib.Pages
NextPageSecond Article
PrevPageSource blocks with line number annotation
NextInSectionResource Counters Name and Title
PrevInSectionSource blocks with line number annotation

Page Params (Debug)

KeyTypeValue
draftbool false
iscjklanguagebool false
lastmodtime.Time 2017-11-02 10:12:52 -0400 -0400
tags[]string "src-block"
titlestring "Source blocks with highlighting"

File Object (Debug)

FileInfo VariableValue
UniqueID "8948ccb3249b02d89268fd544f69ade5"
BaseFileName "source-block-with-highlighting"
TranslationBaseName "source-block-with-highlighting"
Lang "en"
Section "posts"
LogicalName "source-block-with-highlighting.md"
Dir "posts/"
Ext "md"
Path "posts/source-block-with-highlighting.md"

This site is generated using the ox-hugo package for Emacs/Org-mode + hugo-bare-min-theme + Hugo 0.50-DEV (commit d5d50e2f, using Chroma commit d5ca12b) .

[Back to Hugo Sandbox home]