emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How to get === on a line by itself to be a special string
@ 2013-02-10  5:16 Samuel Wales
  2013-02-10  9:01 ` Nicolas Goaziou
  0 siblings, 1 reply; 3+ messages in thread
From: Samuel Wales @ 2013-02-10  5:16 UTC (permalink / raw)
  To: emacs-orgmode

I want separators like this:

===

to be treated as a special string in HTML.  This was the
case in the old exporter.

org-html-special-string-regexps is a variable defined in `ox-html.el'.
Its value is (("^-----$" . "<hr/>")
 ("---\\([^-]\\|$\\)" . "&mdash;\\1")
 ("--\\([^-]\\|$\\)" . "&mdash;\\1")
 ("^===$" . "<hr width=\"10%\"
style=\"width:10%;color:#000;background-color:#000;height:1px;border:none\"
/>")
 ("\\\\-" . "&shy;")
 ("---\\([^-]\\)" . "&mdash;\\1")
 ("--\\([^-]\\)" . "&ndash;\\1")
 ("\\.\\.\\." . "&hellip;"))

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?

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)))

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to get === on a line by itself to be a special string
  2013-02-10  5:16 How to get === on a line by itself to be a special string Samuel Wales
@ 2013-02-10  9:01 ` Nicolas Goaziou
  2013-02-12 19:02   ` Samuel Wales
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Goaziou @ 2013-02-10  9:01 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

Hello,

Samuel Wales <samologist@gmail.com> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to get === on a line by itself to be a special string
  2013-02-10  9:01 ` Nicolas Goaziou
@ 2013-02-12 19:02   ` Samuel Wales
  0 siblings, 0 replies; 3+ messages in thread
From: Samuel Wales @ 2013-02-12 19:02 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

On 2/10/13, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
> (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)

I think this restores the behavior.  Thank you.

Samuel

-- 
The Kafka Pandemic: http://thekafkapandemic.blogspot.com

The disease DOES progress.  MANY people have died from it.  ANYBODY
can get it.  There is no hope without action.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-02-12 19:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-10  5:16 How to get === on a line by itself to be a special string Samuel Wales
2013-02-10  9:01 ` Nicolas Goaziou
2013-02-12 19:02   ` Samuel Wales

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).