From: Phil Estival <pe@7d.nz>
To: Ypo <ypuntot@gmail.com>, Samuel Wales <samologist@gmail.com>
Cc: Timothy <tecosaurus@gmail.com>, emacs-orgmode@gnu.org
Subject: Re: # Comments export
Date: Thu, 2 Jun 2022 08:24:22 +0200 [thread overview]
Message-ID: <a3c5efe7-2827-b22e-ce3b-57ee9c748a92@7d.nz> (raw)
In-Reply-To: <d436c753-205e-4e00-84a3-6c1d10eeda36@gmail.com>
On 29/05/2022 à 02:46, Ypo wrote:
>
> I wanted to export my # comments so I could
> share my notes with more people, using HTML
> export. I would export all of them.
>
Ypo,
As it is very close to what you're asking,
here I'm suggesting how to export # comments in org,
as <!-- comments --> to the HTML
and % comments to the latex backends.
Modifying Org sources instead of providing a
peripheral mechanism may be considered as
unorthodox, but it's not difficult at all and
the modifications to remove the censorship over
comments are small.
ox.el: add a customization option to export comments
#+begin_src elisp
(defcustom org-export--with-comments nil
"Non-nil means provides comments to the backends"
:group 'org-export-general
:type 'boolean
:safe #'booleanp)
#+end_src
Let comments flow to exporters when this option is active
#+begin_src elisp
(defun org-export--skip-p (datum options selected excluded)
[...]
(cl-case (org-element-type datum)
((comment comment-block)
(if org-export--with-comments nil ;; do not skip comments and
comment blocks.
;; Skip all comments and comment blocks. Make to keep maximum
;; number of blank lines around the comment so as to preserve
;; local structure of the document upon interpreting it back into
;; Org syntax.
(let* ((previous (org-export-get-previous-element datum options))
(before (or (org-element-property :post-blank previous) 0))
(after (or (org-element-property :post-blank datum) 0)))
(when previous
(org-element-put-property previous :post-blank (max before
after 0)))
t)))
[...]
#+end_src
ox-html.el: modify the backend derivation to add a comment transcoder
#+begin_src elisp
(org-export-define-backend 'html
'(...
(clock . org-html-clock)
(code . org-html-code)
(comment . org-html-comment)
...
#+end_src
ox-html.el: declare the additional transcoder:
#+begin_src elisp
;;;; Comment
(defun org-html-comment (comment _contents info)
"Transcode COMMENT from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual
information."
(concat "<!-- " (org-element-property :value comment)))
#+end_src
Here it is for latex too
ox-latex.el:
#+begin_src elisp
;;;; Comment
(defun org-latex-comment (comment _contents info)
"Transcode COMMENT from Org to latex.
CONTENTS is nil. INFO is a plist holding contextual
information."
(concat "% " (org-element-property :value comment)))
#+end_src
Best regards,
Phil
prev parent reply other threads:[~2022-06-02 6:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-28 14:58 # Comments export Ypo
2022-05-28 15:44 ` Timothy
2022-05-28 15:58 ` Ypo
2022-05-28 16:05 ` Timothy
2022-05-28 23:15 ` Samuel Wales
2022-05-29 0:46 ` Ypo
2022-05-29 1:19 ` Ihor Radchenko
2022-05-29 11:33 ` Ypo
2022-05-29 11:59 ` Ihor Radchenko
2022-05-30 7:35 ` Eric S Fraga
2022-05-30 10:46 ` Juan Manuel Macías
2022-05-30 21:49 ` Tim Cross
2022-06-02 6:24 ` Phil Estival [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a3c5efe7-2827-b22e-ce3b-57ee9c748a92@7d.nz \
--to=pe@7d.nz \
--cc=emacs-orgmode@gnu.org \
--cc=samologist@gmail.com \
--cc=tecosaurus@gmail.com \
--cc=ypuntot@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.