Support #+attr_html and #+attr_css above fixed width blocks

Ref: https://github.com/kaushalmodi/ox-hugo/issues/319

Test page: https://ox-hugo.scripter.co/test/posts/org-babel-results/
master
Kaushal Modi 6 years ago
parent a9913113e0
commit 0530645d73
  1. 16
      ox-blackfriday.el
  2. 45
      test/site/content-org/all-posts.org
  3. 58
      test/site/content/posts/org-babel-results.md

@ -556,13 +556,15 @@ information."
(parent-type (car parent-element))
(backticks (make-string org-blackfriday--code-block-num-backticks ?`)))
(prog1
(format "%stext\n%s%s"
backticks
(let ((org-src-preserve-indentation t))
;; Preserve leading whitespace in the Org Babel Results
;; blocks.
(org-export-format-code-default fixed-width info))
backticks)
(org-blackfriday--div-wrap-maybe
fixed-width
(format "%stext\n%s%s"
backticks
(let ((org-src-preserve-indentation t))
;; Preserve leading whitespace in the Org Babel Results
;; blocks.
(org-export-format-code-default fixed-width info))
backticks))
(when (equal 'quote-block parent-type)
;; If the current example block is inside a quote block,
;; future example/code blocks (especially the ones outside

@ -1539,7 +1539,11 @@ blocks:
:PROPERTIES:
:EXPORT_FILE_NAME: org-babel-results
:END:
*** Small Results block
#+begin_description
Testing the export of Org Babel ~#+results:~ blocks with and without
wrapping with HTML attributes.
#+end_description
*** "Fixed block" Results block
Below also tests that the indentation in *results* blocks is
preserved.
@ -1553,12 +1557,24 @@ print(str[1:])
The whitespace before "bc" in the results block above should be
preserved.
*** Big Results block
**** "Fixed block" Results block with ~#+attr_html~
#+begin_src python :exports both :results output
str = 'd\tef'
print(str[1:])
#+end_src
#+attr_html: :class results-fixed-block
#+attr_css: :color blue
#+results:
: ef
Above results block will be in _blue_ text.
*** "Example block" Results block
#+begin_src nim :exports both :results output
echo "abc\ndef\nghi\njkl\nmno\npqr\nstu\nvwx\nyz0\n123\n456\n789"
#+end_src
#+RESULTS:
#+results:
#+begin_example
abc
def
@ -1573,7 +1589,30 @@ yz0
456
789
#+end_example
**** "Example block" Results block with ~#+attr_html~
#+begin_src nim :exports both :results output
echo "ABC\nDEF\nGHI\nJKL\nMNO\nPQR\nSTU\nVWX\nYZ0\n123\n456\n789"
#+end_src
#+attr_html: :class results-example-block
#+attr_css: :color green
#+results:
#+begin_example
ABC
DEF
GHI
JKL
MNO
PQR
STU
VWX
YZ0
123
456
789
#+end_example
Above results block will be in _green_ text.
** Indented source block :indented:lists:code_fence:highlight:src_block:@upstream:
:PROPERTIES:
:EXPORT_FILE_NAME: source-block-indented

@ -1,10 +1,14 @@
+++
title = "Org Babel Results"
description = """
Testing the export of Org Babel `#+results:` blocks with and without
wrapping with HTML attributes.
"""
tags = ["src-block", "babel", "results", "indentation", "example-block", "fixed-block"]
draft = false
+++
## Small Results block {#small-results-block}
## "Fixed block" Results block {#fixed-block-results-block}
Below also tests that the indentation in **results** blocks is
preserved.
@ -22,7 +26,27 @@ The whitespace before "bc" in the results block above should be
preserved.
## Big Results block {#big-results-block}
### "Fixed block" Results block with `#+attr_html` {#fixed-block-results-block-with-plus-attr-html}
```python
str = 'd\tef'
print(str[1:])
```
<style>.results-fixed-block { color: blue; }</style>
<div class="results-fixed-block">
<div></div>
```text
ef
```
</div>
Above results block will be in <span class="underline">blue</span> text.
## "Example block" Results block {#example-block-results-block}
```nim
echo "abc\ndef\nghi\njkl\nmno\npqr\nstu\nvwx\nyz0\n123\n456\n789"
@ -42,3 +66,33 @@ yz0
456
789
```
### "Example block" Results block with `#+attr_html` {#example-block-results-block-with-plus-attr-html}
```nim
echo "ABC\nDEF\nGHI\nJKL\nMNO\nPQR\nSTU\nVWX\nYZ0\n123\n456\n789"
```
<style>.results-example-block { color: green; }</style>
<div class="results-example-block">
<div></div>
```text
ABC
DEF
GHI
JKL
MNO
PQR
STU
VWX
YZ0
123
456
789
```
</div>
Above results block will be in <span class="underline">green</span> text.

Loading…
Cancel
Save