2

I'm trying to migrate my current blogging platform (Pelican) where I wrote the posts using Markdown to a one based in org-mode (still considering how).

One of the problems that I found is that I have used the <abbr> HTML tag in several of my articles --thanks to the Markdown Extra markup *[abbr]: definition that I could use with Pelican-- but I can not find a way in org-mode to export that tag.

Is there any way to generate this tag from org-mode?

5

I guess the simplest way is to define a macro in your orgmode file with:

#+MACRO: abbr @@html:<abbr title="$1">$2</abbr>@@

You can then add an abbr in your text with:

{{{abbr(Definition, abbreviation)}}}

Edit:

This is probably the better solution: Add a special tag for abbr:

(defun org-export-abbr (backend)
  "Replace {abbreviation|description} to <abbr> html text in
current buffer"
  (when (equal backend 'html)
    (save-excursion
      (beginning-of-buffer)
      (replace-regexp "{\\(.*?\\)|\\(.*?\\)}"
                      "@@html:<abbr title=\"\\2\">\\1</abbr>@@"))))

(add-hook 'org-export-before-parsing-hook 'org-export-abbr)

This will replace occurence of {abbreviation|description} into an abbr tag on HTML export.

  • 2
    #+HTML does not work in-line. For inlining the format should be @@html:<abbr>@@ according to orgmode.org/manual/Quoting-HTML-tags.html#Quoting-HTML-tags – Juancho May 22 '15 at 22:17
  • It is not as nicest as the Markdown Extra solution but it works (if we do what @Juancho mentioned) and I suppose that I could make a snippet to make it easier to use. Thanks! – joe di castro May 22 '15 at 22:49
  • 1
    See my second solution. Probably a lot more convenient. @Juancho Thx for the correction. – Plankalkül May 22 '15 at 22:56
  • 1
    Well, I don't know if there is a way to avoid to replace that expression on the SRC, EXAMPLE, LaTeX, blocks, etcetera but I had to make a tweak in the regexp to avoid to replace a Jinja expression like this {% foo|bar -%} by an HTML abbr tag in a SRC block. I took the easy way to do the trick: "{[^%]\\(.*?\\)|\\(.*?\\)}" – joe di castro May 29 '15 at 19:10
  • 1
    Sorry, I made a mistake in the previous comment with the regexp, the right one is this "{\\([^%].*?\\)|\\(.*?\\)}" – joe di castro May 31 '15 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.