emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-export-generic table exporting
@ 2012-02-08  4:44 Tom Alexander
  2012-02-15 22:55 ` O[PATCH] " Wes Hardaker
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Alexander @ 2012-02-08  4:44 UTC (permalink / raw)
  To: emacs-orgmode

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

I noticed that the org-export-generic.el script had options for basic
features like checkboxes but not for tables, which were locked into
ascii exporting. The attached patch creates many variables to allow
users to change the table formatting (much like how there are
variables like ":body-list-checkbox-done"). I also created a generic
exporter named "mediawiki" that demonstrates use of the table
exporting.

This is my first post to this mailing list, and my first ever
contribution to an open-source project so I look forward to feedback
and be kind when you point out any sort of mailing list etiquette I
might have broken.

--
Tom Alexander
HS - Secretary
Alpha Sigma Phi; Beta Psi Chapter
Rensselaer Polytechnic Institute
Class of 2013

[-- Attachment #2: table_exporting.patch --]
[-- Type: text/x-patch, Size: 5621 bytes --]

From 6e072d97d056cb61fc7810b8b9fea43d3cf9489e Mon Sep 17 00:00:00 2001
From: Tom Alexander <craftkiller@gmail.com>
Date: Tue, 7 Feb 2012 20:15:29 -0500
Subject: [PATCH] Added variables for exporting tables including:   -
 body-table-start   - body-table-end   -
 body-table-row-start   - body-table-row-end   -
 body-table-cell-start   - body-table-cell-end   -
 body-table-first-cell-start   -
 body-table-interior-cell-start   -
 body-table-interior-cell-end   - body-table-last-cell-end  
 - body-table-hline-start   - body-table-hline-end

Added a mediawiki exporter which uses the new table exporting
---
 contrib/lisp/org-export-generic.el |   87 +++++++++++++++++++++++++++++++++--
 1 files changed, 82 insertions(+), 5 deletions(-)

diff --git a/contrib/lisp/org-export-generic.el b/contrib/lisp/org-export-generic.el
index 436badc..9e21992 100644
--- a/contrib/lisp/org-export-generic.el
+++ b/contrib/lisp/org-export-generic.el
@@ -325,6 +325,51 @@ in this way, it will be wrapped."
      :body-bullet-list-prefix       ("* " "** " "*** " "**** " "***** ")
      )
     ;;
+    ;; mediawiki
+    ;;
+    ("mediawiki"
+     :file-suffix        	    ".txt"
+     :key-binding                   ?m
+
+     :header-prefix            	    ""
+     :header-suffix            	    ""
+
+     :title-format             	    "= %s =\n"
+
+     :date-export        	    nil
+
+     :toc-export                    nil
+
+     :body-header-section-numbers   nil
+     :body-section-prefix           "\n"
+
+     :body-section-header-prefix    ("= " "== " "=== "
+				     "==== " "===== " "====== ")
+     :body-section-header-suffix    (" =\n\n" " ==\n\n" " ===\n\n"
+				     " ====\n\n" " =====\n\n" " ======\n\n")
+
+     :body-line-export-preformated  t          ;; yes/no/maybe???
+     :body-line-format              "%s\n"
+     :body-line-wrap                75
+
+     :body-line-fixed-format       " %s\n"
+
+     :body-list-format              "* %s\n"
+     :body-number-list-format       "# %s\n"
+
+     :body-bullet-list-prefix       ("* " "** " "*** " "**** " "***** ")
+     :body-list-checkbox-todo       "☐ "
+     :body-list-checkbox-done       "☒ "
+     :body-table-start              "{|"
+     :body-table-end                "|}"
+     :body-table-cell-start         "|"
+     :body-table-cell-end           "\n"
+     :body-table-last-cell-end      "|-"
+     :body-table-hline-start          ""
+
+
+     )
+    ;;
     ;; internet-draft .xml for xml2rfc exporter
     ;;
     ("ietfid"
@@ -715,7 +760,34 @@ underlined headlines.  The default is 3."
 	  (or (plist-get export-plist :body-list-checkbox-done-end) ""))
 	 (listcheckhalfend
 	  (or (plist-get export-plist :body-list-checkbox-half-end) ""))
-         (bodynewline-paragraph   (plist-get export-plist :body-newline-paragraph))
+	 (bodytablestart
+	  (or (plist-get export-plist :body-table-start) ""))
+	 (bodytableend
+	  (or (plist-get export-plist :body-table-end) ""))
+	 (bodytablerowstart
+	  (or (plist-get export-plist :body-table-row-start) ""))
+	 (bodytablerowend
+	  (or (plist-get export-plist :body-table-row-end) ""))
+	 (bodytablecellstart
+	  (or (plist-get export-plist :body-table-cell-start) ""))
+	 (bodytablecellend
+	  (or (plist-get export-plist :body-table-cell-end) ""))
+	 (bodytablefirstcellstart
+	  (or (plist-get export-plist :body-table-first-cell-start) ""))
+	 (bodytableinteriorcellstart
+	  (or (plist-get export-plist :body-table-interior-cell-start) ""))
+	 (bodytableinteriorcellend
+	  (or (plist-get export-plist :body-table-interior-cell-end) ""))
+	 (bodytablelastcellend
+	  (or (plist-get export-plist :body-table-last-cell-end) ""))
+	 (bodytablehlinestart
+	  (or (plist-get export-plist :body-table-hline-start) " \\1"))
+	 (bodytablehlineend
+	  (or (plist-get export-plist :body-table-hline-end) ""))
+
+
+
+	 (bodynewline-paragraph   (plist-get export-plist :body-newline-paragraph))
 	 (bodytextpre   (plist-get export-plist :body-text-prefix))
 	 (bodytextsuf   (plist-get export-plist :body-text-suffix))
 	 (bodylinewrap  (plist-get export-plist :body-line-wrap))
@@ -1328,16 +1400,21 @@ REVERSE means to reverse the list if the plist match is a list
       (setq lines (org-table-clean-before-export lines)))
     ;; Get rid of the vertical lines except for grouping
     (let ((vl (org-colgroup-info-to-vline-list org-table-colgroup-info))
-	  rtn line vl1 start)
+	  (rtn (list bodytablestart)) line vl1 start)
       (while (setq line (pop lines))
+	(setq line (concat bodytablerowstart line))
 	(if (string-match org-table-hline-regexp line)
 	    (and (string-match "|\\(.*\\)|" line)
-		 (setq line (replace-match " \\1" t nil line)))
+		 (setq line (replace-match (concat bodytablehlinestart bodytablehlineend) t nil line)))
 	  (setq start 0 vl1 vl)
+	  (if (string-match "|\\(.*\\)|" line)
+	      (setq line (replace-match (concat bodytablefirstcellstart bodytablecellstart " \\1 " bodytablecellend bodytablelastcellend) t nil line)))
 	  (while (string-match "|" line start)
-	    (setq start (match-end 0))
-	    (or (pop vl1) (setq line (replace-match " " t t line)))))
+	    (setq start (+ (match-end 0) (length (concat bodytablecellend bodytableinteriorcellend bodytableinteriorcellstart bodytablecellstart))))
+	    (or (pop vl1) (setq line (replace-match (concat bodytablecellend bodytableinteriorcellend bodytableinteriorcellstart bodytablecellstart) t t line)))))
+	(setq line (concat line bodytablerowend))
 	(push line rtn))
+      (setq rtn (cons bodytableend rtn))
       (nreverse rtn))))
 
 (defun org-colgroup-info-to-vline-list (info)
-- 
1.7.9


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

* Re: O[PATCH] org-export-generic table exporting
  2012-02-08  4:44 [PATCH] org-export-generic table exporting Tom Alexander
@ 2012-02-15 22:55 ` Wes Hardaker
  2012-03-09  3:57   ` Tom Alexander
  2012-03-20 16:03   ` Bastien
  0 siblings, 2 replies; 4+ messages in thread
