Exporting the following file to HTML yields the following:
#+PROPERTY: header-args :exports code
This code has many src_python{def}s.
This code has many def
s.
This renders as ~This code has many def s~, instead of the expected ~This code has many defs~. The extra space is due to the newline after before the closing tag in the HTML exported sources.
This newline is added by ~org-export-unravel-code~:
;; Get code and clean it. Remove blank lines at its
;; beginning and end.
(code (replace-regexp-in-string
"\\`\\([ \t]*\n\\)+" ""
(replace-regexp-in-string
"\\([ \t]*\n\\)*[ \t]*\\'" "\n"
(if (or org-src-preserve-indentation
(org-element-property :preserve-indent element))
value
(org-remove-indentation value)))))
The documentation of this function seems slightly wrong, too, as it gets passed elements of type ~inline-src-block~:
(defun org-export-unravel-code (element)
"Clean source code and extract references out of it.
ELEMENT has either a `src-block' an `example-block' type.
I'd be happy to provide a patch, but it's not clear that it's a good idea to always remove the last blank line, so I'd rather defer to experts on these matters :)
Cheers,
Clément.