[-- Attachment #1: Type: text/plain, Size: 238 bytes --] Is it possible to export the (# comments)? I haven't seen that option in org export general customization. I am making some (# comments) to texts, and I would like to export them when I export the subtree to HTML. Best regards, Ypo [-- Attachment #2: Type: text/html, Size: 636 bytes --]
[-- Attachment #1.1: Type: text/plain, Size: 169 bytes --] Hi Ypo, As I understand it, the whole point of comments is that they’re not exported. Perhaps you’re looking for note blocks instead? All the best, Timothy [-- Attachment #1.2: Type: text/html, Size: 3173 bytes --]
[-- Attachment #1: Type: text/plain, Size: 813 bytes --] Thanks, Timothy Do you mean blocks like #+BEGIN_COMMENT ? Does that kind of blocks already exist? https://i.ibb.co/xHJDgCR/Captura.jpg Ypo El 28/05/2022 a las 17:44, Timothy escribió: > > Hi Ypo, > > As I understand it, the whole point of comments is that they’re not > exported. Perhaps you’re looking for note blocks instead? > > All the best, > *Timothy* > > *From*: Ypo <mailto:"Ypo" <ypuntot@gmail.com>> > *Subject*: # Comments export > *To*: Org-mode <mailto:"Org-mode" <emacs-orgmode@gnu.org>> > *Date*: Sat, 28 May 2022 22:58:28 +0800 > > Is it possible to export the (# comments)? I haven't seen that option > in org export general customization. > > I am making some (# comments) to texts, and I would like to export > them when I export the subtree to HTML. > > > Best regards, > > Ypo > [-- Attachment #2: Type: text/html, Size: 4597 bytes --]
[-- Attachment #1.1: Type: text/plain, Size: 184 bytes --] Hi Ypo, Well, `#+begin_comment' is for content you /don’t/ want exported, but if you want to add a note to be included in exports, try `#+begin_note'. All the best, Timothy [-- Attachment #1.2: Type: text/html, Size: 7618 bytes --]
to op: do you mean to sometimes export comments and sometimes not? On 5/28/22, Timothy <tecosaurus@gmail.com> wrote: > Hi Ypo, > > Well, `#+begin_comment' is for content you /don’t/ want exported, but if you > want to > add a note to be included in exports, try `#+begin_note'. > > All the best, > Timothy > -- The Kafka Pandemic A blog about science, health, human rights, and misopathy: https://thekafkapandemic.blogspot.com
Hi, Timothy
I wanted to export my # comments so I could share my notes with more people, using HTML export. I would export all of them.
But, as it seems not possible, I think I will use footnotes. I liked # comments more, because their face can be customized and because they are nearer to the commented text (although footnotes can be moved manually wherever user wants to), # comments are like more "natural".
Best regards
29 may 2022 1:15:52 Samuel Wales <samologist@gmail.com>:
> to op: do you mean to sometimes export comments and sometimes not?
>
>
> On 5/28/22, Timothy <tecosaurus@gmail.com> wrote:
>> Hi Ypo,
>>
>> Well, `#+begin_comment' is for content you /don’t/ want exported, but if you
>> want to
>> add a note to be included in exports, try `#+begin_note'.
>>
>> All the best,
>> Timothy
>>
>
>
> --
> The Kafka Pandemic
>
> A blog about science, health, human rights, and misopathy:
> https://thekafkapandemic.blogspot.com
Ypo <ypuntot@gmail.com> writes:
> I wanted to export my # comments so I could share my notes with more people, using HTML export. I would export all of them.
>
> But, as it seems not possible, I think I will use footnotes. I liked # comments more, because their face can be customized and because they are nearer to the commented text (although footnotes can be moved manually wherever user wants to), # comments are like more "natural".
It is actually possible, but you will need to write an
org-export-before-parsing-hook that will convert all the comments into
exportable elements.
Not tested, but the hook might be something like
(defun org-export-replace-comments (_)
"Replace all the comments with note blocks."
(org-element-cache-map
(lambda (comment)
(setf (buffer-substring (org-element-property :begin comment) (org-element-property :end comment))
(format "#+begin_note\n%s\n#+end_node\n" (org-element-property :value comment))))
:granularity 'element
:restrict-elements '(comment)))
Best,
Ihor
[-- Attachment #1: Type: text/plain, Size: 1224 bytes --] Thanks for your effort, Ihor But that code is so difficult for me, that I can barely understand it. El 29/05/2022 a las 3:19, Ihor Radchenko escribió: > Ypo<ypuntot@gmail.com> writes: > >> I wanted to export my # comments so I could share my notes with more people, using HTML export. I would export all of them. >> >> But, as it seems not possible, I think I will use footnotes. I liked # comments more, because their face can be customized and because they are nearer to the commented text (although footnotes can be moved manually wherever user wants to), # comments are like more "natural". > It is actually possible, but you will need to write an > org-export-before-parsing-hook that will convert all the comments into > exportable elements. > > Not tested, but the hook might be something like > > (defun org-export-replace-comments (_) > "Replace all the comments with note blocks." > (org-element-cache-map > (lambda (comment) > (setf (buffer-substring (org-element-property :begin comment) (org-element-property :end comment)) > (format "#+begin_note\n%s\n#+end_node\n" (org-element-property :value comment)))) > :granularity 'element > :restrict-elements '(comment))) > > Best, > Ihor [-- Attachment #2: Type: text/html, Size: 1881 bytes --]
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
On Sunday, 29 May 2022 at 00: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.
I use drawers for this and then have specific processing of different
types of drawers, depending on target.
For instance, I might have :note: drawers (similar to inline tasks) with
the following processing (for odt export; similar for LaTeX):
--8<---------------cut here---------------start------------->8---
(setq-local org-odt-format-drawer-function
(lambda (name contents)
(if (string= name "note")
(progn
(format "<text:span text:background=\"#FFFF00\">%s</text:span>" contents)))))
--8<---------------cut here---------------end--------------->8---
(progn because I used to do more in there...)
--
: Eric S Fraga, with org release_9.5.3-511-g8e69ad in Emacs 29.0.50
Eric S Fraga writes: > I use drawers for this and then have specific processing of different > types of drawers, depending on target. > > For instance, I might have :note: drawers (similar to inline tasks) with > the following processing (for odt export; similar for LaTeX): > > --8<---------------cut here---------------start------------->8--- > (setq-local org-odt-format-drawer-function > (lambda (name contents) > (if (string= name "note") > (progn > (format "<text:span text:background=\"#FFFF00\">%s</text:span>" contents))))) > --8<---------------cut here---------------end--------------->8--- > > (progn because I used to do more in there...) I use a special type of footnote, which is exported to LaTeX as pdf annotations (with the pdfannotate package) and to odt as comments. The use of footnotes allows me to put comments and annotations within the paragraph: https://list.orgmode.org/877de55cjf.fsf@posteo.net/ Best regards, Juan Manuel
Juan Manuel Macías <maciaschain@posteo.net> writes:
> Eric S Fraga writes:
>
>> I use drawers for this and then have specific processing of different
>> types of drawers, depending on target.
>>
>> For instance, I might have :note: drawers (similar to inline tasks) with
>> the following processing (for odt export; similar for LaTeX):
>>
>> --8<---------------cut here---------------start------------->8---
>> (setq-local org-odt-format-drawer-function
>> (lambda (name contents)
>> (if (string= name "note")
>> (progn
>> (format "<text:span text:background=\"#FFFF00\">%s</text:span>" contents)))))
>> --8<---------------cut here---------------end--------------->8---
>>
>> (progn because I used to do more in there...)
>
> I use a special type of footnote, which is exported to LaTeX as pdf
> annotations (with the pdfannotate package) and to odt as comments. The
> use of footnotes allows me to put comments and annotations within the
> paragraph:
>
> https://list.orgmode.org/877de55cjf.fsf@posteo.net/
>
I think this is a much better solution. I don't like the idea of adding
the ability to export comments - the whole point of comments are to
provide content which is NOT exported. If you find you have content as
comments which you then want to export, my view would be that these are
not 'comments' in the sense of org-mode. These sound like notes or
annotations and there is likely a better approach than treating them as
org comments. Org comments are probably best thought of as comments
about org content and not org content per se. If you want your comments
to appear as part of yhour exported data at some level, they are no
longer comments, but rather a different class of content and should be
categorised using one of the org content block types or a footnote.
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