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

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

Re: asciidoctor


From: Jean Louis
Subject: Re: asciidoctor
Date: Thu, 9 Feb 2023 21:41:13 +0300
User-agent: Mutt/2.2.9+54 (af2080d) (2022-11-21)

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






-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

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