From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 6PtND6ibtmBHDQEAgWs5BA (envelope-from ) for ; Tue, 01 Jun 2021 22:42:16 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id UPB4CqibtmD+fwAAbx9fmQ (envelope-from ) for ; Tue, 01 Jun 2021 20:42:16 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A4B80224A6 for ; Tue, 1 Jun 2021 22:42:15 +0200 (CEST) Received: from localhost ([::1]:40018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loBDJ-0000xI-UR for larch@yhetil.org; Tue, 01 Jun 2021 16:42:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loBCx-0000wx-Ev for emacs-orgmode@gnu.org; Tue, 01 Jun 2021 16:41:51 -0400 Received: from mail-ua1-x933.google.com ([2607:f8b0:4864:20::933]:43882) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1loBCv-00040I-GW for emacs-orgmode@gnu.org; Tue, 01 Jun 2021 16:41:51 -0400 Received: by mail-ua1-x933.google.com with SMTP id f1so9221176uaj.10 for ; Tue, 01 Jun 2021 13:41:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=r2BQxa089wMpE5TRGwS7ZdHEyG/W1uucELWrrhl0O/Q=; b=SvFEsUKESnRF0XQW3wQveSgSO69tTvTktm5GOdlhRAReu0ey2tJSZsrQG9wjhzEr0e Uho5H2v449qfPhkdnOToSNf+GVo8zD8a+bEql2PBiWGjvHAONfiXoIzh2rRlpqZI86zF YJGZwKGzoMbkOKq0RtcjtPmKI1t3bZeSiot/9AaRAIy3boMhmJQ7wBZk0+B3j0U0wSqf c/wEb/90dwQ4+jQMQqDW1qlKmB/Rc4VeIPKUI607/Szf9rUx0Jx3ll+Vbz3aaFHu4s3Y 3w5b2pm+0lZnz5HdqOB8i4hfelAjL7pM6npfmEYha7pWXGOse+A26/EEEZ7tXC6ZG/Jd v9jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=r2BQxa089wMpE5TRGwS7ZdHEyG/W1uucELWrrhl0O/Q=; b=DItBZvUgii0HU/ZSC+q0Dngx/meCUJjeLBeAmmeS8+QqnUPxq8gyf/OuwcmVtZDpjH JQCsoyrS3jWLXLp/Qp32w2TQ0OM6zqIabH9H2GBgHkYGb9aPlNkJwXIMoraqt7Z4N06R OFZsPcTKxpNFtAMG05IkYlJJhmE4SwP3xcQ7eDiSqduRFrwq4D8k6sd44IsjFCj1guVG QEGncuYZjmc3xd/nhDKGqiqcUpKpcgBQDqjsydAd2y7EnDjp+c5wwrMsT6TeYAC3XVss Yg9OhpcZJDyc2TzCut8CYoj4dDeOXgNUEV+obeX0Z8saaL4Q5eZWS0igunhlYeE0saZR 5Scg== X-Gm-Message-State: AOAM530VkBXj8XkeTuNEAdhQp/beJxrlCuH7GO8qnI2CeDAtesfY/TbQ qSba13SkSO/mHbACtKrHJfqFUPvpgTVnc4NIY7CLb1QlHNs= X-Google-Smtp-Source: ABdhPJxlRAPFwVhmBjZYmM9ej11yMNCL8yi77X3ki1raQuQn7dTO9BfqqFgg2+DTmK0SP5TNqUJ52pjAO1cDCL4Oa1w= X-Received: by 2002:a1f:2b14:: with SMTP id r20mr19856997vkr.9.1622580108001; Tue, 01 Jun 2021 13:41:48 -0700 (PDT) MIME-Version: 1.0 References: <87tumij6kv.fsf@nicolasgoaziou.fr> In-Reply-To: <87tumij6kv.fsf@nicolasgoaziou.fr> From: Dov Grobgeld Date: Tue, 1 Jun 2021 23:41:36 +0300 Message-ID: Subject: Re: Newline woes when exporting to mediawiki markup To: emacs-orgmode , Nicolas Goaziou Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2607:f8b0:4864:20::933; envelope-from=dov.grobgeld@gmail.com; helo=mail-ua1-x933.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1622580135; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=r2BQxa089wMpE5TRGwS7ZdHEyG/W1uucELWrrhl0O/Q=; b=gc5CnQ8Ikkd+LuPmq0acVlT8AuhUcDBOjFb/P+HsobbJk+/Ac+Xyi0lAQCymfpOzQT+0x3 3vEbWZerbAu/p3ywb9ZVfY8wDW2bzvl3DmXXez2T50vYabvockdwcLTLsto8VFyc9UA8ci we71f53dU9H4GydaIiCzeUYV7Lu2w8AHXEFN3emIkvCE1rJD6ha7EqnZSBuiU+a7NvCJyo KH2Aq2IcBtY5Nc0TstuMZ6DrHLqsDL4WFJoKzKJdBiwNhJKu6E1erSS3iYKyLNT0cJ0UvU BJ6pfA2W8Ux+DS+VzS9VsoouYaxfcW6cP8r0h4bEPV4sd42JNI2TKFy02WLtkA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1622580135; a=rsa-sha256; cv=none; b=rRZz3gLVn45iJ9BuhH454WPZt+e8fvHUY737WEw8FKhQ4GK/RgU5GYSg5BEPf02wCxdrCV atty7LdhUQ1k+j1j06agWt025I9am1q0G+Pryq92iQc2LaFP4CQ/wMf+lIjNzILrL1hw1e TQe9moyn004culxJESGurocKpIDB9AXD2LCTeGMt93XyfRV3jlIBrIk/fNs3WJCdcYayBU q8soNo99JzPHvJv0+stOPCieh9/wt8zdZCTCTxX5OSTb0VqKKpM+C58GGqqVGWKLdNU7/4 pharUZHXgQ4+//UrqO9lQ4b/zdF5l42iMmqrV/ce7v1zXr9RZ/CRl6hGxPjrsQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=SvFEsUKE; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -3.13 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=SvFEsUKE; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: A4B80224A6 X-Spam-Score: -3.13 X-Migadu-Scanner: scn0.migadu.com X-TUID: 3Jqy5XlzcDYh 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
    and
      lists. But that's ok for now. Thanks again! On Tue, Jun 1, 2021 at 12:08 PM Nicolas Goaziou wrote: > > Hello, > > Dov Grobgeld 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