Ypo <ypun...@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