Hi When I use org-mime-htmlize, then I can use the setting Render text between "@" in red color, you can use =org-mime-html-hook=, #+begin_src elisp (add-hook 'org-mime-html-hook (lambda () (while (re-search-forward "@\\([^@]*\\)@" nil t) (replace-match "<span style=\"color:red\">\\1</span>")))) #+end_src And every text between @ appears red. Can I have a similar setting when exporting an org file to html via the «normal» html exporter? Thanks Uwe Brauer
[-- Attachment #1: Type: text/plain, Size: 348 bytes --] Hi Uwe, > And every text between @ appears red. > > Can I have a similar setting when exporting an org file to html via the > «normal» html exporter? Have a look at the filter functions, such as `org-export-filter-final-output-functions'. See <https://orgmode.org/manual/Advanced-Export-Configuration.html>. All the best, Timothy
Uwe Brauer writes:
> Can I have a similar setting when exporting an org file to html via the
> «normal» html exporter?
Using a custom filter?
#+begin_src emacs-lisp
(defun foo (text backend info)
(when (org-export-derived-backend-p backend 'html)
(replace-regexp-in-string "@\\([^@]*\\)@"
"<span style=\"color:red\">\\1</span>"
text)))
(add-to-list 'org-export-filter-final-output-functions 'foo)
#+end_src
Best regards,
Juan Manuel
[-- Attachment #1: Type: text/plain, Size: 967 bytes --] >>> "JMM" == Juan Manuel Macías <maciaschain@posteo.net> writes: > Uwe Brauer writes: >> Can I have a similar setting when exporting an org file to html via the >> «normal» html exporter? > Using a custom filter? > #+begin_src emacs-lisp > (defun foo (text backend info) > (when (org-export-derived-backend-p backend 'html) > (replace-regexp-in-string "@\\([^@]*\\)@" > "<span style=\"color:red\">\\1</span>" > text))) > (add-to-list 'org-export-filter-final-output-functions 'foo) > #+end_src Thanks very much it works as expected. However I just realized (and this is true also for the org-mime filter that the reg-exp has a flaw. I used the text =email:oub@mat.ucm.es= So there is only one @, nevertheless the exporter translated that to <code>email:oub<span style="color:red">mat.ucm.es</code><br /> But this is wrong in my view. Any ideas how to deal with such a situation? Thanks Uwe [-- Attachment #2: smime.p7s --] [-- Type: application/pkcs7-signature, Size: 5673 bytes --]
[-- Attachment #1: Type: text/plain, Size: 438 bytes --] >>> "T" == Timothy <tecosaur@gmail.com> writes: Hi Timothy > Hi Uwe, >> And every text between @ appears red. >> >> Can I have a similar setting when exporting an org file to html via the >> «normal» html exporter? > Have a look at the filter functions, such as > `org-export-filter-final-output-functions'. See > <https://orgmode.org/manual/Advanced-Export-Configuration.html>. Thanks, Juan already solved it, thanks. [-- Attachment #2: smime.p7s --] [-- Type: application/pkcs7-signature, Size: 5673 bytes --]
Uwe Brauer writes:
> Thanks very much it works as expected. However I just realized (and
> this is true also for the org-mime filter that the reg-exp has a flaw.
>
> I used the text
>
>
> =email:oub@mat.ucm.es=
>
> So there is only one @, nevertheless the exporter translated that to
> <code>email:oub<span style="color:red">mat.ucm.es</code><br />
>
> But this is wrong in my view.
>
> Any ideas how to deal with such a situation?
You can bind the function to org-export-filter-plain-text-functions
instead of ...-final-output-functions.
That way you wouldn't get false positives on lines like:
=email:oub@mat.ucm.es= some text @some text@
<code>email:oub@mat.ucm.es</code> some text <span style="color:red">some text</span>
Best regards,
Juan Manuel
[-- Attachment #1: Type: text/plain, Size: 983 bytes --] >>> "JMM" == Juan Manuel Macías <maciaschain@posteo.net> writes: > Uwe Brauer writes: >> Thanks very much it works as expected. However I just realized (and >> this is true also for the org-mime filter that the reg-exp has a flaw. >> >> I used the text >> >> >> =email:oub@mat.ucm.es= >> >> So there is only one @, nevertheless the exporter translated that to >> <code>email:oub<span style="color:red">mat.ucm.es</code><br /> >> >> But this is wrong in my view. >> >> Any ideas how to deal with such a situation? > You can bind the function to org-export-filter-plain-text-functions > instead of ...-final-output-functions. Perfect, thanks. Just out of curiosity because google does not know the answer There is (add-hook 'some-hook 'some-function) (remove-hook 'some-hook 'some-function) So if I have (add-to-list 'org-export-filter-plain-text-functions 'my-html-red) How could I remove something from a list? Regards Uwe [-- Attachment #2: smime.p7s --] [-- Type: application/pkcs7-signature, Size: 5673 bytes --]
Uwe Brauer writes:
> (add-to-list 'org-export-filter-plain-text-functions 'my-html-red)
>
> How could I remove something from a list?
I think this would work:
(setq org-export-filter-plain-text-functions
(remove 'my-html-red org-export-filter-plain-text-functions))
Anyway, I recommend that you take a look at the documentation on filters
that Timothy pointed you to, as custom filters are tremendously useful
and versatile, and very "surgical". I use them a lot!
You can also apply a filter only in a document, by using the #+bind
keyword and including the function in a non-exportable code block:
#+begin_src emacs-lisp :exports results :results none
(defun my-html-red (text backend info)
(when (org-export-derived-backend-p backend 'html)
(replace-regexp-in-string "@\\([^@]*\\)@"
"<span style=\"color:red\">\\1</span>"
text)))
#+end_src
#+bind: org-export-filter-plain-text-functions (my-html-red)
(You need to set org-export-allow-bind-keywords to non-nil)
Best regards,
Juan Manuel
[-- Attachment #1: Type: text/plain, Size: 1022 bytes --] >>> "JMM" == Juan Manuel Macías <maciaschain@posteo.net> writes: > I think this would work: > (setq org-export-filter-plain-text-functions > (remove 'my-html-red org-export-filter-plain-text-functions)) > Anyway, I recommend that you take a look at the documentation on filters > that Timothy pointed you to, as custom filters are tremendously useful > and versatile, and very "surgical". I use them a lot! > You can also apply a filter only in a document, by using the #+bind > keyword and including the function in a non-exportable code block: > #+begin_src emacs-lisp :exports results :results none > (defun my-html-red (text backend info) > (when (org-export-derived-backend-p backend 'html) > (replace-regexp-in-string "@\\([^@]*\\)@" > "<span style=\"color:red\">\\1</span>" > text))) > #+end_src > #+bind: org-export-filter-plain-text-functions (my-html-red) > (You need to set org-export-allow-bind-keywords to non-nil) Thanks very much!!! Regards Uwe [-- Attachment #2: smime.p7s --] [-- Type: application/pkcs7-signature, Size: 5673 bytes --]