emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* patch [Feature Addition] exporting comments on org files to html
@ 2008-11-05  6:50 Eric Schulte
  2008-11-06  7:05 ` Carsten Dominik
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Schulte @ 2008-11-05  6:50 UTC (permalink / raw)
  To: Org-mode

[-- Attachment #1: Type: text/plain, Size: 1269 bytes --]

Hi,

I have been co-authoring an org-mode file with a co-worker, and we
started to put comments in org-blocks with the following format

#+begin_comment ems example comment
body of the comment
- a list inside
- of the comment
#+end_comment

I made the following additions to org-exp.el (patch attached) which
allows the optional exportation of comment blocks through the use of a
`block-comments' option line in the file header.

#+OPTIONS:   comment-blocks:t

Currently it only exports to html, and it styles the blocks using css
(added to the org default html css styles).  It also adds id's to the
comment divs which include the authors name, so it's possible to style
the comments by their author (for example different colors by author).
I used something like the following to style our comments (our initials
are wrg and ems).  I'm certainly no css expert, so I'm sure it's
possible to get much nicer looking comment blocks.

,----[comment-style.css]
| div#org-comment-wrg {
|   background: #cdecf8;
|   border: solid 1px #09abe7;
|   padding: 0.5em;
| }
| 
| div#org-comment-ems {
|   background: #d1fbaf;
|   border: solid 1px #78ed19;
|   padding: 0.5em;
| }
`----

Here's the patch to org-exp.el.  I'd love to hear any
ideas/issues/feedback.

Cheers -- Eric


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-exp.patch --]
[-- Type: text/x-diff, Size: 5837 bytes --]

diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index 4be6b01..b3a848e 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -252,6 +252,11 @@ e.g. \"timestamp:nil\"."
   :group 'org-export-general
   :type 'boolean)
 
+(defcustom org-export-comment-blocks nil
+  "If non-nil, export comment blocks"
+  :group 'org-export-general
+  :type 'boolean)
+
 (defcustom org-export-with-tags 'not-in-toc
   "If nil, do not export tags, just remove them from headlines.
 If this is the symbol `not-in-toc', tags will be removed from table of
@@ -519,6 +524,7 @@ Org-mode file."
                                white-space:nowrap; }
   .org-info-js_search-highlight {background-color:#ffff00; color:#000000;
                                  font-weight:bold; }
+  .org-comment { background: #efefef; border: solid 1px; }
  ]]>
 </style>"
   "The default style specification for exported HTML files.
@@ -817,6 +823,7 @@ or if they are only using it locally."
     (:footnotes            . org-export-with-footnotes)
     (:drawers              . org-export-with-drawers)
     (:tags                 . org-export-with-tags)
+    (:comment-blocks       . org-export-comment-blocks)
     (:TeX-macros           . org-export-with-TeX-macros)
     (:LaTeX-fragments      . org-export-with-LaTeX-fragments)
     (:skip-before-1st-heading . org-export-skip-text-before-1st-heading)
@@ -962,7 +969,8 @@ modified) list.")
 		  ("skip"  . :skip-before-1st-heading)
 		  ("author" . :author-info)
 		  ("creator" . :creator-info)
