Skip to content

Commit

Permalink
Preserve line breaks from Org source
Browse files Browse the repository at this point in the history
Fixes #527.

This feature is like the site-wide Goldmark config (ref:
#526 (comment)):

    [markup.goldmark.renderer]
      hardWraps = true

.. but using the "\n:t" export option, this feature can be enabled
only for specific posts.
  • Loading branch information
kaushalmodi committed Jan 15, 2022
1 parent 79f0fdd commit a077adf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ox-blackfriday.el
Expand Up @@ -994,7 +994,7 @@ matches with \"\\\" as needed."
(setq text (org-html-convert-special-strings text)))
;; Handle break preservation, if required.
(when (plist-get info :preserve-breaks)
(setq text (replace-regexp-in-string "[ \t]*\n" " \n" text)))
(setq text (replace-regexp-in-string "[ \t]*\n" " <br/>\n" text)))
;; Return value.
text)

Expand Down
8 changes: 8 additions & 0 deletions test/site/content-org/all-posts.org
Expand Up @@ -6359,6 +6359,14 @@ The front-matter for this post contains the default Creator string.
:EXPORT_FILE_NAME: custom-creator
:END:
The front-matter for this post contains a custom Creator string.
** Preserve Breaks :preserve_breaks:
:PROPERTIES:
:EXPORT_FILE_NAME: preserve-breaks
:EXPORT_OPTIONS: \n:t
:END:
abc
def
ghi
* Export snippets and blocks
** Export snippet :export_snippet:
*** Export snippet Hugo :hugo:
Expand Down
9 changes: 9 additions & 0 deletions test/site/content/posts/preserve-breaks.md
@@ -0,0 +1,9 @@
+++
title = "Preserve Breaks"
tags = ["export-option", "preserve-breaks"]
draft = false
+++

abc <br/>
def <br/>
ghi

0 comments on commit a077adf

Please sign in to comment.