From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: How to get === on a line by itself to be a special string Date: Sun, 10 Feb 2013 10:01:20 +0100 Message-ID: <87wqugfspr.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:40259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4Sn5-0008R6-Jx for emacs-orgmode@gnu.org; Sun, 10 Feb 2013 04:01:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U4Sn4-0001nj-KI for emacs-orgmode@gnu.org; Sun, 10 Feb 2013 04:01:39 -0500 Received: from we-in-x0234.1e100.net ([2a00:1450:400c:c03::234]:48073 helo=mail-we0-x234.google.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4Sn4-0001nb-DY for emacs-orgmode@gnu.org; Sun, 10 Feb 2013 04:01:38 -0500 Received: by mail-we0-f180.google.com with SMTP id k14so4046314wer.11 for ; Sun, 10 Feb 2013 01:01:37 -0800 (PST) In-Reply-To: (Samuel Wales's message of "Sat, 9 Feb 2013 22:16:28 -0700") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Samuel Wales Cc: emacs-orgmode@gnu.org Hello, Samuel Wales 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 "=", 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 "

\n=\n

\n*" paragraph)) "
\n\n")) (add-to-list 'org-export-filter-paragraph-functions 'my-rule-markup) #+end_src Regards, -- Nicolas Goaziou