Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the Info manual creator script #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions bin/mkinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/bash
#
# Convert README.adoc to eldev.info.
#
# Command versions tested:
#
# - Asciidoctor 2.0.18
# - pandoc 2.17.1.1
# - GNU Emacs 30.0.93
# - texi2any (GNU texinfo) 6.8

filename=doc/README
output=doc/eldev.info

{
asciidoctor -b html -o "$filename".html "$filename".adoc
pandoc "$filename".html -f html -t org -o "$filename".org
emacs -Q -batch -L ./ -l bin/mkinfo.el -f make-info "$filename".org
makeinfo "$filename".texi -o "$output"
} || {
:
}

rm -f "$filename".html "$filename".org "$filename".texi
26 changes: 26 additions & 0 deletions bin/mkinfo.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
;;; mkinfo.el --- Make .info -*- lexical-binding: t -*-

(defun fix-targets ()
"Fix targets in links."
(let ((make-backup-files nil)
targets)
(beginning-of-buffer)
(while (re-search-forward "<<\\(.+\\)>>" nil t)
(push (match-string 1) targets))
(dolist (target targets)
(beginning-of-buffer)
(let ((pattern (format "\\[\\[\\(#%s\\)\\]" target)))
(while (re-search-forward pattern nil t)
;; NOTE: While this is the correct form of hyperlink to
;; marked objects, this won't get rendered as hyperlinks in
;; .info upon conversion. Still better than errors stopping
;; it.
(replace-match (format "[[%s]" target)))))
(save-buffer)))

(defun make-info ()
"Make the .info file from the given Org document."
(let ((filename (car (last command-line-args))))
(find-file filename)
(fix-targets)
(org-texinfo-export-to-texinfo)))