まずDebianでは、
pandocのインストールで 標準テンプレートが /usr/share/pandoc/data/templates
に配置されているが、
この状態でmdファイルのあるディレクトリーをカレントディレクトリーにして次のコマンドを実行すれば問題なく目的の文書形式で作成される。
ここで test4.md
は変換したい文書だが、rtf、docx、htmlファイルへの変換では以下のコマンドで成功した。
pandoc -f markdown -o test4.rtf -t rtf --template=default.rtf test4.md
pandoc -f markdown -o test4.docx -t docx --template=default.docbook5 test4.md
pandoc -f markdown -o test4.html -t html5 --template=template-test4.html test4.md
一方、テンプレートが .local/pandoc/templates
にもある状態で /usr/share/pandoc/data/templates
をリネームして変換を実行したが .local/pandoc/templates
を見にいってくれなかった。
/usr/share/pandoc/data/templates
のまま使用するか、文書ファイルと同じディレクトリーにテンプレートを置いた状態で変換するしか現状は成功していない。
Windows10では、文書ファイルと同じディレクトリーにテンプレートを置いた状態で変換するしか現状は成功していない。
テンプレートを指定するのはどの様に指定しているのだろう。
テンプレートの指定をフルパスで指定すればも上手くいくのだけどコマンドが長くなり面倒くさい。
pandoc -f markdown -o test4.html -t html5 --template=/usr/share/pandoc/data/templates-x/default.html5 test4.md
(ここでは "templates" を "templates-x" にリネームする事で既定値では参照できなくし、フルパスで指定すれば使える事を確認している)
標準テンプレートの内容から変更して必要があっても元のテンプレートはいじりたくない。 変換する際には標準テンプレートを違う場所にコピーしてMyテンプレートとして置き、それを変換で使用したいが、その際のMyテンプレートフォルダーの指定方法を知りたい。(どこかにはあると思うけど)
(25 Dec 2022)
ーーーーーーーーー追記(25 Dec 2022)
pandocは次の応答をしています。
$ pandoc -v pandoc 2.9.2.1 Compiled with pandoc-types 1.20, texmath 0.12.0.2, skylighting 0.8.5 Default user data directory: /home/「ユーザ名」/.local/share/pandoc or /home/「ユーザ名」/.pandoc Copyright (C) 2006-2020 John MacFarlane Web: https://pandoc.org This is free software; see the source for copying conditions. There is no warranty, not even for merchantability or fitness for a particular purpose.
/home/「ユーザ名」/.local/share/pandoc
/home/「ユーザ名」/.pandoc
とあり、この下に templatesフォルダーごと置けば参照します。
しかし、 /home/「ユーザ名」/.local/share/pandoc
フォルダーがあって templatesフォルダーが無くても
/home/「ユーザ名」/.pandoc
の方には見にいかない様です。
/home/「ユーザ名」/.local/share/pandoc
フォルダーが無ければ、/home/「ユーザ名」/.pandoc
を見にいきます。
いずれにしても、任意の場所にテンプレートを置きたくなった場合、その指定方法が欲しいと思います。