emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Bug? org-export-unravel-code inserts a spurious newline at end of in


From: Clément Pit--Claudel
Subject: [O] Bug? org-export-unravel-code inserts a spurious newline at end of inline-src-block elements
Date: Sat, 27 Aug 2016 18:44:05 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

Exporting the following file to HTML yields the following:

    #+PROPERTY: header-args :exports code
    This code has many src_python{def}s.

    <p>
    This code has many <code class="src src-python"><span style="color: 
#b4fa70;">def</span>
    </code>s.
    </p>

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 
</code> 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.

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]