emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* possible fix for a bug in org-mode html export
@ 2020-05-06 15:29 bpanthi
  2020-05-16 17:30 ` Nicolas Goaziou
  0 siblings, 1 reply; 3+ messages in thread
From: bpanthi @ 2020-05-06 15:29 UTC (permalink / raw)
  To: emacs-orgmode


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

When exporting an org file containing latex fragments with option

#+OPTIONS: tex:dvipng

in the html file the png image src attribute's value is not a valid URI. 
<img src="e:/dir/sth.png" ...>  while it should be <img 
src="file:///e:/dir/sth.png" ...>  for the browser to work. In my config 
I have  (setq org-preview-latex-image-directory "E:/tmp/ltximg/") so 
that all images are created in a single directory and don't clutter my 
org file directory.

I fixed this issue for me by modifying `org-html--format-image' function 
of ox-html.el file as follow:

(defun org-html--format-image (source attributes info)
   "Return \"img\" tag with given SOURCE and ATTRIBUTES.
SOURCE is a string specifying the location of the image.
ATTRIBUTES is a plist, as returned by
`org-export-read-attribute'.  INFO is a plist used as
a communication channel."
   (if (string= "svg" (file-name-extension source))
       (org-html--svg-image source attributes info)
     (org-html-close-tag
      "img"
      (org-html--make-attribute-string
       (org-combine-plists
        (list :src (concat "file:///" source)
	     :alt (if (string-match-p "^ltxpng/" source)
		      (org-html-encode-plain-text
		       (org-find-text-property-in-string 'org-latex-src source))
		    (file-name-nondirectory source)))
        attributes))
      info)))

I just changed (list :src source ...) to (list :src (concat "file:///" 
source).

I don't know if it is an acceptable way or it further causes bugs in 
other places.
Hope that this will find the proper way and fix it.

(emacs-version) = "GNU Emacs 26.3 (build 1, x86_64-w64-mingw32) of 2019-11-01"
(org-version) = "9.3.6"

Emacs Admirer,
Bibek Panthi


[-- Attachment #1.2: Type: text/html, Size: 2201 bytes --]

[-- Attachment #2: sample.org --]
[-- Type: text/plain, Size: 243 bytes --]

#+OPTIONS: tex:dvipng

* Vector Subspace
+ Subspace :: A subspace of a vector space $V$ is a subset $S \subset V$
  such that $S$ itself is a vector space. (i.e. it must be closed
  under addition, and scaling and thus also include $0$)

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

end of thread, other threads:[~2020-05-17  3:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-06 15:29 possible fix for a bug in org-mode html export bpanthi
2020-05-16 17:30 ` Nicolas Goaziou
2020-05-17  3:18   ` Bibek Panthi

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).