Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spurious file: prefixes while generating <img> tags #5

Open
pinard opened this issue Mar 18, 2014 · 0 comments
Open

Spurious file: prefixes while generating <img> tags #5

pinard opened this issue Mar 18, 2014 · 0 comments

Comments

@pinard
Copy link
Contributor

pinard commented Mar 18, 2014

Masafumi? Still me...

This one may be debatable somehow, I'm not sure. Currently, org-js includes the file: prefix coming out of Org into the generated HTML. For example, from this file:

#+TITLE: OK
[[file:image.png]]

I get this HTML while going through org-js:

<h1>OK</h1>
<ul></ul>

<img src="file:image.png" alt="file:image.png" title="file:image.png"/>

This generated code is not understood by browsers. The Emacs HTML exporter assumes that a file in the same directory is meant to be available in the directory where the corresponding HTML will be. I cannot ignore this problem, as there are 1500 such image references in the set of Org files I'm currently handling.

So, around this difficulty, I made a publish script with this content:

#!/bin/sh

org=$1
if test -z "$2"; then
  html=`echo $1 | sed 's/.org$/.html/'`
else
  html=$2
fi

if etc/org2html < $org | sed > $html-tmp 's/="file:/="/g'; then
  mv $html-tmp $html
else
  rm $html-tmp
  exit 1
fi

(OK, I know, this script is buggy, because the if tests the exit status from sed rather than the exit status of org2html. Do not bash me too severly, I'm only half-guilty: I consider that the sed is a temporary measure!)

I would presume that org-js would be a nice guy if it was dropping the file: itself.

François

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant