emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rodrigo Morales <rodrigo@morales.pe>
To: <emacs-orgmode@gnu.org>
Subject: HTML export: Force links that end in .jpg or .png to be exported as a tags
Date: Wed, 17 Jul 2024 10:00:41 -0500	[thread overview]
Message-ID: <87sew8rrl2.fsf@morales.pe> (raw)


Consider the following Org document:

#+HEADER: :tangle /tmp/a.org
#+BEGIN_SRC org
,#+TITLE: My document
,#+DATE: 2024-07-17

This is a link that ends in html: foo https://example.org/a.html bar

This is a link that ends in txt: foo https://example.org/a.txt bar

This is a link that ends in jpg: foo https://example.org/a.jpg bar

This is a link that ends in png: foo https://example.org/a.png bar
#+END_SRC

I started Emacs using the following command:

#+BEGIN_SRC sh
emacs \
  --quick \
  --eval='(find-file "/tmp/a.org")' \
  --eval='(org-html-export-as-html)'
#+END_SRC

The following code block shows the relevant content in the buffer =*Org HTML Export*=.

#+BEGIN_SRC html
<div id="content" class="content">
<h1 class="title">My document</h1>
<p>
This is a link that ends in html: foo <a href="https://example.org/a.html">https://example.org/a.html</a> bar
</p>

<p>
This is a link that ends in txt: foo <a href="https://example.org/a.txt">https://example.org/a.txt</a> bar
</p>

<p>
This is a link that ends in jpg: foo <img src="https://example.org/a.jpg" alt="a.jpg" /> bar
</p>

<p>
This is a link that ends in png: foo <img src="https://example.org/a.png" alt="a.png" /> bar
</p>
</div>
#+END_SRC

As we can see above, links that end in =html= or =txt= are exported as =a= tags, while links that end in =jpg= or =png= are exported as =img= tags.

I want links that end in =.jpg= or =.png= to also be =a= tags. The
reason is that in my use case, I need to display a link (i.e. a =a= tag)
inside a paragraph of an image hosted at Wikimedia Commons in the HTML
export. For example: https://commons.wikimedia.org/wiki/File:Banana_on_whitebackground.jpg

My question is: How to force a link that end in =.jpg= or =.png= to be exported as a =a= tag instead of an =img= tag?


             reply	other threads:[~2024-07-17 15:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-17 15:00 Rodrigo Morales [this message]
2024-07-17 15:06 ` HTML export: Force links that end in .jpg or .png to be exported as a tags Ihor Radchenko

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=87sew8rrl2.fsf@morales.pe \
    --to=rodrigo@morales.pe \
    --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).