I’ve been experimenting with adding highlights to text in my daily posts. The idea is that it makes scanning easier. I pick out the important parts of each entry and add a <mark> HTML tag. Then I style the region like so:

1
2
3
mark {
  background: rgba(255, 255, 0, 0.3);
}

Recently, there’s been a change in org that broke my markup when exporting from ox-hugo. Here’s the comment by kaushalmodi:

Issue #540

This was a recent breaking change that fixed an inconsistency in ox-hugo (compared to ox-html). If we want to export verbatim HTML, it needs to be in .. or in an HTML export block

His suggestion to use a macro was excellent, so I did that. At the top of my posts.org file, is this:

#+macro: mark @@html:<mark>$1</mark>@@

When I want to <mark> some text, I add the macro inline, like so:

I would like to {{{mark(mark this text)}}} so that it is highlighted

But who has time to add all that markup by hand? To make it easier, I created the following function:

1
2
3
4
5
6
7
8
9
(defun jab/markregion ()
  "Add a 'mark' macro to the current region (for Hugo)"
  (interactive)
  (if (region-active-p)
      (progn
        (goto-char (region-end))
        (insert ")}}}")
        (goto-char (region-beginning))
        (insert "{{{mark("))))

Now, I select a region and run M-x jab/markregion. I may create a keybinding for it, too, but for now this is fast and easy.