-		  ("timestamp" . :time-stamp-file)))
+		  ("timestamp" . :time-stamp-file)
+		  ("comment-blocks" . :comment-blocks)))
 	    o)
 	(while (setq o (pop op))
 	  (if (string-match (concat (regexp-quote (car o))
@@ -1436,6 +1444,9 @@ on this string to produce the exported version."
 
       ;; Handle source code snippets
       (org-export-replace-src-segments)
+
+      ;; Handle comment environment and comment subtrees
+      (org-export-handle-comment-blocks-and-subtrees (plist-get parameters :comment-blocks))
       
       ;; Get rid of drawers
       (org-export-remove-or-extract-drawers drawers
@@ -1478,10 +1489,6 @@ on this string to produce the exported version."
       ;; Blockquotes and verse
       (org-export-mark-blockquote-and-verse)
 
-      ;; Remove comment environment and comment subtrees
-      (org-export-remove-comment-blocks-and-subtrees)
-
-
       ;; Find matches for radio targets and turn them into internal links
       (org-export-mark-radio-links)
 
@@ -1783,15 +1790,21 @@ These special cookies will later be interpreted by the backend."
 		       "ORG-VERSE-END" "ORG-VERSE-START")
 		   t t)))
 
-(defun org-export-remove-comment-blocks-and-subtrees ()
-  "Remove the comment environment, and also commented subtrees."
+(defun org-export-handle-comment-blocks-and-subtrees (comment-blocks)
+  "Prepare comment blocks and comment subtrees for export.  If
+COMMENT-BLOCKS is non-nil then format comment blocks using
+`org-export-format-comment', otherwise hide all comment blocks
+during export.  Hides all comment subtrees."
   (let ((re-commented (concat "^\\*+[ \t]+" org-comment-string "\\>"))
-        (case-fold-search nil))
+        (case-fold-search t))
     ;; Remove comment environment
     (goto-char (point-min))
     (while (re-search-forward
-	    "^#\\+BEGIN_COMMENT[ \t]*\n[^\000]*?^#\\+END_COMMENT\\>.*" nil t)
-      (replace-match "" t t))
+	    "^#\\+begin_comment\\([ \t]+\\(\\S-+\\)\\)?[ \t]*\\(.*\\)?[\r\n]\\([^\000]*?\\)#\\+end_comment"
+	    nil t)
+      (replace-match (if comment-blocks
+			 (org-export-format-comment (match-string 4) (match-string 2) (match-string 3))
+			 "") t t))
     ;; Remove subtrees that are commented
     (goto-char (point-min))
     (while (re-search-forward re-commented nil t)
@@ -2170,6 +2183,34 @@ backends, it converts the segment into an EXAMPLE segment."
 	      (if (string-match "\n\\'" code) "" "\n")
 	      "#+END_EXAMPLE\n")))))
 
+(defun org-export-format-comment (body &optional owner title)
+  "Format comment BODY by OWNER and return it formatted for export.
+Currently, this only does something for HTML export, for all
+other backends, it converts the comment into an EXAMPLE segment."
+  (save-match-data
+    (cond
+      (htmlp ;; We are exporting to HTML
+       (concat "#+BEGIN_HTML\n"
+	       "<div class=\"org-comment\" "
+	       (if owner (format "id=\"org-comment-%s\" " owner))
+	       ">\n"
+	       (if owner (concat "<b>" owner "</b> ") "")
+	       (if (and title (> (length title) 0)) (concat " -- " title "</br>\n") "</br>\n")
+	       "<p>\n"
+	       "#+END_HTML\n"
+	       body
+	       "#+BEGIN_HTML\n"
+	       "</p>\n"
+	       "</div>\n"
+	       "\n#+END_HTML\n"))
+      (t ;; This is not HTML, so just make it an example.
+       (concat "#+BEGIN_EXAMPLE\n"
+	       (if title (concat "Title:" title "\n") "")
+	       (if owner (concat "By:" owner "\n") "")
+	       body
+	       (if (string-match "\n\\'" body) "" "\n")
+	       "#+END_EXAMPLE\n")))))
+
 ;;; ASCII export
 
 (defvar org-last-level nil) ; dynamically scoped variable
@@ -2250,6 +2291,7 @@ underlined headlines.  The default is 3."
 		  :verbatim-multiline t
 		  :select-tags (plist-get opt-plist :select-tags)
 		  :exclude-tags (plist-get opt-plist :exclude-tags)
+		  :comment-blocks (plist-get opt-plist :comment-blocks)
 		  :archived-trees
 		  (plist-get opt-plist :archived-trees)
 		  :add-text (plist-get opt-plist :text))
@@ -2924,7 +2966,9 @@ PUB-DIR is set, use this as the publishing directory."
 	    :add-text
 	    (plist-get opt-plist :text)
 	    :LaTeX-fragments
-	    (plist-get opt-plist :LaTeX-fragments))
+	    (plist-get opt-plist :LaTeX-fragments)
+	    :comment-blocks
+	    (plist-get opt-plist :comment-blocks))
 	   "[\r\n]"))
 	 table-open type
 	 table-buffer table-orig-buffer

[-- Attachment #3: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: patch [Feature Addition] exporting comments on org files to html
  2008-11-05  6:50 patch [Feature Addition] exporting comments on org files to html Eric Schulte
@ 2008-11-06  7:05 ` Carsten Dominik
  2008-11-07  5:40   ` Eric Schulte
  0 siblings, 1 reply; 8+ messages in thread
From: Carsten Dominik @ 2008-11-06  7:05 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Org-mode

Hi Eric,

before adding this, I would like to investigate with you if selective  
export (section 12.2 of the manual) could maybe used to achieve pretty  
much the same goal, with the only limiting condition that the part  
treated as a switchable comment does structurally have to be a subtree.

Are you aware of selective export?  Maybe you could give us more  
detail about how you actually used this, and to what end?

- Carsten


On Nov 5, 2008, at 7:50 AM, Eric Schulte wrote:

> Hi,
>
> I have been co-authoring an org-mode file with a co-worker, and we
> started to put comments in org-blocks with the following format
>
> #+begin_comment ems example comment
> body of the comment
> - a list inside
> - of the comment
> #+end_comment
>
> I made the following additions to org-exp.el (patch attached) which
> allows the optional exportation of comment blocks through the use of a
> `block-comments' option line in the file header.
>
> #+OPTIONS:   comment-blocks:t
>
> Currently it only exports to html, and it styles the blocks using css
> (added to the org default html css styles).  It also adds id's to the
> comment divs which include the authors name, so it's possible to style
> the comments by their author (for example different colors by author).
> I used something like the following to style our comments (our  
> initials
> are wrg and ems).  I'm certainly no css expert, so I'm sure it's
> possible to get much nicer looking comment blocks.
>
> ,----[comment-style.css]
> | div#org-comment-wrg {
> |   background: #cdecf8;
> |   border: solid 1px #09abe7;
> |   padding: 0.5em;
> | }
> |
> | div#org-comment-ems {
> |   background: #d1fbaf;
> |   border: solid 1px #78ed19;
> |   padding: 0.5em;
> | }
> `----
>
> Here's the patch to org-exp.el.  I'd love to hear any
> ideas/issues/feedback.
>
> Cheers -- Eric
>
> diff --git a/lisp/org-exp.el b/lisp/org-exp.el
> index 4be6b01..b3a848e 100644
> --- a/lisp/org-exp.el
> +++ b/lisp/org-exp.el
> @@ -252,6 +252,11 @@ e.g. \"timestamp:nil\"."
>   :group 'org-export-general
>   :type 'boolean)
>
> +(defcustom org-export-comment-blocks nil
> +  "If non-nil, export comment blocks"
> +  :group 'org-export-general
> +  :type 'boolean)
> +
> (defcustom org-export-with-tags 'not-in-toc
>   "If nil, do not export tags, just remove them from headlines.
> If this is the symbol `not-in-toc', tags will be removed from table of
> @@ -519,6 +524,7 @@ Org-mode file."
>                                white-space:nowrap; }
>   .org-info-js_search-highlight {background-color:#ffff00;  
> color:#000000;
>                                  font-weight:bold; }
> +  .org-comment { background: #efefef; border: solid 1px; }
>  ]]>
> </style>"
>   "The default style specification for exported HTML files.
> @@ -817,6 +823,7 @@ or if they are only using it locally."
>     (:footnotes            . org-export-with-footnotes)
>     (:drawers              . org-export-with-drawers)
>     (:tags                 . org-export-with-tags)
> +    (:comment-blocks       . org-export-comment-blocks)
>     (:TeX-macros           . org-export-with-TeX-macros)
>     (:LaTeX-fragments      . org-export-with-LaTeX-fragments)
>     (:skip-before-1st-heading . org-export-skip-text-before-1st- 
> heading)
> @@ -962,7 +969,8 @@ modified) list.")
> 		  ("skip"  . :skip-before-1st-heading)
> 		  ("author" . :author-info)
> 		  ("creator" . :creator-info)
> -		  ("timestamp" . :time-stamp-file)))
> +		  ("timestamp" . :time-stamp-file)
> +		  ("comment-blocks" . :comment-blocks)))
> 	    o)
> 	(while (setq o (pop op))
> 	  (if (string-match (concat (regexp-quote (car o))
> @@ -1436,6 +1444,9 @@ on this string to produce the exported version."
>
>       ;; Handle source code snippets
>       (org-export-replace-src-segments)
> +
> +      ;; Handle comment environment and comment subtrees
> +      (org-export-handle-comment-blocks-and-subtrees (plist-get  
> parameters :comment-blocks))
>
>       ;; Get rid of drawers
>       (org-export-remove-or-extract-drawers drawers
> @@ -1478,10 +1489,6 @@ on this string to produce the exported  
> version."
>       ;; Blockquotes and verse
>       (org-export-mark-blockquote-and-verse)
>
> -      ;; Remove comment environment and comment subtrees
> -      (org-export-remove-comment-blocks-and-subtrees)
> -
> -
>       ;; Find matches for radio targets and turn them into internal  
> links
>       (org-export-mark-radio-links)
>
> @@ -1783,15 +1790,21 @@ These special cookies will later be  
> interpreted by the backend."
> 		       "ORG-VERSE-END" "ORG-VERSE-START")
> 		   t t)))
>
> -(defun org-export-remove-comment-blocks-and-subtrees ()
> -  "Remove the comment environment, and also commented subtrees."
> +(defun org-export-handle-comment-blocks-and-subtrees (comment-blocks)
> +  "Prepare comment blocks and comment subtrees for export.  If
> +COMMENT-BLOCKS is non-nil then format comment blocks using
> +`org-export-format-comment', otherwise hide all comment blocks
> +during export.  Hides all comment subtrees."
>   (let ((re-commented (concat "^\\*+[ \t]+" org-comment-string "\\>"))
> -        (case-fold-search nil))
> +        (case-fold-search t))
>     ;; Remove comment environment
>     (goto-char (point-min))
>     (while (re-search-forward
> -	    "^#\\+BEGIN_COMMENT[ \t]*\n[^\000]*?^#\\+END_COMMENT\\>.*" nil  
> t)
> -      (replace-match "" t t))
> +	    "^#\\+begin_comment\\([ \t]+\\(\\S-+\\)\\)?[ \t]*\\(.*\\)?[\r 
> \n]\\([^\000]*?\\)#\\+end_comment"
> +	    nil t)
> +      (replace-match (if comment-blocks
> +			 (org-export-format-comment (match-string 4) (match-string 2)  
> (match-string 3))
> +			 "") t t))
>     ;; Remove subtrees that are commented
>     (goto-char (point-min))
>     (while (re-search-forward re-commented nil t)
> @@ -2170,6 +2183,34 @@ backends, it converts the segment into an  
> EXAMPLE segment."
> 	      (if (string-match "\n\\'" code) "" "\n")
> 	      "#+END_EXAMPLE\n")))))
>
> +(defun org-export-format-comment (body &optional owner title)
> +  "Format comment BODY by OWNER and return it formatted for export.
> +Currently, this only does something for HTML export, for all
> +other backends, it converts the comment into an EXAMPLE segment."
> +  (save-match-data
> +    (cond
> +      (htmlp ;; We are exporting to HTML
> +       (concat "#+BEGIN_HTML\n"
> +	       "<div class=\"org-comment\" "
> +	       (if owner (format "id=\"org-comment-%s\" " owner))
> +	       ">\n"
> +	       (if owner (concat "<b>" owner "</b> ") "")
> +	       (if (and title (> (length title) 0)) (concat " -- " title  
> "</br>\n") "</br>\n")
> +	       "<p>\n"
> +	       "#+END_HTML\n"
> +	       body
> +	       "#+BEGIN_HTML\n"
> +	       "</p>\n"
> +	       "</div>\n"
> +	       "\n#+END_HTML\n"))
> +      (t ;; This is not HTML, so just make it an example.
> +       (concat "#+BEGIN_EXAMPLE\n"
> +	       (if title (concat "Title:" title "\n") "")
> +	       (if owner (concat "By:" owner "\n") "")
> +	       body
> +	       (if (string-match "\n\\'" body) "" "\n")
> +	       "#+END_EXAMPLE\n")))))
> +
> ;;; ASCII export
>
> (defvar org-last-level nil) ; dynamically scoped variable
> @@ -2250,6 +2291,7 @@ underlined headlines.  The default is 3."
> 		  :verbatim-multiline t
> 		  :select-tags (plist-get opt-plist :select-tags)
> 		  :exclude-tags (plist-get opt-plist :exclude-tags)
> +		  :comment-blocks (plist-get opt-plist :comment-blocks)
> 		  :archived-trees
> 		  (plist-get opt-plist :archived-trees)
> 		  :add-text (plist-get opt-plist :text))
> @@ -2924,7 +2966,9 @@ PUB-DIR is set, use this as the publishing  
> directory."
> 	    :add-text
> 	    (plist-get opt-plist :text)
> 	    :LaTeX-fragments
> -	    (plist-get opt-plist :LaTeX-fragments))
> +	    (plist-get opt-plist :LaTeX-fragments)
> +	    :comment-blocks
> +	    (plist-get opt-plist :comment-blocks))
> 	   "[\r\n]"))
> 	 table-open type
> 	 table-buffer table-orig-buffer
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: patch [Feature Addition] exporting comments on org files to html
  2008-11-06  7:05 ` Carsten Dominik
@ 2008-11-07  5:40   ` Eric Schulte
  2008-11-07 19:02     ` modular block exportation was " Eric Schulte
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Schulte @ 2008-11-07  5:40 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Org-mode

Carsten Dominik <dominik@science.uva.nl> writes:

> Hi Eric,
>
> before adding this, I would like to investigate with you if selective
> export (section 12.2 of the manual) could maybe used to achieve pretty
> much the same goal, with the only limiting condition that the part
> treated as a switchable comment does structurally have to be a
> subtree.
>

Hi Carsten,

That's really the motivation; the ability to embed a comment anywhere in
an org-mode file without changing the structure of the document.  Also I
liked the ability to change the colors of the comments based on the
initial string following the =#+begin_comment= part of the block.  Maybe
this would be more useful if it was generalized to selectively exporting
any =#+begin_*= type of block?

>
> Are you aware of selective export?  Maybe you could give us more
> detail about how you actually used this, and to what end?
>

We are building an application which has a web interface.  As we're in
the early stages we have been tracking todo's (and documenting the app)
with an org-mode file, which exports to the documentation of the
application and it times it is useful to export our comments as well.

Of course as this likely isn't generally useful I understand not pushing
it into the already busy org-exp.el file.

Thanks -- Eric

>
> - Carsten
>
>
> On Nov 5, 2008, at 7:50 AM, Eric Schulte wrote:
>
>> Hi,
>>
>> I have been co-authoring an org-mode file with a co-worker, and we
>> started to put comments in org-blocks with the following format
>>
>> #+begin_comment ems example comment
>> body of the comment
>> - a list inside
>> - of the comment
>> #+end_comment
>>
>> I made the following additions to org-exp.el (patch attached) which
>> allows the optional exportation of comment blocks through the use of a
>> `block-comments' option line in the file header.
>>
>> #+OPTIONS:   comment-blocks:t
>>
>> Currently it only exports to html, and it styles the blocks using css
>> (added to the org default html css styles).  It also adds id's to the
>> comment divs which include the authors name, so it's possible to style
>> the comments by their author (for example different colors by author).
>> I used something like the following to style our comments (our
>> initials
>> are wrg and ems).  I'm certainly no css expert, so I'm sure it's
>> possible to get much nicer looking comment blocks.
>>
>> ,----[comment-style.css]
>> | div#org-comment-wrg {
>> |   background: #cdecf8;
>> |   border: solid 1px #09abe7;
>> |   padding: 0.5em;
>> | }
>> |
>> | div#org-comment-ems {
>> |   background: #d1fbaf;
>> |   border: solid 1px #78ed19;
>> |   padding: 0.5em;
>> | }
>> `----
>>
>> Here's the patch to org-exp.el.  I'd love to hear any
>> ideas/issues/feedback.
>>
>> Cheers -- Eric
>>
>> diff --git a/lisp/org-exp.el b/lisp/org-exp.el
>> index 4be6b01..b3a848e 100644
>> --- a/lisp/org-exp.el
>> +++ b/lisp/org-exp.el
>> @@ -252,6 +252,11 @@ e.g. \"timestamp:nil\"."
>>   :group 'org-export-general
>>   :type 'boolean)
>>
>> +(defcustom org-export-comment-blocks nil
>> +  "If non-nil, export comment blocks"
>> +  :group 'org-export-general
>> +  :type 'boolean)
>> +
>> (defcustom org-export-with-tags 'not-in-toc
>>   "If nil, do not export tags, just remove them from headlines.
>> If this is the symbol `not-in-toc', tags will be removed from table of
>> @@ -519,6 +524,7 @@ Org-mode file."
>>                                white-space:nowrap; }
>>   .org-info-js_search-highlight {background-color:#ffff00;
>> color:#000000;
>>                                  font-weight:bold; }
>> +  .org-comment { background: #efefef; border: solid 1px; }
>>  ]]>
>> </style>"
>>   "The default style specification for exported HTML files.
>> @@ -817,6 +823,7 @@ or if they are only using it locally."
>>     (:footnotes            . org-export-with-footnotes)
>>     (:drawers              . org-export-with-drawers)
>>     (:tags                 . org-export-with-tags)
>> +    (:comment-blocks       . org-export-comment-blocks)
>>     (:TeX-macros           . org-export-with-TeX-macros)
>>     (:LaTeX-fragments      . org-export-with-LaTeX-fragments)
>>     (:skip-before-1st-heading . org-export-skip-text-before-1st-
>> heading)
>> @@ -962,7 +969,8 @@ modified) list.")
>> 		  ("skip"  . :skip-before-1st-heading)
>> 		  ("author" . :author-info)
>> 		  ("creator" . :creator-info)
>> -		  ("timestamp" . :time-stamp-file)))
>> +		  ("timestamp" . :time-stamp-file)
>> +		  ("comment-blocks" . :comment-blocks)))
>> 	    o)
>> 	(while (setq o (pop op))
>> 	  (if (string-match (concat (regexp-quote (car o))
>> @@ -1436,6 +1444,9 @@ on this string to produce the exported version."
>>
>>       ;; Handle source code snippets
>>       (org-export-replace-src-segments)
>> +
>> +      ;; Handle comment environment and comment subtrees
>> +      (org-export-handle-comment-blocks-and-subtrees (plist-get
>> parameters :comment-blocks))
>>
>>       ;; Get rid of drawers
>>       (org-export-remove-or-extract-drawers drawers
>> @@ -1478,10 +1489,6 @@ on this string to produce the exported
>> version."
>>       ;; Blockquotes and verse
>>       (org-export-mark-blockquote-and-verse)
>>
>> -      ;; Remove comment environment and comment subtrees
>> -      (org-export-remove-comment-blocks-and-subtrees)
>> -
>> -
>>       ;; Find matches for radio targets and turn them into internal
>> links
>>       (org-export-mark-radio-links)
>>
>> @@ -1783,15 +1790,21 @@ These special cookies will later be
>> interpreted by the backend."
>> 		       "ORG-VERSE-END" "ORG-VERSE-START")
>> 		   t t)))
>>
>> -(defun org-export-remove-comment-blocks-and-subtrees ()
>> -  "Remove the comment environment, and also commented subtrees."
>> +(defun org-export-handle-comment-blocks-and-subtrees (comment-blocks)
>> +  "Prepare comment blocks and comment subtrees for export.  If
>> +COMMENT-BLOCKS is non-nil then format comment blocks using
>> +`org-export-format-comment', otherwise hide all comment blocks
>> +during export.  Hides all comment subtrees."
>>   (let ((re-commented (concat "^\\*+[ \t]+" org-comment-string "\\>"))
>> -        (case-fold-search nil))
>> +        (case-fold-search t))
>>     ;; Remove comment environment
>>     (goto-char (point-min))
>>     (while (re-search-forward
>> -	    "^#\\+BEGIN_COMMENT[ \t]*\n[^\000]*?^#\\+END_COMMENT\\>.*"
>> nil t)
>> -      (replace-match "" t t))
>> +	    "^#\\+begin_comment\\([ \t]+\\(\\S-+\\)\\)?[
>> \t]*\\(.*\\)?[\r
>> \n]\\([^\000]*?\\)#\\+end_comment"
>> +	    nil t)
>> +      (replace-match (if comment-blocks
>> +			 (org-export-format-comment (match-string 4)
>> (match-string 2) (match-string 3))
>> +			 "") t t))
>>     ;; Remove subtrees that are commented
>>     (goto-char (point-min))
>>     (while (re-search-forward re-commented nil t)
>> @@ -2170,6 +2183,34 @@ backends, it converts the segment into an
>> EXAMPLE segment."
>> 	      (if (string-match "\n\\'" code) "" "\n")
>> 	      "#+END_EXAMPLE\n")))))
>>
>> +(defun org-export-format-comment (body &optional owner title)
>> +  "Format comment BODY by OWNER and return it formatted for export.
>> +Currently, this only does something for HTML export, for all
>> +other backends, it converts the comment into an EXAMPLE segment."
>> +  (save-match-data
>> +    (cond
>> +      (htmlp ;; We are exporting to HTML
>> +       (concat "#+BEGIN_HTML\n"
>> +	       "<div class=\"org-comment\" "
>> +	       (if owner (format "id=\"org-comment-%s\" " owner))
>> +	       ">\n"
>> +	       (if owner (concat "<b>" owner "</b> ") "")
>> +	       (if (and title (> (length title) 0)) (concat " -- "
>> title "</br>\n") "</br>\n")
>> +	       "<p>\n"
>> +	       "#+END_HTML\n"
>> +	       body
>> +	       "#+BEGIN_HTML\n"
>> +	       "</p>\n"
>> +	       "</div>\n"
>> +	       "\n#+END_HTML\n"))
>> +      (t ;; This is not HTML, so just make it an example.
>> +       (concat "#+BEGIN_EXAMPLE\n"
>> +	       (if title (concat "Title:" title "\n") "")
>> +	       (if owner (concat "By:" owner "\n") "")
>> +	       body
>> +	       (if (string-match "\n\\'" body) "" "\n")
>> +	       "#+END_EXAMPLE\n")))))
>> +
>> ;;; ASCII export
>>
>> (defvar org-last-level nil) ; dynamically scoped variable
>> @@ -2250,6 +2291,7 @@ underlined headlines.  The default is 3."
>> 		  :verbatim-multiline t
>> 		  :select-tags (plist-get opt-plist :select-tags)
>> 		  :exclude-tags (plist-get opt-plist :exclude-tags)
>> +		  :comment-blocks (plist-get opt-plist :comment-blocks)
>> 		  :archived-trees
>> 		  (plist-get opt-plist :archived-trees)
>> 		  :add-text (plist-get opt-plist :text))
>> @@ -2924,7 +2966,9 @@ PUB-DIR is set, use this as the publishing
>> directory."
>> 	    :add-text
>> 	    (plist-get opt-plist :text)
>> 	    :LaTeX-fragments
>> -	    (plist-get opt-plist :LaTeX-fragments))
>> +	    (plist-get opt-plist :LaTeX-fragments)
>> +	    :comment-blocks
>> +	    (plist-get opt-plist :comment-blocks))
>> 	   "[\r\n]"))
>> 	 table-open type
>> 	 table-buffer table-orig-buffer
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Remember: use `Reply All' to send replies to the list.
>> Emacs-orgmode@gnu.org
>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: modular block exportation was patch [Feature Addition] exporting comments on org files to html
  2008-11-07  5:40   ` Eric Schulte
