Skip to content

Commit

Permalink
fix: Don't add blank line after a code block followed by para either
Browse files Browse the repository at this point in the history
Fixes #645.

This handles this case:

    1. item one
    2. This paragraph is followed by a source block, which is then
       followed by another paragraph.
       #+begin_src emacs-lisp
       (message "hey")
       #+end_src
       Paragraph following the source block in a list item.
  • Loading branch information
kaushalmodi committed May 27, 2022
1 parent 9471c21 commit ace25a6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
14 changes: 10 additions & 4 deletions ox-blackfriday.el
Original file line number Diff line number Diff line change
Expand Up @@ -751,9 +751,9 @@ to this rule:
paragraph and the next sub-list when the latter ends the
current item.
3. In an item, if a paragraph is immediately followed by an
src or example block, don't add a blank line after that
paragraph."
3. In an item, if a paragraph is immediately followed by an src
or example block (or vice-versa), don't add a blank line
between those elements."
(org-element-map tree (remq 'item org-element-all-elements) ;Exception 1 in the doc-string
(lambda (el)
(let ((post-blank (cond
Expand All @@ -765,12 +765,18 @@ to this rule:
(and (eq (org-element-type next-el) 'plain-list)
(not (org-export-get-next-element next-el info)))))
0)
;; Exception 3 in the doc-string.
;; Exception 3 in the doc-string (paragraph -> src-block).
((and (eq (org-element-type el) 'paragraph)
(eq (org-element-type (org-element-property :parent el)) 'item)
(let ((next-el (org-export-get-next-element el info)))
(memq (org-element-type next-el) '(src-block example-block))))
0)
;; Exception 3 in the doc-string (src-block -> paragraph).
((and (memq (org-element-type el) '(src-block example-block))
(eq (org-element-type (org-element-property :parent el)) 'item)
(let ((next-el (org-export-get-next-element el info)))
(memq (org-element-type next-el) '(paragraph))))
0)
(t
1))))
(org-element-put-property el :post-blank post-blank)
Expand Down
1 change: 0 additions & 1 deletion test/site/content/posts/code-fenced-src-blocks-default.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Here are few variables that you might like to change in the `local.mk`:
```makefile
prefix = /dir/where/you/want/to/install/org # Default: /usr/share
```

The `.el` files will go to `$(prefix)/emacs/site-lisp/org` by
default. If you'd like to change that, you can tweak the
`lispdir` variable.
Expand Down
1 change: 0 additions & 1 deletion test/site/content/posts/code-fenced-src-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Here are few variables that you might like to change in the `local.mk`:
```makefile
prefix = /dir/where/you/want/to/install/org # Default: /usr/share
```

The `.el` files will go to `$(prefix)/emacs/site-lisp/org` by
default. If you'd like to change that, you can tweak the
`lispdir` variable.
Expand Down
1 change: 0 additions & 1 deletion test/site/content/posts/highlight-shortcode-src-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Here are few variables that you might like to change in the `local.mk`:
{{< highlight makefile >}}
prefix = /dir/where/you/want/to/install/org # Default: /usr/share
{{< /highlight >}}

The `.el` files will go to `$(prefix)/emacs/site-lisp/org` by
default. If you'd like to change that, you can tweak the
`lispdir` variable.
Expand Down
1 change: 0 additions & 1 deletion test/site/content/posts/shortcode-src-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Here are few variables that you might like to change in the `local.mk`:
{{< highlight makefile >}}
prefix = /dir/where/you/want/to/install/org # Default: /usr/share
{{< /highlight >}}

The `.el` files will go to `$(prefix)/emacs/site-lisp/org` by
default. If you'd like to change that, you can tweak the
`lispdir` variable.
Expand Down

0 comments on commit ace25a6

Please sign in to comment.