Function: org-man-src-block

org-man-src-block is a byte-compiled function defined in ox-man.el.gz.

Signature

(org-man-src-block SRC-BLOCK CONTENTS INFO)

Documentation

Transcode a SRC-BLOCK element from Org to Man.

CONTENTS holds the contents of the item. INFO is a plist holding contextual information.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ox-man.el.gz
;;; Src Block

(defun org-man-src-block (src-block _contents info)
  "Transcode a SRC-BLOCK element from Org to Man.
CONTENTS holds the contents of the item.  INFO is a plist holding
contextual information."
  (if (not (plist-get info :man-source-highlight))
      (format ".RS\n.nf\n\\fC%s\\fP\n.fi\n.RE\n\n"
	      (org-man--protect-example (org-export-format-code-default src-block info)))
    (let* ((tmpdir temporary-file-directory)
	   (in-file  (make-temp-name (expand-file-name "srchilite" tmpdir)))
	   (out-file (make-temp-name (expand-file-name "reshilite" tmpdir)))
	   (code (org-element-property :value src-block))
	   (org-lang (org-element-property :language src-block))
	   (lst-lang
            (and org-lang
                 (cadr (assq (intern org-lang)
			     (plist-get info :man-source-highlight-langs)))))
	   (cmd (concat "source-highlight"
			" -s " lst-lang
			" -f groff_man "
			" -i " in-file
			" -o " out-file)))
      (if lst-lang
	  (let ((code-block ""))
	    (with-temp-file in-file (insert code))
	    (shell-command cmd)
	    (setq code-block  (org-file-contents out-file))
	    (delete-file in-file)
	    (delete-file out-file)
	    code-block)
	(format ".RS\n.nf\n\\fC\\m[black]%s\\m[]\\fP\n.fi\n.RE" (org-man--protect-example code))))))