@ 2008-11-07 19:02     ` Eric Schulte
  2008-11-10  8:26       ` Carsten Dominik
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Schulte @ 2008-11-07 19:02 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Org-mode

Hi,

This has had me thinking about the exportation of blocks in general.  I
think it makes sense to pull block exportation out into it's own
component both for simplicity and for ease of code-reading, hacking, and
customization.

with a set of blocks of forms like...

#+begin_html

#+begin_src

#+begin_comment

#+begin_example

etc...

We could have an alist in which we look up the type of the block, and
call the appropriate function to handle exportation.  Users could then
add their own custom block export functions to this list.

The optional exportation of these blocks could then be controlled by a
single #+option variable which takes a list of blocks not to export.
For example

#+OPTION   hidden_blocks:comment,src

I'd be interested to hear anyone's thoughts on this.  If it sounds like
a good idea I'd be happy to take a stab at implementation.

Cheers -- Eric

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: modular block exportation was patch [Feature Addition] exporting comments on org files to html
  2008-11-07 19:02     ` modular block exportation was " Eric Schulte
@ 2008-11-10  8:26       ` Carsten Dominik
  2008-11-10 15:49         ` Eric Schulte
  2008-11-12  2:03         ` Eric Schulte
  0 siblings, 2 replies; 8+ messages in thread
