From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/31453 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.text.pandoc Subject: AW: Fw: Fixing lua filter to number paragraphs Date: Sat, 24 Sep 2022 06:04:54 +0000 Message-ID: <9c110d41d7b24b39b98b999c78d6210b@unibe.ch> References: <78BBgUlgdEJOaNOIxhfkTKPgf07yZREVfvlbeq1kqYQ59CCPSpaXEX4T_806rUzuPjbb5aIvpmynEu04PsBHsJTnWtkNNiG5dZQYfDGsO0Y=@proton.me> , 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: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="391"; mail-complaints-to="usenet@ciao.gmane.io" To: Original-X-From: pandoc-discuss+bncBCZ27W53TUFBBCN4XKMQMGQEHRP4KDA-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sat Sep 24 08:05:02 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-lj1-f190.google.com ([209.85.208.190]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1obyHe-000AS6-D0 for gtp-pandoc-discuss@m.gmane-mx.org; Sat, 24 Sep 2022 08:05:02 +0200 Original-Received: by mail-lj1-f190.google.com with SMTP id bn39-20020a05651c17a700b0026309143eeesf484067ljb.4 for ; Fri, 23 Sep 2022 23:05:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1663999501; cv=pass; d=google.com; s=arc-20160816; b=0BvFWybbYIVrZ+0MIFuDYt1q+lwXxkLBPF7e0PvU/hxQwXEJCn2q04IjiFvTGeiGdH /IP1nSZpw6z0nOAhZQ08as2VWdQAOWG2v8HT+GkCBo5XFh2Brwi7t9Htuviz6V1sqPMk haQzbbl+c/bQt0xvFcbmgvst13AIvc8HFlJ2RweBUVpoNEOTeM9OBlj16ppGSbz3d2uy OicsOZbkvACetnIo0dvaguCcRuwBD/bxJjqtVsCMKtHW+lIIoSP/lwmbd0bTi6dorbhO 2N4GyXYTa+VIfL9AHJL1Dm7vH60jL7R/BZLosuhfqfaQ9H21rOt14GBP+iuN3sB5ldgk EQDA== 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:mime-version :content-transfer-encoding:content-language:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:to:from:sender:dkim-signature; bh=S1P43VbSjbYRWbxn8yvVTLs8PiXJD2ddMwkwOkcX/yc=; b=nmZlyOPfwvfB/1pjj1jr0FRwHyFt6bsz7Gr+y117/B8CodW/YcY6ik8NZWZQI5VAz9 DL+dfADgktJQfkEvPeREzj8AitSsP2ZbNop4hY2rPRc3YX+U56m6erlQzfb8JPGxxJva heHzBQPJwRWKdp04+DXgrAaf5gUzaJcrNge2d9RzTyXLHTLwjMgj2D/suBsFpmRrONr4 +HYeQhWSsAVMTTKyOINaugIrGgGgPSDMG0aFJac1GU6+Sk3wRqXHJP12dEMFItYyUc0s dvQe3tLQhp8da3k4LyBxq/DoJsHhkLjGn/YHU1U1vxHdkndUi5575y63kbsWu3BCYo85 1/8A== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@unibe.ch header.s=mgwsel1 header.b=OwXi8o9X; spf=pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.83 as permitted sender) smtp.mailfrom=denis.maier-NSENcxR/0n0@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=unibe.ch DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:mime-version :content-transfer-encoding:content-language:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:to:from:sender:from:to:cc:subject:date; bh=S1P43VbSjbYRWbxn8yvVTLs8PiXJD2ddMwkwOkcX/yc=; b=PcrOFlQkJsKROPm3U7i3ZMlsKc+nQDJ0WLimZa+5WCyjWdPh3iZeuQvi9VeS1804Cu REWcbLbArxFnlGZOyxVLOw4D973IBdDI8rHfcaZH8ENl182CdHPoeFOvWccPyO/U1TtA 5dvhli/S2mOnp9WB+uSdDReTXRmZt/8sfRM4YChMph06xVOW6wTd9B5f9sNcO54ls3Ch p0Iov6I9rcy86Y1TlqZEKm8anojlh02gB4T8ReCbwLCGXJBrNDK7XcWHJ36c/y/tzWQn gHjnxg83QudUfvvM61ZqONYM0l X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:mime-version :content-transfer-encoding:content-language:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:to:from:x-gm-message-state:sender:from:to:cc:subject:date; bh=S1P43VbSjbYRWbxn8yvVTLs8PiXJD2ddMwkwOkcX/yc=; b=pnOqByRR6CnBSZsCyngJ3N/Bn01HA8yImRFvUzImmgk0rL3nNGIEdsLGHyUOM1iJdI P6DUB3vGmURSi0p4XP7XtACDnHF78JoukJ8IumpxwKp74BsmZT7aLytjUgDHqFw7zaq0 DVPz3rgV8dg2VuLcAEcMI25xIohgtWmV9nG8Tps0cLYCcaUOwnsVfETForDegvg0awqr oBPfi/i7f6Inoqq2JF5i/t1gvxaaCTatTl29st3cgdPP8LZUs/1MjUaJh0l Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: ACrzQf22SLuAigJAiCEmcvN+bKUV1SpCsVe7FzCrUp9PsP3QcqH8Qrgk nkC/R8R29hU1eizHCe8vSg8= X-Google-Smtp-Source: AMsMyM6EEh6IwFdXzR/nlRFKoFsqDmTr0NT9RJqyeIu8gyPa6TlQ3w+nQLEbeQKQQl/eEYkZhV49NA== X-Received: by 2002:a05:6512:1283:b0:499:d0a3:3ca8 with SMTP id u3-20020a056512128300b00499d0a33ca8mr4480280lfs.665.1663999501744; Fri, 23 Sep 2022 23:05:01 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:ac2:5e7b:0:b0:48b:2227:7787 with SMTP id a27-20020ac25e7b000000b0048b22277787ls1326504lfr.3.-pod-prod-gmail; Fri, 23 Sep 2022 23:04:56 -0700 (PDT) X-Received: by 2002:a05:6512:3187:b0:49e:6607:3a75 with SMTP id i7-20020a056512318700b0049e66073a75mr4429999lfe.28.1663999496695; Fri, 23 Sep 2022 23:04:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663999496; cv=none; d=google.com; s=arc-20160816; b=ErQxxmd+MSVbpulTdnTWz6L5nCTHXLF7VAfxp4K1UGLSBqcggVi34b4jKI+JyKNINK 5zJBZKXawCJp5ySvXz20WHkLofI8waiQtyc9cEP1lEbPSm8T9A5UYfdgOejNC6CnNaiE MD9Ws08eB1UGC0N0f58g9+P+5poBDhjKYJW0svB/PljvTA2U6E3a4Hg/ylhU5CJIS3LZ JAmFvf8xTYgYiDBaeeQhcndO4wLlXZFwXZPy2HGvMnRYom3yjDJxVCsL6TpIlv1HNcEy y3y8RHYnUlKm6Beh2UtTqqGHDdhnj9fmPj36I6BqRcSqI4DusfzDsmDgH1uySnUqGIj7 vZ+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-transfer-encoding:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:to:from:dkim-signature; bh=Kxp1CHLd8QAof1gBFBUyYpQbAgzT1ZZTmH1XVg0l2U4=; b=vLp/j/1i47Y6uVGtpyezbiGr69Y/DrFGfMZwN6U/rAdY10cwPFzllyHCRMtzcNMreZ J8ByPxnZ49jbwxsdIRlqAC8CvcXjdffoX/t6maPmuPMhRIK2PDZtvgMX5hkwH+OgEfLO idAyEUtVCXgbRq4icP0ajEZ8DtaXBDqjq/MErlTxg4ezxYbOtWPShjOQ9SrSFuQicJnA sqRHqVEm01YI9zwRsgk8iiS81pEqFqoENW+hPzvs1xfRN28cFZ8uvCLZebHlPY+BBcsQ FPkunakpYNEyxJMqrMa2775ULt08vVGiYMgnXHpgiKjLFMoHj65ndCQATv/ZVEVZn19W QM9g== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@unibe.ch header.s=mgwsel1 header.b=OwXi8o9X; spf=pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.83 as permitted sender) smtp.mailfrom=denis.maier-NSENcxR/0n0@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=unibe.ch Original-Received: from mailhub-lb2.unibe.ch (mailhub-lb2.unibe.ch. [130.92.0.83]) by gmr-mx.google.com with ESMTPS id bd3-20020a05651c168300b0026bfbc4be3csi337720ljb.7.2022.09.23.23.04.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Sep 2022 23:04:56 -0700 (PDT) Received-SPF: pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.83 as permitted sender) client-ip=130.92.0.83; X-Virus-Scanned: By University of Bern - MGW Original-Received: from mail.campus.unibe.ch (aai-edge-02.campus.unibe.ch [130.92.13.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailhub-lb2.unibe.ch (Postfix) with ESMTPS id EC3CB50007F for ; Sat, 24 Sep 2022 08:04:54 +0200 (CEST) Original-Received: from aai-mail-01.campus.unibe.ch (130.92.13.40) by AAI-EDGE-02.campus.unibe.ch (130.92.13.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P256) id 15.1.2507.12; Sat, 24 Sep 2022 08:04:53 +0200 Original-Received: from aai-mail-03.campus.unibe.ch (130.92.13.41) by aai-mail-01.campus.unibe.ch (130.92.13.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P256) id 15.1.2507.12; Sat, 24 Sep 2022 08:04:54 +0200 Original-Received: from aai-mail-03.campus.unibe.ch ([172.18.73.17]) by aai-mail-03.campus.unibe.ch ([172.18.73.17]) with mapi id 15.01.2507.012; Sat, 24 Sep 2022 08:04:54 +0200 Thread-Topic: Fw: Fixing lua filter to number paragraphs Thread-Index: AQHYz6GZVeS3GTCMJ0uCVIl1T0QxAa3t7yQAgAAoX3g= In-Reply-To: Accept-Language: de-CH, en-US Content-Language: de-CH x-originating-ip: [130.92.13.161] X-Original-Sender: denis.maier-NSENcxR/0n0@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@unibe.ch header.s=mgwsel1 header.b=OwXi8o9X; spf=pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.83 as permitted sender) smtp.mailfrom=denis.maier-NSENcxR/0n0@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=unibe.ch 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.io gmane.text.pandoc:31453 Archived-At: Or maybe the xcolor package. ________________________________________ Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org im A= uftrag von Bastien DUMONT Gesendet: Samstag, 24. September 2022 07:39:08 An: 'Mark Johnno' via pandoc-discuss Betreff: Re: Fw: Fixing lua filter to number paragraphs The error means that the command \color is not defined, i.e. the package th= at defines it is not loaded. It should be fixed by adding this after addTex= Preamble("\\reversemarginpar"): addTexPreamble("\\usepackage{\\color}") Le Friday 23 September 2022 =C3=A0 11:09:42PM, 'Mark Johnno' via pandoc-dis= cuss a =C3=A9crit : > Hi, I have been using a lua filter for a few months with no issue, howeve= r, for the last few days, I've not been able to produce a PDF. I can't find= hints online. I am hoping someone can help me. > > That is the error message I get: > > ! Undefined control sequence. > ... \hspace {\z@ }\ignorespaces \color > > {lightgray}\tiny {[1]}\end... > l.72 \paragraphnumber{[1]} > > I had some error messages in the past, usually due to missing squared bra= ckets which I resolved by using --trace to check where parsing was slowing = down (that is where the brackets were missing), but this time --trace does = not provide any hints. > > I can convert the document from .md to .pdf (without the filter); that is= the command I use: > > $ pandoc file.md --pdf-engine=3Dxelatex -o file.pdf > > ...but when I add count-para.lua filter: > > $ pandoc file.md --pdf-engine=3Dxelatex --lua-filter=3Dcount-para.lua -o = file.pdf > > I get the error message mentioned above. > > I also tried with another document. I get the same error message. > > I tried contacting the author of the filter, in vain. > > Do you have a hint about how I could troubleshoot or fix this issue? > > Does the filter need to be updated? > > $ pandoc -v > pandoc 2.5 > Compiled with pandoc-types 1.17.5.4, texmath 0.11.2.2, skylighting 0.7.7 > > I use Trisquel GNU/Linux 10.0.1. > > This is the filter: > > --[[ > Make all 'regular' paragraphs into a div and assign a numeric ID > Format this number in the margin > Copyright =C2=A9 2021 Michael Cysouw > Permission to use, copy, modify, and/or distribute this software for any > purpose with or without fee is hereby granted, provided that the above > copyright notice and this permission notice appear in all copies. > THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES > WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF > MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR > ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES > WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN > ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF > OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. > ]] > > local count =3D 0 > local chapter =3D 0 > local indexUserID =3D {} > > ------------------------------ > -- Options with default values > ------------------------------ > > local resetAtChapter =3D false > local enclosing =3D "[]" > local chapterSep =3D "." > local refName =3D "paragraph " > local addPageNr =3D true > > function getUserSettings (meta) > > if meta.resetAtChapter ~=3D nil then > resetAtChapter =3D meta.resetAtChapter > end > > if meta.enclosing ~=3D nil then > enclosing =3D pandoc.utils.stringify(meta.enclosing) > end > > if meta.chapterSep ~=3D nil then > chapterSep =3D pandoc.utils.stringify(meta.chapterSep) > end > > if meta.refName ~=3D nil then > refName =3D pandoc.utils.stringify(meta.refName) > if FORMAT:match "latex" then > if refName =3D=3D "#" then refName =3D "\\#" end > end > end > > if meta.addPageNr ~=3D nil then > addPageNr =3D meta.addPageNr > end > > end > > ------------------------ > -- Add global formatting > ------------------------ > > function addFormatting (meta) > > local tmp =3D pandoc.MetaList{meta['header-includes']} > if meta['header-includes'] ~=3D nil then > tmp =3D meta['header-includes'] > end > > if FORMAT:match "html" then > local css =3D [[ > > > ]] > tmp[#tmp+1] =3D pandoc.MetaBlocks(pandoc.RawBlock("html", css)) > end > > function addTexPreamble (tex) > tmp[#tmp+1] =3D pandoc.MetaBlocks(pandoc.RawBlock("tex", tex)) > end > > if FORMAT:match "latex" then > addTexPreamble("\\usepackage{marginnote}") > addTexPreamble("\\reversemarginpar") > addTexPreamble("\\newcommand{\\paragraphnumber}[1]{\\marginnote{\\col= or{lightgray}\\tiny{#1}}[0pt]}") > end > > meta['header-includes'] =3D tmp > return(meta) > end > > ------------------------- > -- count Para and add Div > ------------------------- > > function countPara (doc) > > for i=3D1,#doc.blocks do > > -- optionally reset counter > if doc.blocks[i].tag =3D=3D "Header" > and doc.blocks[i].level =3D=3D 1 > and doc.blocks[i].classes[1] ~=3D "unnumbered" > and resetAtChapter > then > chapter =3D chapter + 1 > count =3D 0 > end > > -- get Para, but not if there is an Image inside > if doc.blocks[i].tag =3D=3D "Para" > and doc.blocks[i].content[1].tag ~=3D "Image" > then > > -- count paragraphs > count =3D count + 1 > local ID =3D count > if resetAtChapter then > ID =3D chapter..chapterSep..count > end > > -- format number to insert > local number =3D ID > if enclosing:len() =3D=3D 1 then > number =3D enclosing..ID..enclosing > else > number =3D enclosing:sub(1,1)..ID..enclosing:sub(2,2) > end > > -- check for user-inserted ids at the start of the paragraph > local firstElem =3D pandoc.utils.stringify(doc.blocks[i].content[1]= ) > local userID =3D firstElem:match("{#(.*)}") > if userID ~=3D nil then > -- add to index > indexUserID[userID] =3D ID > -- remove reference from text > table.remove(doc.blocks[i].content, 1) > -- remove possible space > if doc.blocks[i].content[1].tag =3D=3D "Space" then > table.remove(doc.blocks[i].content, 1) > end > end > > -- insert number > if FORMAT:match "latex" then > -- use marginnote for formatting number in margin > local texCount =3D "\\paragraphnumber{"..number.."}" > if userID ~=3D nil then > -- add target for link to the number > texCount =3D "\\hypertarget{"..userID.."}{\n"..texCount.."\\lab= el{"..userID.."}}" > end > table.insert(doc.blocks[i].content, 1, pandoc.RawInline("tex", te= xCount)) > else > table.insert(doc.blocks[i].content, 1, pandoc.Space()) > table.insert(doc.blocks[i].content, 1, pandoc.Span(number, pandoc= .Attr(ID, {"paragraph-number"}))) > end > > end > end > return doc > end > > ------------------------------ > -- set in-text cross-references > ------------------------------ > > function setCrossRefs (cite) > > local userID =3D cite.citations[1].id > local paraID =3D indexUserID[userID] > > -- ignore other "cite" elements > if paraID ~=3D nil then > > -- make in-document cross-references > if FORMAT:match "latex" then > > local texInsert =3D refName.."\\hyperlink{"..userID.."}{"..paraID..= "}" > if addPageNr then > texInsert =3D texInsert.." on page~\\pageref{"..userID.."}" > end > return pandoc.RawInline("tex", texInsert) > > else > return pandoc.Link(refName..paraID, "#"..paraID) > end > > end > end > > -------------------- > -- basic Pandoc loop > -------------------- > > return { > { Meta =3D addFormatting }, > { Meta =3D getUserSettings }, > { Pandoc =3D countPara }, > { Cite =3D setCrossRefs } > } > > -- > 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/e2suTdCtcLJ3u0PBmkSX9YRRukwnvuWJPhOFU1iL8lR84w_f8f9j1UrjpH= EW_3oHRO5aC_mDpkazLs5dfMXA1EKkXvf4eZs3_tgIXsFq1uU%3D%40proton.me. -- 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/Yy6X/FXIPVN1zij3%40localhost. --=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/9c110d41d7b24b39b98b999c78d6210b%40unibe.ch.