Source blocks with highlighting (Blackfriday)
tags:
src-block
shortcode
blackfriday
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
#
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 Params (Debug)
Key | Type | Value |
draft | bool |
false
|
iscjklanguage | bool |
false
|
lastmod | time.Time |
2022-03-08 20:49:23 -0500 -0500
|
tags | []string |
"src-block"
"shortcode"
"blackfriday"
"highlight"
|
title | string |
"Source blocks with highlighting (Blackfriday)"
|
File Object (Debug)
FileInfo Variable | Value |
UniqueID |
"d0213521b0fc867777ab27657c8d4ea0"
|
BaseFileName |
"source-block-with-highlighting-blackfriday"
|
TranslationBaseName |
"source-block-with-highlighting-blackfriday"
|
Lang |
"en"
|
Section |
"posts"
|
LogicalName |
"source-block-with-highlighting-blackfriday.md"
|
Dir |
"posts/"
|
Ext |
"md"
|
Path |
"posts/source-block-with-highlighting-blackfriday.md"
|