I've figured out something that works but isn't perfect.
#+BEGIN_SRC emacs-lisp :var text="" :var width="100%" :var height="100%" :results raw
(concat "#+ATTR_HTML: :width " width " :height " height "\n[[file:" text "]]")
Then I can set the
:results of a src block to
raw and add that emacs-lisp src block as a
:post header arg.
#+BEGIN_SRC python :noweb-ref test-detect-table :noweb yes :results raw :post html-image-size(text=*this*, width="300px")
image_filename = "resources/examples/example-page.png"
image = cv2.imread(image_filename, cv2.IMREAD_GRAYSCALE)
image = find_tables(image)
That is almost perfect. The only thing I've noticed that I lose is
org-babel-remove-result no longer works. It just removes the
#+RESULTS: line while the file link remains.
Anyone know of a solution to that?
Edit: Found a solution.
There's no configurable option. There is a
defconst regex that org-babel uses to find the start/end of result blocks. But I wrote a function to remove the
#+ATTR.* lines that were causing the built-in regex to fail.
(defun remove-attributes-from-src-block-result (&rest args)
(let ((location (org-babel-where-is-src-block-result))
(attr-regexp "[ ]*#\\+ATTR.*$"))
(when (looking-at (concat org-babel-result-regexp ".*$"))
(while (looking-at attr-regexp)
(advice-add 'org-babel-remove-result :before #'remove-attributes-from-src-block-result)
(advice-add 'org-babel-execute-src-block :before #'remove-attributes-from-src-block-result)