Fix error when trying to highlight only 1 line

Also add a test case for that.
master
Kaushal Modi 8 years ago
parent 79616a30eb
commit 4919415a8a
  1. 22
      ox-hugo.el
  2. 17
      test/site/content-org/all-posts.org
  3. 23
      test/site/content/posts/source-block-with-highlighting.md
  4. 2
      test/site/themes/bare_min

@ -868,9 +868,18 @@ is in progress. See `org-hugo--before-export-function' and
(dolist (param parameters)
(dolist (retain-key param-keys-to-be-retained)
(when (equal retain-key (car param))
(setq str (concat str " "
(symbol-name retain-key) " "
(cdr param))))))
(let ((val (cdr param)))
(setq str
(concat str " "
(symbol-name retain-key) " "
(cond
((stringp val)
val)
((numberp val)
(number-to-string val))
(t
(user-error "Invalid value %S assigned to %S"
val retain-key)))))))))
(org-string-nw-p (org-trim str))))
ret)
;; (message "[ox-hugo ob-exp] info: %S" info)
@ -2020,8 +2029,11 @@ channel."
(parameters-str (org-element-property :parameters src-block))
(parameters (org-babel-parse-header-arguments parameters-str))
(hl-lines (cdr (assoc :hl_lines parameters)))
(hl-lines (when hl-lines
(replace-regexp-in-string "," " " hl-lines))) ;"1,3-4" -> "1 3-4"
(hl-lines (cond
((stringp hl-lines)
(replace-regexp-in-string "," " " hl-lines)) ;"1,3-4" -> "1 3-4"
((numberp hl-lines)
(number-to-string hl-lines))))
(label (let ((lbl (and (org-element-property :name src-block)
(org-export-get-reference src-block info))))
(if lbl

@ -1147,6 +1147,15 @@ 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 org :noweb yes
<<src-block-hl-without-n-just-1-line>>
#+end_src
******* Output
#+begin_src org :noweb yes :exports results :results output replace :eval yes
<<src-block-hl-without-n-just-1-line>>
#+end_src
**** With line numbers *not* starting from 1
:PROPERTIES:
:CUSTOM_ID: source-blocks-with-highlighting-with-linenums-not-starting-from-1
@ -5528,6 +5537,14 @@ So, for emacs version 25.0.50.1, this variable will be 25_0.")
:PROPERTIES:
:CUSTOM_ID: source-block-with-line-highlighting-examples
:END:
#+begin_src org :noweb-ref src-block-hl-without-n-just-1-line
,#+begin_src emacs-lisp :hl_lines 2
(message "This is line 1")
(message "This is line 2")
(message "This is line 3")
,#+end_src
#+end_src
#+begin_src org :noweb-ref src-block-hl-without-n
,#+begin_src emacs-lisp :hl_lines 1,3-5
(message "This is line 1")

@ -39,6 +39,29 @@ the HTML limitation.
A workaround is below.. **use line numbers too!**.
#### Highlighting only 1 line {#highlighting-only-1-line}
##### Org source {#org-source}
```org
#+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 {#output}
{{< highlight emacs-lisp "hl_lines=2" >}}
(message "This is line 1")
(message "This is line 2")
(message "This is line 3")
{{< /highlight >}}
## With line numbers **not** starting from 1 {#source-blocks-with-highlighting-with-linenums-not-starting-from-1}
With line numbers enabled, the highlighting is limited to the width of

@ -1 +1 @@
Subproject commit 083f86e585548dbf9c0b3e00246f9daa6e87863f
Subproject commit 4f1f3d129b1043232f15c65cf4255d6f8dd6540b
Loading…
Cancel
Save