* org-->html text between @ should be red.
@ 2022-01-15 18:04 Uwe Brauer
2022-01-15 18:20 ` Timothy
2022-01-15 18:21 ` Juan Manuel Macías
0 siblings, 2 replies; 9+ messages in thread
From: Uwe Brauer @ 2022-01-15 18:04 UTC (permalink / raw)
To: emacs-orgmode
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: org-->html text between @ should be red.
2022-01-15 18:04 org-->html text between @ should be red Uwe Brauer
@ 2022-01-15 18:20 ` Timothy
2022-01-15 19:39 ` Uwe Brauer
2022-01-15 18:21 ` Juan Manuel Macías
1 sibling, 1 reply; 9+ messages in thread
From: Timothy @ 2022-01-15 18:20 UTC (permalink / raw)
To: Uwe Brauer; +Cc: emacs-orgmode
[-- 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: org-->html text between @ should be red.
2022-01-15 18:04 org-->html text between @ should be red Uwe Brauer
2022-01-15 18:20 ` Timothy
@ 2022-01-15 18:21 ` Juan Manuel Macías
2022-01-15 19:39 ` Uwe Brauer
1 sibling, 1 reply; 9+ messages in thread
From: Juan Manuel Macías @ 2022-01-15 18:21 UTC (permalink / raw)
To: Uwe Brauer; +Cc: orgmode
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: org-->html text between @ should be red.
2022-01-15 18:21 ` Juan Manuel Macías
@ 2022-01-15 19:39 ` Uwe Brauer
2022-01-15 19:59 ` Juan Manuel Macías
0 siblings, 1 reply; 9+ messages in thread
From: Uwe Brauer @ 2022-01-15 19:39 UTC (permalink / raw)
To: emacs-orgmode
[-- 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 --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: org-->html text between @ should be red.
2022-01-15 18:20 ` Timothy
@ 2022-01-15 19:39 ` Uwe Brauer
0 siblings, 0 replies; 9+ messages in thread
From: Uwe Brauer @ 2022-01-15 19:39 UTC (permalink / raw)
To: emacs-orgmode
[-- 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 --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: org-->html text between @ should be red.
2022-01-15 19:39 ` Uwe Brauer
@ 2022-01-15 19:59 ` Juan Manuel Macías
2022-01-15 20:24 ` Uwe Brauer
0 siblings, 1 reply; 9+ messages in thread
From: Juan Manuel Macías @ 2022-01-15 19:59 UTC (permalink / raw)
To: Uwe Brauer; +Cc: orgmode
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: org-->html text between @ should be red.
2022-01-15 19:59 ` Juan Manuel Macías
@ 2022-01-15 20:24 ` Uwe Brauer
2022-01-15 20:58 ` Juan Manuel Macías
0 siblings, 1 reply; 9+ messages in thread
From: Uwe Brauer @ 2022-01-15 20:24 UTC (permalink / raw)
To: emacs-orgmode
[-- 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 --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: org-->html text between @ should be red.
2022-01-15 20:24 ` Uwe Brauer
@ 2022-01-15 20:58 ` Juan Manuel Macías
2022-01-15 21:01 ` Uwe Brauer
0 siblings, 1 reply; 9+ messages in thread
From: Juan Manuel Macías @ 2022-01-15 20:58 UTC (permalink / raw)
To: Uwe Brauer; +Cc: orgmode
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: org-->html text between @ should be red.
2022-01-15 20:58 ` Juan Manuel Macías
@ 2022-01-15 21:01 ` Uwe Brauer
0 siblings, 0 replies; 9+ messages in thread
From: Uwe Brauer @ 2022-01-15 21:01 UTC (permalink / raw)
To: emacs-orgmode
[-- 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 --]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-01-15 21:03 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-15 18:04 org-->html text between @ should be red Uwe Brauer
2022-01-15 18:20 ` Timothy
2022-01-15 19:39 ` Uwe Brauer
2022-01-15 18:21 ` Juan Manuel Macías
2022-01-15 19:39 ` Uwe Brauer
2022-01-15 19:59 ` Juan Manuel Macías
2022-01-15 20:24 ` Uwe Brauer
2022-01-15 20:58 ` Juan Manuel Macías
2022-01-15 21:01 ` Uwe Brauer
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).