all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Bug? org-export-unravel-code inserts a spurious newline at end of inline-src-block elements
@ 2016-08-27 22:44 Clément Pit--Claudel
  2016-08-28 10:04 ` Nicolas Goaziou
  0 siblings, 1 reply; 2+ messages in thread
From: Clément Pit--Claudel @ 2016-08-27 22:44 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1435 bytes --]

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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bug? org-export-unravel-code inserts a spurious newline at end of inline-src-block elements
  2016-08-27 22:44 Bug? org-export-unravel-code inserts a spurious newline at end of inline-src-block elements Clément Pit--Claudel
@ 2016-08-28 10:04 ` Nicolas Goaziou
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2016-08-28 10:04 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: emacs-orgmode

Hello,

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

The documentation is correct. `org-export-unravel-code' is not meant to
be called on inline source blocks since they cannot contain coderefs.

I fixed "ox-html.el" accordingly. Thank you.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-08-28 10:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-27 22:44 Bug? org-export-unravel-code inserts a spurious newline at end of inline-src-block elements Clément Pit--Claudel
2016-08-28 10:04 ` Nicolas Goaziou

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.