emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Extraneous blank lines in when attempting to export org tables
@ 2024-02-18  3:36 Rohit Patnaik
  2024-02-18 16:33 ` Ihor Radchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Rohit Patnaik @ 2024-02-18  3:36 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

I'm currently working on an exporter that will allow org-mode to export to
PMWiki markdown (https://github.com/quanticle/ox-pmwiki/), and I'm running into
a problem when writing the export code to handle tables. When exporting table
rows, I'm getting extraneous blank lines between table rows.

My export code for tables is as follows:

#+begin_src elisp
(defun org-pmwiki-table-cell (table-cell contents info)
  "Transcode a TABLE-CELL from org to pmwiki format. CONTENTS is nil. INFO is a
plist used as a communications channel."
  (let ((cell-alignment (org-export-table-cell-alignment table-cell info)))
    (cond ((eq cell-alignment 'left) (format "%s  ||" contents))
          ((eq cell-alignment 'right) (format "  %s||" contents))
          ((eq cell-alignment 'center) (format " %s ||" contents)))))

(defun org-pmwiki-table-row (table-row contents info)
  "Transcode a TABLE-ROW element from org to pmwiki format. CONTENTS is the
contents of the row. INFO is a plist used as a communications channel."
  (format "||%s" contents))

(defun org-pmwiki-table (table contents info)
  "Transcode a TABLE from org to pmwiki format. TABLE is the table element
itself. CONTENTS is the contents of the table. INFO is a plist holding
contextual information."
  contents)
#+end_src

When I run this code on the following table:
#+begin_src org
| Col 1             |     Col 2     |              Col 3 |
| <l>               |      <c>      |                <r> |
| left aligned cell | centered cell | right aligned cell |
#+end_src

I expect to see the following output:

#+begin_example
||Col 1  || Col 2 ||  Col 3||
||left aligned cell  || centered cell ||  right aligned cell||
#+end_example

However, the actual output generated by the code is:

#+begin_example
||Col 1  || Col 2 ||  Col 3||

||left aligned cell  || centered cell ||  right aligned cell||
#+end_example

The contents of each cell are formatted correctly, but there's an additional
newline between the two rows. How do I prevent this newline from being added?

Thanks,
Rohit Patnaik


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

end of thread, other threads:[~2024-02-19  3:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-18  3:36 Extraneous blank lines in when attempting to export org tables Rohit Patnaik
2024-02-18 16:33 ` Ihor Radchenko
2024-02-19  3:37   ` Rohit Patnaik

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