From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id sE4eJGge1GEu0gAAgWs5BA (envelope-from ) for ; Tue, 04 Jan 2022 11:16:08 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id IHiwIGge1GGhFwAAauVa8A (envelope-from ) for ; Tue, 04 Jan 2022 11:16:08 +0100 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 083EA173E3 for ; Tue, 4 Jan 2022 11:16:08 +0100 (CET) Received: from localhost ([::1]:50744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n4grP-0003aA-3k for larch@yhetil.org; Tue, 04 Jan 2022 05:16:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47924) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n4gqT-0003Wv-OE for emacs-orgmode@gnu.org; Tue, 04 Jan 2022 05:15:10 -0500 Received: from mout01.posteo.de ([185.67.36.65]:60293) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n4gqN-0004gh-RE for emacs-orgmode@gnu.org; Tue, 04 Jan 2022 05:15:09 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 911B224002C for ; Tue, 4 Jan 2022 11:15:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1641291300; bh=ZJeZl8yLNu0mefG+FYWvP0+gPUeXSdAngPWTy6r8dE0=; h=From:To:Subject:Date:From; b=IncAng+NpPm3uJffhkvPErHJBxNQtz69gWVtOejbBkvIGMzuYv0pfyv/I8L7qE7R9 Xt2/3YSbv0kaWgG5ewp65Izsgk4wuM0Xv9m3V+C1YXqK9L/Zv8+o1kXA4KuOVUdxXZ FtJFS4vjZ/Tiontk/pMQEtAOsXjMB2qf21ciMcVb4R0HcUFqxVjSqXSsx9Wbh1hBKr b0FJp00p0cH3yIszybyRj87SckWxxB3z53Xp/8xaNIfxHWwN7mJR3CCxolZvyev7QT 6utSVb4pmTJauAqGeCMv6eG3E3cTT8VGnQ+iuKd7+r8b5ydMu6kGkHexqQj91hFGTC uUwdpoqMivIIw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4JSpQC74zYz6tmL for ; Tue, 4 Jan 2022 11:14:59 +0100 (CET) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: orgmode Subject: A simple Lua filter for Pandoc Date: Tue, 04 Jan 2022 10:14:58 +0000 Message-ID: <875yqzu7rx.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.67.36.65; envelope-from=maciaschain@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 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 X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1641291368; 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: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=wYnEBsOSPrfYvDe6T4siSj3nlbR6YA+3eSecE7HQxLM=; b=eOglMtqna9H4VKgi4BnoGSc31oSa5PzN38P+Hlx4v3/Bzm57rLfo9q4dAC3yOPJC8hqd78 dX5/IdPGSZ+pxE7tuW4ZzgAUBYw36O67FRDweQZtwqKn/9OA9tcTyz0h2BLwLl2RdDdRly JnDYIOXFT70wlKoc+NvSp2hTGufrLITqd63XuB+WsSkmfEq/jXjv02iH53mqERt4m0TOCh SECZ6rGgj2qXN1lvlifH2XTH9/dJeFSK0ajgft6ttKGz/V1RSobcJYa5tWVQU1MnJmuBM/ yUYeXMJGLV6OQ2pP9wQywzgjMxOWtbjU2lMK0IE3qdvBCbK19EkiTikBa1PDLQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1641291368; a=rsa-sha256; cv=none; b=SzBFjtcu7u/YS0vl8Rc5Y0IeoB7iKrLTMSX72TR4UvO6GGDxNJuMjqjcbL/DI+9GLJBvSo hmPOPVBb7VvQ8TuFAAZNJ8LI9pX4Z6IwenmlN7bMXoi0SsQ7dBfAEE0mQ6EKSj4rmY5nSt HxHyGnoR+W5lJLFO4Gqj7qdD/t42aRG0TN/3fXVx06tizty4b13jvDCg60FtvGewI4FfVE AxTjT7s82dqSKyG+gvtSIRo4bO0/BqFQd5zhFzKoGx2UCmjXlAk8O+qxRJnYLurjI2oYpm aWS6YHMTO7pMf5LdPXhete/R+u2tL9w8y3xNY1hC49/6KeEBp/f/1ddPgqmJTQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=IncAng+N; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.99 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=IncAng+N; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 083EA173E3 X-Spam-Score: -3.99 X-Migadu-Scanner: scn1.migadu.com X-TUID: IKBNNlB5H57i Hi, Very often I need to convert docx documents to Org. There are a series of characters that I prefer to be passed to Org as Org entities and not literally, so I have written this little filter in Lua for Pandoc. I share it here in case it could be useful to someone. Of course, the associative table can be expanded with more replacement cases: #+begin_src lua :tangle entities.lua local chars =3D {["/"] =3D "\\slash{}", ["*"] =3D "\\lowast{}", ["<"] =3D= "\\lt{}", [">"] =3D "\\gt{}", ["=E2=80=A0"] =3D "\\dagger{}", [utf8.char(0x00A0)] = =3D "\\nbsp{}"} function Str (elem) x =3D elem.text:match 'http[^%s]' if not x then for i in pairs(chars) do elem =3D pandoc.Str(elem.text:gsub (i, chars[i])) end return elem end end #+end_src And a quick test: #+begin_src sh :results org str=3D"/ =E2=80=A0 * < > http://foo.es =C2=A0" pandoc -f markdown -t org --lua-filter=3Dentities.lua <<< $str #+end_src #+RESULTS: #+begin_src org \slash{} \dagger{} \lowast{} \lt{} \gt{} http://foo.es \nbsp{} #+end_src Best regards, Juan Manuel=20