emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Rohit Patnaik" <quanticle@quanticle.net>
To: emacs-orgmode@gnu.org
Subject: Extraneous blank lines in when attempting to export org tables
Date: Sat, 17 Feb 2024 21:36:10 -0600	[thread overview]
Message-ID: <d84d5df0-108f-4a75-b7d2-299392613052@app.fastmail.com> (raw)

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


             reply	other threads:[~2024-02-18  3:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-18  3:36 Rohit Patnaik [this message]
2024-02-18 16:33 ` Extraneous blank lines in when attempting to export org tables Ihor Radchenko
2024-02-19  3:37   ` Rohit Patnaik

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d84d5df0-108f-4a75-b7d2-299392613052@app.fastmail.com \
    --to=quanticle@quanticle.net \
    --cc=emacs-orgmode@gnu.org \
    /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 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).