---
title: "#이맥스 #판독 - 연동 설정"
url: "https://notes.junghanacs.com/notes/20250129T215257"
author: "Junghan Kim"
date: "2025-01-29T21:52:00+09:00"
lastmod: "2025-01-29T21:54:00+09:00"
tags: ["configuration","emacs","pandoc"]
description: "이맥스와 판독, pandoc 변환 설정을 연결해 두는 작업용 설정 노트이다."
---

> [!abstract] 이 노트에 대하여
> 
> Pandoc 기반 문서 변환과 Emacs 설정이 어디서 어떻게 연결되는지 코드와 참고 노트를 통해 정리한다. 전자책과 문서 변환 워크플로우를 지속적으로 다듬는 기반 노트다.

## BIBLIOGRAPHY

## 관련연구

-   [#판독](https://notes.junghanacs.com/meta/20240211T101911)

-   [bib/ @tecosaur 조직모드 마술사 이맥스 '2025-01-28 #2025-02-26](https://notes.junghanacs.com/bib/20250128T152148)
-   [llmlog/ #조직모드: EPUB2Org 판독 전자책 변환 - 내부링크 라벨 타겟 북마크 앵커 섹션 연결 '2025-07-14 #2025-07-14]
-   [llmlog/ Pandoc YAML로 PDF 스타일링 완벽 제어 '2025-10-02]
-   [notes/ #용어집: #조직모드 #테이블 #스프레스시트 #변환 '2024-06-13 #2025-04-22](https://notes.junghanacs.com/notes/20240613T121834)
-   [notes/ #콰르토 #재현성 #전자책: 재현 가능한 책의 미래 '2024-09-23 #2025-02-24](https://notes.junghanacs.com/notes/20240923T162112)
-   [notes/ 조합형 NFD 자모를 완성형 NFC 음절 변환 - 정규화 '2025-01-25 #2025-01-25](https://notes.junghanacs.com/notes/20250125T190619)
-   [notes/ junghan0611/pandoc-templates '2025-03-09 #2025-03-09](https://notes.junghanacs.com/notes/20250309T180741)
-   [notes/ 구글 문서 번역 - 판독 '2025-05-25 #2025-05-25](https://notes.junghanacs.com/notes/20250525T164501)

## cashpw 예시

[2025-01-29 Wed 08:04]

cashpw-dotfiles-node/config/doom/config-personal.org

```emacs-lisp

(defun cashpw/pandoc--convert-buffer-from-markdown-to-org-in-place ()
  "Converts the current buffer to org-mode in place."
  (interactive)
  (let ((buffer-content (buffer-string))
        (tmp-file
         (format "/tmp/%s.md" (format-time-string "%s" (current-time)))))
    (with-temp-buffer
      (insert buffer-content)
      (write-file tmp-file))
    (erase-buffer)
    (insert
     (shell-command-to-string
      (concat
       (format "pandoc --wrap=none -f markdown -t org %s" tmp-file)
       ;; Remove :PROPERTIES: drawers beneath headings
       " | sed -E '/^[[:space:]]*:/d'")))
    (org-mode)))

(defun cashpw/pandoc-cli (command)
  (let ((pandoc-command (format "pandoc %s" command)))
    (message "Running %s" pandoc-command)
    (shell-command-to-string pandoc-command)))

(defun cashpw/pandoc-convert (text source-format target-format)
  "Convert TEXT from SOURCE-FORMAT to TARGET-FORMAT."
  (cashpw/pandoc-cli
   (s-lex-format "-f ${source-format} -t ${target-format} <<< \"${text}\"")))

(defun cashpw/pandoc-convert-via-file (text source-format target-format)
  "Convert TEXT from SOURCE-FORMAT to TARGET-FORMAT."
  (let ((tmp-input-file-path
         (format "/tmp/pandoc-tmp-input-%s" (format-time-string "%s")))
        (tmp-output-file-path
         (format "/tmp/pandoc-tmp-output-%s" (format-time-string "%s"))))
    (with-temp-buffer text
      (let ((coding-system-for-write 'utf-8))
        (write-file tmp-input-file-path)))
    (cashpw/pandoc-cli
     (s-lex-format
      "${tmp-input-file-path} -f ${source-format} -t ${target-format} -o ${tmp-output-file-path}"))
    (with-current-buffer (find-file-noselect tmp-output-file-path)
      (buffer-substring-no-properties (point-min) (point-max)))))
```
