.Kind (page): .Type (posts) / .Layout ()
Bundle: n/a (regular page)
[ categories | tags | search ]
ox-hugo Test Site

This is the test site for the ox-hugo package for Emacs/Org-mode.

It is updated automatically after each commit to the ox-hugo repo. It was last updated on Mar 05, 2024 19:24 UTC.


This page was created/modified in commit efdf4c0 "Change `linenos` arg value to `true`; update tests" on 2022-03-08.
Markdown source of this page

Source blocks with highlighting (Goldmark)

tags: src-block annotations goldmark highlight


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!.

Highlighting only 1 line #

Org source #
#+begin_src emacs-lisp :hl_lines 2
(message "This is line 1")
(message "This is line 2")
(message "This is line 3")
#+end_src
Output #
(message "This is line 1")
(message "This is line 2")
(message "This is line 3")

With line numbers not starting from 1 #

With line numbers enabled, the highlighting is limited to the width of the HTML table rows if the linenos option is set to table (default).

Note 1
When using both, switches (like -n), and header args (like :hl_lines), the switches have to come first.
Note 2
The line numbers in the value for :hl_lines parameter is always with the starting line number reference of 1. That has no relation with the value of the line numbers displayed using the -n or +n switches!

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 (Goldmark)"
Title "Source blocks with highlighting (Goldmark)"
ResourceType "page"
Kind "page"
Section "posts"
Draft false
Type "posts"
Layout ""
Permalink "https://ox-hugo.scripter.co/test/posts/source-block-with-highlighting/"
RelPermalink "/posts/source-block-with-highlighting/"
Data
page.Data{} (type:page.Data)
NextPageSource blocks with highlighting (Blackfriday)
PrevPageSource blocks with langs that need to be replaced in Markdown
NextInSectionSource blocks with highlighting (Blackfriday)
PrevInSectionSource blocks with langs that need to be replaced in Markdown

Page Params (Debug)

KeyTypeValue
aliases[]string "/posts/source-block-with-highlighting-goldmark"
draftbool false
iscjklanguagebool false
lastmodtime.Time 2022-03-08 20:49:23 -0500 -0500
tags[]string "src-block" "annotations" "goldmark" "highlight"
titlestring "Source blocks with highlighting (Goldmark)"

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.101.0 (commit 466fa43c16709b4483689930a4f9ac8add5c9f66) . This site is powered by Netlify.
[Test Site home | ox-hugo home]