- Download the Emacs source from a GNU mirror and unpack it with
tar xf
.
- Run
makeinfo --docbook doc/emacs/emacs.texi -o emacs.docbook
to create an intermediate DocBook.
- Run
pandoc --from docbook --to org --out emacs.org emacs.docbook
to create your org file. Note that you really should add the document types explicitly, at least for the input type. Otherwise Pandoc will use a lot of memory as it tries to guess the correct type. At least in my virtual machine (4GB memory), Pandoc 2.6 crashed without --from
.
Unfortunately, there will still be some noise, as the @cindex
and @kindex
directives aren't filtered out by Pandoc. You can remove them beforehand with sed
or other similar tools:
sed -i 's#^@[ck]index .*$##g'
All in all, you should get your desired results with the following script.
#!/bin/sh
EMACS_VERSION=26.1
EMACS_DIRECTORY=emacs-${EMACS_VERSION}
EMACS_DL_FILE=${EMACS_DIRECTORY}.tar.xz
EMACS_PACKAGE_URL=http://ftpmirror.gnu.org/emacs/${EMACS_DL_FILE}
# Get Emacs source
wget ${EMACS_PACKAGE_URL}
tar xf ${EMACS_DL_FILE}
# Remove keyboard and concept indices
sed -i 's#^@.index .*$##g' ${EMACS_DIRECTORY}/doc/emacs/*.texi
# Create the DocBook
makeinfo --docbook ${EMACS_DIRECTORY}/doc/emacs/emacs.texi -o emacs.docbook
# Create the Org file
pandoc --from docbook --to org -o emacs.org emacs.docbook
Keep in mind that you can heavily customize Pandocs output with Lua, so if you don't like the output, try your hands on a Lua filter.