From: Wes Hardaker @ 2012-02-15 22:55 UTC (permalink / raw)
  To: Tom Alexander; +Cc: emacs-orgmode

>>>>> On Tue, 7 Feb 2012 23:44:42 -0500, Tom Alexander <tomalexander@paphus.com> said:

TA> I noticed that the org-export-generic.el script had options for basic
TA> features like checkboxes but not for tables, which were locked into
TA> ascii exporting. The attached patch creates many variables to allow
TA> users to change the table formatting (much like how there are
TA> variables like ":body-list-checkbox-done"). I also created a generic
TA> exporter named "mediawiki" that demonstrates use of the table
TA> exporting.

Awesome!

TA> This is my first post to this mailing list, and my first ever
TA> contribution to an open-source project so I look forward to feedback
TA> and be kind when you point out any sort of mailing list etiquette I
TA> might have broken.

Well, I think you've certainly given a good first shot at a
contribution!

[Hopefully someone with write access will apply it soon]
-- 
Wes Hardaker                                     
My Pictures:  http://capturedonearth.com/
My Thoughts:  http://pontifications.hardakers.net/

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

* Re: O[PATCH] org-export-generic table exporting
  2012-02-15 22:55 ` O[PATCH] " Wes Hardaker
@ 2012-03-09  3:57   ` Tom Alexander
  2012-03-20 16:03   ` Bastien
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Alexander @ 2012-03-09  3:57 UTC (permalink / raw)
  To: Wes Hardaker; +Cc: emacs-orgmode

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

Well thank you! I apologize for the late reply, my coursework has a hold on
me, but I was getting worried when no one responded immediately :-). I
think the next step would be editing the configs for generic exporting to
other mediums to support the tables (which HTML would be beyond trivial
with the variables I included), but I am waiting for the lords of org-mode
to either approve this patch or suggest changes first.

Also, I have been using this modification to handle meeting minutes for my
fraternity for the past month and I have not run into a hiccup yet, so
http://i.imgur.com/xzfgp.jpg .

On Wed, Feb 15, 2012 at 5:55 PM, Wes Hardaker <wjhns209@hardakers.net>wrote:

> >>>>> On Tue, 7 Feb 2012 23:44:42 -0500, Tom Alexander <
> tomalexander@paphus.com> said:
>
> TA> I noticed that the org-export-generic.el script had options for basic
> TA> features like checkboxes but not for tables, which were locked into
> TA> ascii exporting. The attached patch creates many variables to allow
> TA> users to change the table formatting (much like how there are
> TA> variables like ":body-list-checkbox-done"). I also created a generic
> TA> exporter named "mediawiki" that demonstrates use of the table
> TA> exporting.
>
> Awesome!
>
> TA> This is my first post to this mailing list, and my first ever
> TA> contribution to an open-source project so I look forward to feedback
> TA> and be kind when you point out any sort of mailing list etiquette I
> TA> might have broken.
>
> Well, I think you've certainly given a good first shot at a
> contribution!
>
> [Hopefully someone with write access will apply it soon]
> --
> Wes Hardaker
> My Pictures:  http://capturedonearth.com/
> My Thoughts:  http://pontifications.hardakers.net/
>



-- 
Tom Alexander
HS - Secretary
Alpha Sigma Phi; Beta Psi Chapter
Rensselaer Polytechnic Institute
Class of 2013

[-- Attachment #2: Type: text/html, Size: 2598 bytes --]

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

* Re: O[PATCH] org-export-generic table exporting
  2012-02-15 22:55 ` O[PATCH] " Wes Hardaker
  2012-03-09  3:57   ` Tom Alexander
@ 2012-03-20 16:03   ` Bastien
  1 sibling, 0 replies; 4+ messages in thread
From: Bastien @ 2012-03-20 16:03 UTC (permalink / raw)
  To: Wes Hardaker; +Cc: emacs-orgmode, Tom Alexander

Hi there,

Wes Hardaker <wjhns209@hardakers.net> writes:

> TA> This is my first post to this mailing list, and my first ever
> TA> contribution to an open-source project so I look forward to feedback
> TA> and be kind when you point out any sort of mailing list etiquette I
> TA> might have broken.
>
> Well, I think you've certainly given a good first shot at a
> contribution!
>
> [Hopefully someone with write access will apply it soon]

Applied in master.  

Thanks Tom for the patch and Wes for the check!

-- 
 Bastien

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

end of thread, other threads:[~2012-03-20 16:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-08  4:44 [PATCH] org-export-generic table exporting Tom Alexander
2012-02-15 22:55 ` O[PATCH] " Wes Hardaker
2012-03-09  3:57   ` Tom Alexander
2012-03-20 16:03   ` Bastien

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).