From: Carsten Dominik @ 2008-11-10  8:26 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Org-mode

Hi Eric,

I think this interesting functionality could at least initially
be implemented as a add-on, hooking into `org-export-preprocess-hook'.
This hook is called before Org looks at any of the blocks, so the hook
could remove blocks or format them and replace them with finished
HTML (in the case of HTML export....) in a BEGIN_HTML ... END_HTML  
block.

- Carsten


On Nov 7, 2008, at 8:02 PM, Eric Schulte wrote:

> Hi,
>
> This has had me thinking about the exportation of blocks in  
> general.  I
> think it makes sense to pull block exportation out into it's own
> component both for simplicity and for ease of code-reading, hacking,  
> and
> customization.
>
> with a set of blocks of forms like...
>
> #+begin_html
>
> #+begin_src
>
> #+begin_comment
>
> #+begin_example
>
> etc...
>
> We could have an alist in which we look up the type of the block, and
> call the appropriate function to handle exportation.  Users could then
> add their own custom block export functions to this list.
>
> The optional exportation of these blocks could then be controlled by a
> single #+option variable which takes a list of blocks not to export.
> For example
>
> #+OPTION   hidden_blocks:comment,src
>
> I'd be interested to hear anyone's thoughts on this.  If it sounds  
> like
> a good idea I'd be happy to take a stab at implementation.
>
> Cheers -- Eric

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: modular block exportation was patch [Feature Addition] exporting comments on org files to html
  2008-11-10  8:26       ` Carsten Dominik
