From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/23333 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: John MacFarlane Newsgroups: gmane.text.pandoc Subject: Re: Replace Str with HTML in Lua Filter Date: Thu, 29 Aug 2019 10:51:33 -0700 Message-ID: References: <8736i9qa95.fsf@zeitkraut.de> <87a12669-ed81-4ce4-aa8e-eb5d3d64bf3d@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="146206"; mail-complaints-to="usenet@blaine.gmane.org" To: Ken Dow , pandoc-discuss Original-X-From: pandoc-discuss+bncBCJZJHG45QDBBM5BUDVQKGQEM32LWFI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Aug 29 19:51:49 2019 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-pf1-f190.google.com ([209.85.210.190]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1i3OaL-000bub-8F for gtp-pandoc-discuss@m.gmane.org; Thu, 29 Aug 2019 19:51:49 +0200 Original-Received: by mail-pf1-f190.google.com with SMTP id s10sf3072464pfd.16 for ; Thu, 29 Aug 2019 10:51:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1567101107; cv=pass; d=google.com; s=arc-20160816; b=sXQYoQrqgcm3Bd6lMDQG2/bXNybmpUWpVxjTOE4NSVyZf0SkZr8H+SdrhTSHEErua0 7SEfWFsnOH+ADdeznZN0nihDYRBcUlkqAIg+V9b35nGguMsQe+HbhIxqku83mrxiZXPn SQq2xJQTUze+SmLxetvaOLI756/0p1q4f0L2x2AhTrDvzCUK1BjLT+Kn/QxrlrCB/xtj Hk1ljaI50vQ/5PtiowMuQiZvEYKYdt4+Z5zqryKP0iCCtCVzS4oF4CZPxlpAeaeQ2QPt rPpK5tc++8RGZMNhhDtNnzXVs07H+JTNNHJ/T6ocD8oqPCdv10bW5sHneqaZ+WzzCBDS C6bA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:content-transfer-encoding :mime-version:message-id:date:references:in-reply-to:subject:to:from :sender:dkim-signature; bh=2BhtN3P5qMj5oseNqJyb7u3zC0XFMuwoNiq4s2hmxW4=; b=cSiT7ckNMrnpv6dGHdBr68DJVdlXMUtsxkG/v9YJXKGlIFRI5t2AFvObjy9l0nTqjk 4PHaSoAksAHzn/DePzaIYUjy9ps+33WtcdMN5SMYWmgDxEs/piaUISoLBDwH77ltNId5 lrp0Bzkcc3HzOptBZ88HtQZbcTCwbpVdjwFEguii/IHP7dsPCJze7QVJnAhJorckpWRA NbJTt9zfnBgn1RZG+YYeqy6zmemkSCvLvayQuTWBhrkfjS3ZfjGhMTPTcQ4cZLLUSnMu y82iyHxA/EmLkGeb8+rn72Mw9dLjRXZ5CSijp+fmJhmt6Bb5wMnY4FTr7B9/sWXeN7EY 32+A== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20150623.gappssmtp.com header.s=20150623 header.b=FvI7sMKE; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::431 as permitted sender) smtp.mailfrom=jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:subject:in-reply-to:references:date:message-id :mime-version:content-transfer-encoding:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=2BhtN3P5qMj5oseNqJyb7u3zC0XFMuwoNiq4s2hmxW4=; b=Z0orTDknNQ4JP+zNKcftUujaQECnOv+uEy1shWF5BrsNzTM2AHD3XI5juU+rugq/XK 6Fg4dcB5bEgIae+LDR5fjanI4rRvENhaXyUwR0vt1jG+PlONb/FzJW1jT6zmMS4KP/co H5c0sR/W05mq4X+FO6B8+hnhQSCnZjvDFK30u3Fj3XfbxSciUJr7Hv2mvEbq+6KzqSYl n+T620cqCFExA6FSwhbJiyLLx8v98eAzqML8K+ydrF/NRESFkzdsxXEugqAcc0yapBJ3 H+5X1t7YYMkIODVUnuYBueFxBGwApECUZjDNKB+WEIyXsyNmFxL3QvsP1Z6uc35pLzV1 W/VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:subject:in-reply-to:references :date:message-id:mime-version:content-transfer-encoding :x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=2BhtN3P5qMj5oseNqJyb7u3zC0XFMuwoNiq4s2hmxW4=; b=Ua99vOUgXPKhiclBE/NqnLOAnzSA0t48uJVigh9EX7zlTZY9YV9Zc21cXi38StA15l LApy2XrC/i7YVR512B/jG2ABDc86J5DQ5IanQ0+Ax6x1cR0/WIDSXn+pezVPmE01w7wn zZ9Zy0r9XX1+5quzVl5gCd7yVpDSZLvxx1mNST+XFs2WPIr3r9KqwhfRbh/IKvtyGxbr Zomm5XqO7uZ3gFXCFtFcz8EiJgSOlzHj+CDwxeCX7CMJhV5U6spKIN8yVqQE3Xy8lUG3 LZGrGiYGzZbhv0wwuYVPtHWakh0/bJq6dU3pkmVmba9TS2Uh+M09CrIFuFqlXulNa234 Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: APjAAAULk3Ly11v0BFqdV+/fAcZwh62ti3PIpQ5CARtYjzCgxra3tYcU USPyWa7vY3QJ/wPlYnAnjO8= X-Google-Smtp-Source: APXvYqzyrwqYZDosvUkJM+5aKRo6XsjB+Us6+mZj86zCZ6qyjmCCvd/FgoIeZGPECukzkOYz4aQzGg== X-Received: by 2002:aa7:8a0a:: with SMTP id m10mr13391635pfa.100.1567101107540; Thu, 29 Aug 2019 10:51:47 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a62:53c2:: with SMTP id h185ls1079323pfb.1.gmail; Thu, 29 Aug 2019 10:51:46 -0700 (PDT) X-Received: by 2002:a63:784c:: with SMTP id t73mr9835379pgc.268.1567101106620; Thu, 29 Aug 2019 10:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567101106; cv=none; d=google.com; s=arc-20160816; b=lwO8yPRg+ugmTdX8eO1Mne4VqjOwhgtgUPp8MIdMA7W9Bs015OxE17EGxjFIJMKT8+ kBTQkPddG2+6U3+HczPD71GkJOkUW2CPsSi5VLA2RG3nBLHS0xaUTvND20GJE60ExYUP CGbfEAKYTRYEJcuALCNcE/Bg0jqdGb8LIVIm1zW3My5Grwb6uk/uG8tXyn9yrDCapzOZ HuSoAGpW7Z5jq/bWU69bkrcTfkDw7fjNQ/sDY5yOcrqaiZBCxOiUPB7ICCyOiEnXu0LL rmtDCO4cDUfVITNtE3H4Xq9lvcd4+1RXJgHJJIjK8RwU8Xp+0d1Abw+WB5Q8muk8oGx7 mpiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:to:from:dkim-signature; bh=9+MvKiK6bgs9ND3othGOs1DPNFDlUH/4BeKpiqUjVlo=; b=yZ546dQP7FjdD5GYxrk0xkdMWZViBcg4Nj6R4oZWFlK8vvFUBcl3i3te7EMu8TvriR wdE53S3eV884wVmNCP/Cu9QdaOYXWtLDJkJNBcHJ+xYMzmoYpc81+Vp4vorYoD+e7sa6 iflNuECpIPcZKMbYKWn+zDaYddcVPT3T8yMvRUpiq3nbNsOCamhxbSZTy+4vj0XUR5aV eyDf9O4XvK7zfP0QHooX03PVJKbu6/TIip0WGJGCM2rzoTGO/MGHTOzUayc5X1sB+IZm IAiJUD2Ohj6vBEgaL9/egY3x8uzRatXpDNQWsahGeNfk4y249BUHVypXIt+X0Z3Muk0y VOWg== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20150623.gappssmtp.com header.s=20150623 header.b=FvI7sMKE; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::431 as permitted sender) smtp.mailfrom=jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org Original-Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com. [2607:f8b0:4864:20::431]) by gmr-mx.google.com with ESMTPS id r202si232047pfc.0.2019.08.29.10.51.46 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Aug 2019 10:51:46 -0700 (PDT) Received-SPF: pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::431 as permitted sender) client-ip=2607:f8b0:4864:20::431; Original-Received: by mail-pf1-x431.google.com with SMTP id o70so2570589pfg.5 for ; Thu, 29 Aug 2019 10:51:46 -0700 (PDT) X-Received: by 2002:aa7:96ee:: with SMTP id i14mr13076122pfq.217.1567101106383; Thu, 29 Aug 2019 10:51:46 -0700 (PDT) Original-Received: from johnmacfarlane.net (li55-134.members.linode.com. [74.82.3.134]) by smtp.gmail.com with ESMTPSA id e189sm2889133pgc.15.2019.08.29.10.51.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 10:51:45 -0700 (PDT) Original-Received: by johnmacfarlane.net (Postfix, from userid 1000) id CEB8AA16D; Thu, 29 Aug 2019 13:51:34 -0400 (EDT) In-Reply-To: <87a12669-ed81-4ce4-aa8e-eb5d3d64bf3d-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> X-Original-Sender: jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20150623.gappssmtp.com header.s=20150623 header.b=FvI7sMKE; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::431 as permitted sender) smtp.mailfrom=jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.org gmane.text.pandoc:23333 Archived-At: Or better yet just use the unicode character (make sure your lua filter is UTF-8 encoded): s.text =3D=3D '=E2=80=93' Ken Dow writes: > Thanks for the help (Sorry for the long delay - I didn't get notified of= =20 > your post). > > I tried your suggestion and it works perfectly when searching for normal= =20 > text (e.g., s.text =3D=3D "Widget") but with s.text =3D=3D "\8211", Pando= c throws=20 > the following error: > > decimal escape too large near '"\5881' > > Single quotes (.e.g, s.text =3D=3D '\8211') gives the same error. I tried= =20 > "\\8211" in case the backslash needs to be escaped; no error but no=20 > replacement occurs. > > Finally, I tried the utf8.codes approach, referring to Material Icon=20 > codepoints doc for the value that should match, like so: > > function Str (s) > if utf8.codes(s.text) =3D=3D 'e5c3' then > return pandoc.RawInline( > 'html', > 'apps' > ) > end > end=20 > > No error but no replacement.=20 > > On Saturday, 10 August 2019 12:02:40 UTC-4, Albert Krewinkel wrote: >> >> Ken Dow writes:=20 >> >> > My DOCX source document, which is being converted to HTML, uses some= =20 >> Google=20 >> > Material fonts. What shows up in the AST are values like=20 >> >=20 >> > Str "\8211"=20 >> >=20 >> > I'd like to find and replace those to produce something like the=20 >> following=20 >> > HTML:=20 >> >=20 >> > face=20 >> >=20 >> > Is that possible and if so, how?=20 >> >> The way to go here is via `RawInline` elements, e.g.:=20 >> >> function Str (s)=20 >> if s.text =3D=3D '=E2=80=93' then=20 >> return pandoc.RawInline(=20 >> 'html',=20 >> 'face'=20 >> )=20 >> end=20 >> end=20 >> >> Note matching on an exact string would fail if the character was=20 >> somewhere within a word (a typical would be em-dashes). One would have= =20 >> to use the [utf8.codes] module to manually find and replace those=20 >> characters in that case.=20 >> >> [utf8.codes](https://www.lua.org/manual/5.3/manual.html#pdf-utf8.codes)= =20 >> >> --=20 >> Albert Krewinkel=20 >> GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124=20 >> > > --=20 > You received this message because you are subscribed to the Google Groups= "pandoc-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an= email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msgi= d/pandoc-discuss/87a12669-ed81-4ce4-aa8e-eb5d3d64bf3d%40googlegroups.com. --=20 You received this message because you are subscribed to the Google Groups "= pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an e= mail to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/= pandoc-discuss/m2muframhm.fsf%40johnmacfarlane.net.