emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] How to get === on a line by itself to be a special string


From: Nicolas Goaziou
Subject: Re: [O] How to get === on a line by itself to be a special string
Date: Sun, 10 Feb 2013 10:01:20 +0100

Hello,

Samuel Wales <address@hidden> writes:

> I want separators like this:
>
> ===
>
> to be treated as a special string in HTML.  This was the
> case in the old exporter.

[...]

> I don't want them to be interpreted as code.  I don't want
> to turn off all code just to get this one thing to work.  I don't want
> to do ~===~.
>
> Does this mean some filter has to be used?

There are a few solutions to your problem: a macro, a hook, a filter...

> This did not work.
>
> (add-to-list 'org-export-filter-code-functions
>        (lambda (text back-end &rest _rest)
>          (if (eq back-end 'html)
>              (replace-regexp-in-string "^===$" "~===~" text)
>            text)))

That's because `html' back-end never returns "^===$", but
"<code>=</code>", as "=" is a verbatim marker. Also, the output of
a filter function will appear in the final output. I doubt that you want
"~===~" to appear in your HTML document.

Here is one solution, with a filter:

#+begin_src emacs-lisp
(defun my-rule-markup (paragraph backend info)
  (when (and (org-export-derived-backend-p backend 'html)
             (string-match "<p>\n<code>=</code>\n</p>\n*" paragraph))
    "<hr width=\"10%\" 
style=\"width:10%;color:#000;background-color:#000;height:1px;border:none\"/>\n\n"))
(add-to-list 'org-export-filter-paragraph-functions 'my-rule-markup)
#+end_src


Regards,

-- 
Nicolas Goaziou



reply via email to

[Prev in Thread] Current Thread [Next in Thread]