From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/23332 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:50:16 -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="140778"; mail-complaints-to="usenet@blaine.gmane.org" To: Ken Dow , pandoc-discuss Original-X-From: pandoc-discuss+bncBCJZJHG45QDBBZVAUDVQKGQEO4FZAFQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Aug 29 19:50:32 2019 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-vs1-f59.google.com ([209.85.217.59]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1i3OZ6-000aVM-At for gtp-pandoc-discuss@m.gmane.org; Thu, 29 Aug 2019 19:50:32 +0200 Original-Received: by mail-vs1-f59.google.com with SMTP id c22sf255290vse.11 for ; Thu, 29 Aug 2019 10:50:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1567101031; cv=pass; d=google.com; s=arc-20160816; b=0fghbWJeS3wRktl2Et9id5DeHPRGiulQo5iM8PSmj7Plwo0VB+Nuo/BJ9x1akq3X5+ S13UDM32FSfZIJg6RMhEQdEePVG4aTrHdiCjwD86ykprtEkqbDfyPYGVQT44iXCeFYST MWn4nSUs5QdH/aRaQ+LQjZBqHx6JcS+Wgm691wn87WA5VhA2Dl5PFtg5wNzj61PyxrFM pzVW6pruu1+YGs8jseo7roJXmrzwd2L6ckGxkN7Jfd5llIgjAzETAOdq/2d0iSdRDSDk 3dtTQgZgRZj7MXoXex1SWupfOTJCwWqX+aKWR9gXxDo7x5fXFHCr8YQ+VThLwMv8ahQN qGzg== 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=Qp8DZjdrZ2yTWZn89Dh9uWzpkTbpwEoPS2F9mTGZ3Ek=; b=Wnzd0FG1CRRLZrmVZtQbADIVY1np3KUUj4rSznSyx21g1Vg37vMBarZ/fHBPG3dENg 1gEaxOd5PxDQxlGiBGA6Wtx4qp/vio5ihNJubS6O0xirG0vhaWOyboAl63eE2aZP5k2h v93qTiFFO4u6X3yxsDJAEEiuhXznu4OxicbjBHeVNX+Y9mw3l0C003rZbc+8b8qLSHm4 xOAJShu4w2koc1hu8h06EpB/Gvg3NuEUhjpWwsIYHnD9Ot2j9SKySUNj7RP8XKtaZ1am maksLzp+ZXz0/UE2AYFrrogVbCHawnIyOlcAxU5ldLT/crw5wuCy1eg/EfCiT7SeADRe g89w== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20150623.gappssmtp.com header.s=20150623 header.b=me8B+P42; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::534 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=Qp8DZjdrZ2yTWZn89Dh9uWzpkTbpwEoPS2F9mTGZ3Ek=; b=TNlb5+HvNqFToa4PjEmXVOdz42xGU2tHVXe1kcKDx2d7b5as5GDQ5k7c+/eVkS7H54 fD84xz72f2DokjwYByh0qHed/8nOCt1JsrF4hR24yi8dksFcRus6KfBfWgKthPKwbarv rMWPL25NXh6vzPyJE9CulpRc8FrPraW4Bhz0UEWKNW3wDm1glsmoSJuAD4ErKtCxfv1u 2dB0F4Bal6BWTCbjaG/ND/pSOB/p3IRsOB969luMT809Edxbsjwsd/2706WKqPNRU3QN Bflycnh9MZSbpH0W+tX3Rz01AvWBxAKOoS+q+9AeNy+TphJGl7iRgZ/T5z9QBh8ZwXuP o6Gw== 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=Qp8DZjdrZ2yTWZn89Dh9uWzpkTbpwEoPS2F9mTGZ3Ek=; b=JJnY+mnF23h6TAQviQsT1fAMArq/4uNnRWu9pwu6aZn4RaibBGXQaai838uwfUp2xw M14eM/nC9CLNH0w8sHEx3IGmCwLnn7g+M6z32/Dbc6tqkvaeN3OZMfkxzQEtK1ugtrWb B38r+fL0cNpPEXPOspMgBV/jPUIbmy9j5RAODNHcAyrc+dF7vzydUtsOYCmLXTnVJmz1 ldIl3gkYgin2Ro1NINtpwCjFMniXO41VzX2HdeLCq0+Z1udtgPmsy8Ujj28ANA1gL5AT ASRF51d+iXXzvAktPhh/hFxmV42rvWYM4e5csjO0LqFjFW68Ll67oW9FnbUyWlCzTrpj Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: APjAAAXOvaTTTeXJDNTHygReIfs409HTLluPeWOWpzpWJC86h/x5L/MU A+hP2nBK8y+h9odJtObtDzc= X-Google-Smtp-Source: APXvYqzlHD49eL8C5GfWdrz4QnsWTdcjBoBn+yx4wRf9lSigkM+L95ZI0YxwGbOnKGMFYsfhJf2JKQ== X-Received: by 2002:ab0:7811:: with SMTP id x17mr5268343uaq.83.1567101031029; Thu, 29 Aug 2019 10:50:31 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a67:e0dc:: with SMTP id m28ls10874vsl.10.gmail; Thu, 29 Aug 2019 10:50:29 -0700 (PDT) X-Received: by 2002:a67:2083:: with SMTP id g125mr6631537vsg.45.1567101029974; Thu, 29 Aug 2019 10:50:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567101029; cv=none; d=google.com; s=arc-20160816; b=E5VocVjXZ8xHnWidLShRVUsHwnnjIT7TAMWzUU5VciYskt2LPGFQqDza/X1g2Ib46N c5+sKCd76yCc+UpOC+W4WXr5EbdjbvbQmYQoF6FRiVGW6cYVa1PA763VXT8uie6tWg9l 2UJxSHJJ+LV4A3iZNwB8aiI+MDlojQshhqzZRWGwRTw2pXXsKLe/J4c1bt90yiEkAKvK kdk79NfWueWnH9ueskVGEqygXWiQ3jU69faq+pYhzQGkoh0xD8TZx+VgDpfOXUDvVZY0 uMYI5mdiZqaDijOiucIvLuPLe/ZbzLeB4LgK7FwCaNWL7LhvmiGAKSIlyYgL3/Y0EdMd dndw== 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=1Dye0PcB7VxloODX4gba0D8AMDEtAsz8danO5eaifIA=; b=H8XG3htM6NMgbhEAvGzhF6kutazHFUUt42a/AxuRuDhICRl405anyfEOzYeV8S0fTL mTDUiNmLKHcxnpAaeyOsw5Xa6fQhWHBGav7GiDO23p2zbar7ym6KRAzF1el0Fzd7k7/4 FGpk+zbUuh01cais+wfd/jsF4wt6a38tUl6INWVhiwK9hhBNaAvfYNbGt37wsaTHiNiG ztueRAMaPeKbmg505iU4T9uzKWdXxG7u3+HW5UZ7a2M+/XYNXZuMb8evrDdqxJPH34WB GrjIytG5QtjD+UyIOk2UNHD8FoDu4PIFqVATF6WkQ79l7C8n/IfUmhnLShRF8LaV/rwO YgTg== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20150623.gappssmtp.com header.s=20150623 header.b=me8B+P42; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::534 as permitted sender) smtp.mailfrom=jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org Original-Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com. [2607:f8b0:4864:20::534]) by gmr-mx.google.com with ESMTPS id u189si146133vkb.2.2019.08.29.10.50.29 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Aug 2019 10:50:29 -0700 (PDT) Received-SPF: pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::534 as permitted sender) client-ip=2607:f8b0:4864:20::534; Original-Received: by mail-pg1-x534.google.com with SMTP id l21so1983291pgm.3 for ; Thu, 29 Aug 2019 10:50:29 -0700 (PDT) X-Received: by 2002:a62:1858:: with SMTP id 85mr13275843pfy.120.1567101029060; Thu, 29 Aug 2019 10:50:29 -0700 (PDT) Original-Received: from johnmacfarlane.net (li55-134.members.linode.com. [74.82.3.134]) by smtp.gmail.com with ESMTPSA id o67sm6453109pfb.39.2019.08.29.10.50.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 10:50:28 -0700 (PDT) Original-Received: by johnmacfarlane.net (Postfix, from userid 1000) id 9C2A2A16D; Thu, 29 Aug 2019 13:50:17 -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=me8B+P42; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:4864:20::534 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:23332 Archived-At: In Haskell you can use "\5881" but in lua this won't work. Try "\u{16F9}". 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/m2pnknamjr.fsf%40johnmacfarlane.net.