@ 2008-11-10 15:49         ` Eric Schulte
  2008-11-12  2:03         ` Eric Schulte
  1 sibling, 0 replies; 8+ messages in thread
From: Eric Schulte @ 2008-11-10 15:49 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Org-mode

Thanks for the pointer,

I'll be sure to follow that path for any future work on this front.

-- Eric

Carsten Dominik <dominik@science.uva.nl> writes:

> Hi Eric,
>
> I think this interesting functionality could at least initially
> be implemented as a add-on, hooking into `org-export-preprocess-hook'.
> This hook is called before Org looks at any of the blocks, so the hook
> could remove blocks or format them and replace them with finished
> HTML (in the case of HTML export....) in a BEGIN_HTML ... END_HTML
> block.
>
> - Carsten
>
>
> On Nov 7, 2008, at 8:02 PM, Eric Schulte wrote:
>
>> Hi,
>>
>> This has had me thinking about the exportation of blocks in general.
>> I
>> think it makes sense to pull block exportation out into it's own
>> component both for simplicity and for ease of code-reading, hacking,
>> and
>> customization.
>>
>> with a set of blocks of forms like...
>>
>> #+begin_html
>>
>> #+begin_src
>>
>> #+begin_comment
>>
>> #+begin_example
>>
>> etc...
>>
>> We could have an alist in which we look up the type of the block, and
>> call the appropriate function to handle exportation.  Users could then
>> add their own custom block export functions to this list.
>>
>> The optional exportation of these blocks could then be controlled by a
>> single #+option variable which takes a list of blocks not to export.
>> For example
>>
>> #+OPTION   hidden_blocks:comment,src
>>
>> I'd be interested to hear anyone's thoughts on this.  If it sounds
>> like
>> a good idea I'd be happy to take a stab at implementation.
>>
>> Cheers -- Eric

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: modular block exportation was patch [Feature Addition] exporting comments on org files to html
  2008-11-10  8:26       ` Carsten Dominik
  2008-11-10 15:49         ` Eric Schulte
@ 2008-11-12  2:03         ` Eric Schulte
  2008-11-12  6:50           ` Carsten Dominik
  1 sibling, 1 reply; 8+ messages in thread
From: Eric Schulte @ 2008-11-12  2:03 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Org-mode

Carsten Dominik <dominik@science.uva.nl> writes:

> Hi Eric,
>
> I think this interesting functionality could at least initially
> be implemented as a add-on, hooking into `org-export-preprocess-hook'.
> This hook is called before Org looks at any of the blocks, so the hook
> could remove blocks or format them and replace them with finished
> HTML (in the case of HTML export....) in a BEGIN_HTML ... END_HTML
> block.
>

