unofficial mirror of emacs-orgmode@gnu.org
 help / color / mirror / code / Atom feed
From: Dov Grobgeld <dov.grobgeld@gmail.com>
To: emacs-orgmode <emacs-orgmode@gnu.org>,
	Nicolas Goaziou <mail@nicolasgoaziou.fr>
Subject: Re: Newline woes when exporting to mediawiki markup
Date: Tue, 1 Jun 2021 23:41:36 +0300	[thread overview]
Message-ID: <CA++fsGH592MQoyGuT1x+PB7E2yEp2NPMgX06_a0mOzAz9_TahQ@mail.gmail.com> (raw)
In-Reply-To: <87tumij6kv.fsf@nicolasgoaziou.fr>

Thanks for the help. I now updated the function `org-mw-item` to:

    (defun org-mw-item (item contents info)
      "Transcode ITEM element into Mediawiki format.
    CONTENTS is the item contents.  INFO is a plist used as
    a communication channel."
      (let* ((type (org-element-property :type (org-export-get-parent item)))
             (bullet (if (eq type 'ordered) ?# ?*))
             (the-item (org-trim contents))
             (level (- (/
                     (length (org-element-map (org-element-lineage
item) 'plain-list
                              #'identity info)) 2) 3)))
        (progn
          (org-element-put-property item :post-blank 0)
          (format "%s %s" (make-string level bullet) the-item))))

With this change the following org input:
```
* A section
Here is a list of things

- An item
- Another item
    - A subitem
    - Another subitem
- Back to first
```

Is output as:
```
= A section =
Here is a list of things

* An item
* Another item

** A subitem
** Another subitem
* Back to first

```

This is close to the required result though there is still a redundant
empty line before "A subitem". How can  I get rid of it?

I also have no idea why I had to do the expression $level/2-3$ to get
the correct number of asterisks.

Another complication that I am currently ignoring is how to nest <UL>
and <OL> lists. But that's ok for now.

Thanks again!


On Tue, Jun 1, 2021 at 12:08 PM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
>
> Hello,
>
> Dov Grobgeld <dov.grobgeld@gmail.com> writes:
>
> > I tried to modify ox-mediawiki.el to solve the following two issues:
> >
> > - Get rid of redundant newlines between exported list items
> > - Replicate the leading asterisk to reflect the indentation level of the
> > list.
> >
> > To get of the newline I tried to rewrite the org-export "item" translation
> > function `org-mw-item` but I would either get no newlines at all between my
> > items, or an extra newline between two subsequent items.
> >
> > I just noted that ox-mediawiki is derived from the html backend, so perhaps
> > the limitations are there.
> >
> > I would appreciate any guidance of how to fix this.
>
> It's difficult to answer since I know neither what you tried nor what is
> correct syntax, but I think asterisks could be obtained with
>
>   (let ((level
>          ;; Level can be seen as the number of parent plain lists.
>          (length (org-element-map (org-element-lineage item) 'plain-list
>                    #'identity info))))
>     (make-string level ?*))
>
> To remove any newline, you may try
>
>   (org-element-put-property item :post-blank 0)
>
> prior to returning.
>
> Regards,
> --
> Nicolas Goaziou


      reply	other threads:[~2021-06-01 20:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-01  7:59 Dov Grobgeld
2021-06-01  9:08 ` Nicolas Goaziou
2021-06-01 20:41   ` Dov Grobgeld [this message]

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=CA++fsGH592MQoyGuT1x+PB7E2yEp2NPMgX06_a0mOzAz9_TahQ@mail.gmail.com \
    --to=dov.grobgeld@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    --subject='Re: Newline woes when exporting to mediawiki markup' \
    /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

unofficial mirror of emacs-orgmode@gnu.org

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/orgmode/0 orgmode/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 orgmode orgmode/ https://yhetil.org/orgmode \
		emacs-orgmode@gnu.org
	public-inbox-index orgmode

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


code repositories for project(s) associated with this inbox:

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

AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git