help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: asciidoctor


From: Gottfried
Subject: Re: asciidoctor
Date: Fri, 10 Feb 2023 15:20:19 +0000

Hi Jean,

thank you very much.

I copied it into my init.el file and it works.

when I did a

C-c a my browser Icecat opened and the file was shown.

I am very happy.

kind regards

Gottfried


Am 09.02.23 um 19:41 schrieb Jean Louis:
* Gottfried <gottfried@posteo.de> [2023-02-09 19:51]:
Hi everybody,

I installed asccidoc and asciidoctor

and I was able to open adoc-mode in emacs.

But what are with those messages?

You need not put attention on it. It is not critical. adoc-mode will
work.

Here are some handy functions, I have modified it for you that you get
preview of Asciidoc by using `asciidoctor` implementation (not
asciidoc one). Both are good, but try this one first.

You need to put functions somewhere.

If you are in markdown or asciidoc mode you will get preview with C-c a

(defun string-to-file-force (string file)
   "Prints string into file, matters not if file exists. Return FILE as file 
name."
   (with-temp-file file
     (insert string))
   file)

(defun rcd-command-output-from-input (program input &rest args)
   "Return output string from PROGRAM with given INPUT string and optional 
ARGS."
   (let* ((output (with-temp-buffer
                   (insert input)
                   (apply #'call-process-region nil nil program t '(t nil) nil 
args)
                   (buffer-string))))
     output))

(defun rcd-asciidoctor (string &rest args)
   "Return HTML by using Asciidoctor markup STRING."
   (let ((asciidoctor (executable-find "asciidoctor")))
     (apply 'rcd-command-output-from-input "asciidoctor" string "-" args)))

(defun rcd-asciidoctor-preview ()
   "Preview asciidoctor"
   (interactive)
   (let ((asciidoctor (executable-find "asciidoctor")))
     (when asciidoctor
       (let* ((output (buffer-string))
             (output (rcd-asciidoctor output))
             (file (string-to-file-force output "asciidoctor-preview.html")))
        (browse-url file)))))

(require 'adoc-mode)
(define-key adoc-mode-map (kbd "C-c a") #'rcd-asciidoctor-preview)



Attachment: OpenPGP_0x61FAF349C9FB7F94.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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