Skip to content

Commit

Permalink
Fix for ws trimming around a special block before/after code block
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushalmodi committed Jan 25, 2022
1 parent ea2f065 commit 171667f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
6 changes: 3 additions & 3 deletions ox-hugo.el
Original file line number Diff line number Diff line change
Expand Up @@ -1831,10 +1831,10 @@ holding export options."
(concat (org-hugo--build-toc info toc-level) "\n")
""))
(contents (replace-regexp-in-string ;Trim stuff before selected exported elements
(concat "\\([[:space:]>]\\|\n\\)+" (regexp-quote org-hugo--trim-pre-marker))
" " contents))
(concat "\\([^`]\\)\\([[:space:]>]\\|\n\\)+" (regexp-quote org-hugo--trim-pre-marker))
"\\1 " contents))
(contents (replace-regexp-in-string ;Trim stuff after selected exported elements
(concat (regexp-quote org-hugo--trim-post-marker) "\\([[:space:]>]\\|\n\\)+\\([^-#]\\)")
(concat (regexp-quote org-hugo--trim-post-marker) "\\([[:space:]>]\\|\n\\)+\\([^-#`]\\)")
" \\2" contents)))
;; (message "[org-hugo-inner-template DBG] toc-level: %s" toc-level)
(org-trim (concat
Expand Down
20 changes: 19 additions & 1 deletion test/site/content-org/all-posts.org
Original file line number Diff line number Diff line change
Expand Up @@ -4860,7 +4860,7 @@ line 1
abc def
#+end_sidenote<>
line 2
*** Whitespace trimming around special blocks (corner cases) :quotes:
*** Whitespace trimming around special blocks (corner cases)
:PROPERTIES:
:EXPORT_FILE_NAME: ws-trimming-around-special-blocks-corner-cases
:END:
Expand All @@ -4885,6 +4885,24 @@ something
marked text
#+end_mark<>
***** Next heading
**** Whitespace trimming before and after code blocks
something
#+begin_mark<>
marked text
#+end_mark<>
#+begin_example
code line
#+end_example
#+begin_mark<>
marked text
#+end_mark<>

something
~inline code 1~
#+begin_mark<>
marked text
#+end_mark<>
~inline code 2~
* Shortcodes :shortcode:
** Alert CSS :noexport:
*** Common CSS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
+++
title = "Whitespace trimming around special blocks (corner cases)"
tags = ["special-block", "whitespace", "trimming", "quotes"]
tags = ["special-block", "whitespace", "trimming"]
draft = false
+++

Expand All @@ -20,3 +20,15 @@ something <mark>marked text</mark>

something <mark>marked text</mark>
### Next heading {#next-heading}


## Whitespace trimming before and after code blocks {#whitespace-trimming-before-and-after-code-blocks}

something <mark>marked text</mark>
```text
code line
```
<mark>marked text</mark> something
`inline code 1`
<mark>marked text</mark>
`inline code 2`

0 comments on commit 171667f

Please sign in to comment.