Skip to content

Commit

Permalink
Preserve leading whitespace in Org Babel Result block exports
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushalmodi committed Aug 9, 2017
1 parent 841255a commit f0becd6
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
13 changes: 13 additions & 0 deletions example-site/content-org/all-posts.org
Expand Up @@ -405,6 +405,19 @@ code block does not have Markdown syntax lists.
#+BEGIN_SRC md
- list 1
#+END_SRC
** Org Babel Results
:PROPERTIES:
:EXPORT_FILE_NAME: org-babel-results-preserve-indent
:END:
#+BEGIN_SRC python :exports both :results output
str = 'a\tbc'
print(str[1:])
#+END_SRC

#+RESULTS:
: bc

The whitespace before "bc" in the results block above should be preserved.
** Org Source Block :noexport:
:PROPERTIES:
:EXPORT_FILE_NAME: org-source-block
Expand Down
16 changes: 16 additions & 0 deletions example-site/content/posts/org-babel-results-preserve-indent.md
@@ -0,0 +1,16 @@
+++
title = "Org Babel Results"
tags = ["src-block"]
draft = false
+++

```python
str = 'a\tbc'
print(str[1:])
```

```text
bc
```

The whitespace before "bc" in the results block above should be preserved.
12 changes: 12 additions & 0 deletions ox-blackfriday.el
Expand Up @@ -77,6 +77,7 @@ inserted after the first row of the table.")
(if a (org-blackfriday-export-to-markdown t s v)
(org-open-file (org-blackfriday-export-to-markdown nil s v)))))))
:translate-alist '((example-block . org-blackfriday-example-block)
(fixed-width . org-blackfriday-fixed-width) ;Org Babel Results
(inner-template . org-blackfriday-inner-template)
(italic . org-blackfriday-italic)
(item . org-blackfriday-item)
Expand Down Expand Up @@ -212,6 +213,17 @@ information."
(format "```text\n%s```"
(org-export-format-code-default example-block info)))

;;;; Fixed Width
(defun org-blackfriday-fixed-width (fixed-width _contents info)
"Transcode a FIXED-WIDTH element into Blackfriday Markdown format.
CONTENTS is nil. INFO is a plist holding contextual
information."
(format "```text\n%s```"
(let ((org-src-preserve-indentation t))
;; Preserve leading whitespace in the Org Babel Results
;; blocks.
(org-export-format-code-default fixed-width info))))

;;;; Inner Template
(defun org-blackfriday-inner-template (contents info)
"Return body of document after converting it to Markdown syntax.
Expand Down

0 comments on commit f0becd6

Please sign in to comment.