Hi Carsten,

Thanks for the pointer.  I was able to implement generic block
pre-processing on export using the `org-export-preprocess-hook' you
mentioned.  The resulting org-mode add-on is hosted at

http://github.com/eschulte/org-contrib/tree/master/org-exp-blocks.el

Currently it implements the comment processing I was after, and ditaa
image creation.  I think that it could also be used to implement the
src-code, block-quote, and verse exportation currently implemented in
org-exp.el.

Thanks for the advice, I think this is much better than my initial
comment exportation utility. -- Eric

>
> - Carsten
>
>
> On Nov 7, 2008, at 8:02 PM, Eric Schulte wrote:
>
>> Hi,
>>
>> This has had me thinking about the exportation of blocks in general.
>> I
>> think it makes sense to pull block exportation out into it's own
>> component both for simplicity and for ease of code-reading, hacking,
>> and
>> customization.
>>
>> with a set of blocks of forms like...
>>
>> #+begin_html
>>
>> #+begin_src
>>
>> #+begin_comment
>>
>> #+begin_example
>>
>> etc...
>>
>> We could have an alist in which we look up the type of the block, and
>> call the appropriate function to handle exportation.  Users could then
>> add their own custom block export functions to this list.
>>
>> The optional exportation of these blocks could then be controlled by a
>> single #+option variable which takes a list of blocks not to export.
>> For example
>>
>> #+OPTION   hidden_blocks:comment,src
>>
>> I'd be interested to hear anyone's thoughts on this.  If it sounds
>> like
>> a good idea I'd be happy to take a stab at implementation.
>>
>> Cheers -- Eric

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: modular block exportation was patch [Feature Addition] exporting comments on org files to html
  2008-11-12  2:03         ` Eric Schulte
