emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: bpanthi <bpanthi977@gmail.com>
To: emacs-orgmode@gnu.org
Subject: possible fix for a bug in org-mode html export
Date: Wed, 6 May 2020 21:14:14 +0545	[thread overview]
Message-ID: <6c6618d6-16bc-c76e-7f6c-24b5fb7f324e@gmail.com> (raw)


[-- 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$)

             reply	other threads:[~2020-05-16 15:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06 15:29 bpanthi [this message]
2020-05-16 17:30 ` possible fix for a bug in org-mode html export Nicolas Goaziou
2020-05-17  3:18   ` Bibek Panthi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6c6618d6-16bc-c76e-7f6c-24b5fb7f324e@gmail.com \
    --to=bpanthi977@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).