[Top][All Lists]

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

Re: Question Regarding Creating HTML Style Buttons With Org Mode

From: Juan Manuel Macías
Subject: Re: Question Regarding Creating HTML Style Buttons With Org Mode
Date: Sat, 19 Feb 2022 09:41:04 +0000

Samuel Banya writes:

> To clarify, did you evaluate that code block on the org mode docs
> itself?

The code must be evaluated *before* using that new type of link, or saved
to your ~/.emacs. You can simply evaluate it in your `scratch' buffer:

  (org-link-set-parameters "button"
                           :face '(:foreground "green4" :underline t)
                           :follow (lambda (path) (browse-url path))
                           :export (lambda (path desc backend)
                                     (when (eq backend 'html)
                                       (format "<form><button 
class=\"mybutton\" formaction=\"%s\">%s</button></form>" path desc))))

If you want to pass the class or id 'manually' to each link, and thus
have more control, you can evaluate this other version, where the class
or id would be added at the end of the link description, after (for
example) "!style":

  (org-link-set-parameters "button"
                           :face '(:foreground "green4" :underline t)
                           :follow (lambda (path) (browse-url path))
                           :export (lambda (path desc backend)
                                     (when (eq backend 'html)
                                       (let* ((style (if (string-match 
"\\(!style .+\\)" desc)
                                                         (match-string 1 desc)
                                              (desc (replace-regexp-in-string 
style "" desc)))
                                         (format "<form><button %s 
formaction=\"%s\">%s</button></form>" style path desc)))))


[[button:http://www.sambanya.com/artgallery.html][Art Gallery Page Link !style 

== HTML ==>

<form><button !style class="mybutton" 
formaction="http://www.sambanya.com/artgallery.html";>Art Gallery Page Link 

> I ask because if I try to evaluate it, aka 'C-c C-c' on the
> '#begin_src' block, nothing happens.

When you evaluate the code and add the new link type 'button', does it
appear in your document with the face defined for that link: green,
underlined? Have you tried testing it on a clean Emacs/Org?

Best regards,

Juan Manuel 

reply via email to

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