pandoc プログラム仕様

Pandoc専用:MarkdownのWord/PowerPoint/HTML変換とテンプレート生成。 - AI処理は一切ありません(tkai_lib不要) - 例:

# テンプレート生成 python pandoc_convert.py --make_template docx --template template_textbook.docx python pandoc_convert.py --make_template pptx --template template_slide.pptx

# 変換 python pandoc_convert.py --convert docx --infile lecture_textbook.md --template template_textbook.docx python pandoc_convert.py --convert pptx --infile lecture_slide.md --template template_slide.pptx python pandoc_convert.py --convert html --infile lecture_textbook.md --mathml python pandoc_convert.py --convert html --infile lecture_textbook.md --css custom_style.css

converter.pandoc.convert_md(infile_md, target, pandoc_path, outfile=None, template=None, toc=False, css=None, mathml=False, no_yaml=False, verbose=False, smart_conversion=False)[ソース]

Library API for md -> docx/pptx/html

converter.pandoc.convert_with_pandoc(pandoc_path: str, target: str, infile_md: str, outfile: str, template: str = None, css: str = None, no_yaml: bool = False, args=None)[ソース]
converter.pandoc.correct_html(outfile)[ソース]
converter.pandoc.correct_markdown_pandoc_error(md_text: str, base_dir: Path = None) str[ソース]

pandoc がエラーを出す典型的な Markdown の問題を自動修正する。 - YAML と誤判定される --- の前後に空行を追加(ただし本物の YAML は保持) - 存在しない画像・リンクを無害化(コード化) - $$ inline $$ のような1行ブロック数式を、pandoc が確実に読めるブロック形式に正規化 - 生成AIがよく出す $[ ... ]$ を $$ ... $$ に変換

converter.pandoc.extract_yaml_front_matter(md_text: str)[ソース]

Markdown の先頭に YAML フロントマターがあれば抽出する。

converter.pandoc.find_pandoc() str | None[ソース]

pandoc 実行ファイルのパスを探す。 優先順位: 1. 環境変数 pandoc_path 2. 環境変数 tkProg_path に基づく既定配置

  • Windows: {tkProg_path}/tkApp_Win/pandoc/pandoc.exe

  • Linux: {tkProg_path}/tkApp_Linux/pandoc/pandoc

3. PATH 環境変数から探す 見つからなければ None を返す。

converter.pandoc.find_template(template_path: str) str | None[ソース]

template_path で与えられたファイル名を以下の順に探す: 1. 実行ディレクトリ (カレントディレクトリ) 2. スクリプトのあるディレクトリ (sys.argv[0] 基準)

見つかればフルパスを返し、見つからなければ None を返す。

converter.pandoc.is_valid_yaml(yaml_text: str) bool[ソース]

YAML として正しいかどうかを判定する。

converter.pandoc.main()[ソース]
converter.pandoc.make_pandoc_template(pandoc_path: str, fmt: str, template_file: str)[ソース]
converter.pandoc.parse_args()[ソース]
converter.pandoc.read_text_with_chardet(path)[ソース]
converter.pandoc.run_command(cmd: list) bool[ソース]
converter.pandoc.terminate()[ソース]