[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: # Comments export
From: |
Ihor Radchenko |
Subject: |
Re: # Comments export |
Date: |
Sun, 29 May 2022 19:59:40 +0800 |
Ypo <ypuntot@gmail.com> writes:
> Thanks for your effort, Ihor
>
> But that code is so difficult for me, that I can barely understand it.
Well. The basic idea is to go through the document right before
exporting and replace all the comments with some kind of exportable
environment. Below is the working code that you can try directly. The
code replaces comments with quote blocks. You might want to tweak
"#+begin_quote\n%s\n#+end_quote\n"
to something else if you want to customize how the comments are
exported. Just put %s where you want to put the comment text and do not
forget to leavee the trailing newline "\n". Hope it helps.
(defun org-export-replace-comments (_)
"Replace all the comments with QUOTE blocks."
(org-with-wide-buffer
;; Search the all the comments in temporary export buffer.
(goto-char (point-min))
(while (re-search-forward org-comment-regexp nil t)
(let ((comment (org-element-at-point)))
;; We just called Org parser to determine the syntactic element at point.
(when (eq 'comment (org-element-type comment))
;; The current element is really comment. Replace its contents with
;; QUOTE block. `setf' here is replacing buffer region defined by
;; `buffer-substring' with new string containing the QUOTE block.
(setf (buffer-substring (org-element-property :begin comment)
(org-element-property :end comment))
(format "#+begin_quote\n%s\n#+end_quote\n"
(org-element-property :value comment))))))))
(add-hook 'org-export-before-parsing-hook #'org-export-replace-comments)
Best,
Ihor
- # Comments export, Ypo, 2022/05/28
- Re: # Comments export, Timothy, 2022/05/28
- Re: # Comments export, Ypo, 2022/05/28
- Re: # Comments export, Timothy, 2022/05/28
- Re: # Comments export, Samuel Wales, 2022/05/28
- Re: # Comments export, Ypo, 2022/05/28
- Re: # Comments export, Ihor Radchenko, 2022/05/28
- Re: # Comments export, Ypo, 2022/05/29
- Re: # Comments export,
Ihor Radchenko <=
- Re: # Comments export, Eric S Fraga, 2022/05/30
- Re: # Comments export, Juan Manuel MacĂas, 2022/05/30
- Re: # Comments export, Tim Cross, 2022/05/30