@ 2008-11-12  6:50           ` Carsten Dominik
  0 siblings, 0 replies; 8+ messages in thread
From: Carsten Dominik @ 2008-11-12  6:50 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Org-mode


On Nov 12, 2008, at 3:03 AM, Eric Schulte wrote:

> Carsten Dominik <dominik@science.uva.nl> writes:
>
>> Hi Eric,
>>
>> I think this interesting functionality could at least initially
>> be implemented as a add-on, hooking into `org-export-preprocess- 
>> hook'.
>> This hook is called before Org looks at any of the blocks, so the  
>> hook
>> could remove blocks or format them and replace them with finished
>> HTML (in the case of HTML export....) in a BEGIN_HTML ... END_HTML
>> block.
>>
>
> Hi Carsten,
>
> Thanks for the pointer.  I was able to implement generic block
> pre-processing on export using the `org-export-preprocess-hook' you
> mentioned.  The resulting org-mode add-on is hosted at
>
> http://github.com/eschulte/org-contrib/tree/master/org-exp-blocks.el
>
> Currently it implements the comment processing I was after, and ditaa
> image creation.  I think that it could also be used to implement the
> src-code, block-quote, and verse exportation currently implemented in
> org-exp.el.

Hi Eric,

since this hook is called early on, you are free to
implement your own processing of other blocks like
example or src as well - maybe in a customizable way, so
that users can opt how they want to do things, of if they
would like to use the formatting built into the Org core.

You might wat to think about the LaTeX side as
well - certainly the ditaa thing could be implemented
for the LaTeX backend - for the ASCII backend it would be
trivial :-)

Thanks for yet another great contribution.

- Carsten

>
>
> Thanks for the advice, I think this is much better than my initial
> comment exportation utility. -- Eric
>
>>
>> - Carsten
>>
>>
>> On Nov 7, 2008, at 8:02 PM, Eric Schulte wrote:
>>
>>> Hi,
>>>
>>> This has had me thinking about the exportation of blocks in general.
>>> I
>>> think it makes sense to pull block exportation out into it's own
>>> component both for simplicity and for ease of code-reading, hacking,
>>> and
>>> customization.
>>>
>>> with a set of blocks of forms like...
>>>
>>> #+begin_html
>>>
>>> #+begin_src
>>>
>>> #+begin_comment
>>>
>>> #+begin_example
>>>
>>> etc...
>>>
>>> We could have an alist in which we look up the type of the block,  
>>> and
>>> call the appropriate function to handle exportation.  Users could  
>>> then
>>> add their own custom block export functions to this list.
>>>
>>> The optional exportation of these blocks could then be controlled  
>>> by a
>>> single #+option variable which takes a list of blocks not to export.
>>> For example
>>>
>>> #+OPTION   hidden_blocks:comment,src
>>>
>>> I'd be interested to hear anyone's thoughts on this.  If it sounds
>>> like
>>> a good idea I'd be happy to take a stab at implementation.
>>>
>>> Cheers -- Eric

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-11-12  6:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-05  6:50 patch [Feature Addition] exporting comments on org files to html Eric Schulte
2008-11-06  7:05 ` Carsten Dominik
2008-11-07  5:40   ` Eric Schulte
2008-11-07 19:02     ` modular block exportation was " Eric Schulte
2008-11-10  8:26       ` Carsten Dominik
2008-11-10 15:49         ` Eric Schulte
2008-11-12  2:03         ` Eric Schulte
2008-11-12  6:50           ` Carsten Dominik

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).