From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/29670 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.text.pandoc Subject: AW: Pandoc Document Model in Python Date: Sat, 4 Dec 2021 14:58:26 +0000 Message-ID: References: <3b5d75fe4e2a45e38ab45a820d110faf@unibe.ch>, 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="4805"; mail-complaints-to="usenet@ciao.gmane.io" To: Original-X-From: pandoc-discuss+bncBCZ27W53TUFBBFEEV2GQMGQELXJLA7Q-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sat Dec 04 15:58:32 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-ed1-f59.google.com ([209.85.208.59]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mtWUh-00014M-IE for gtp-pandoc-discuss@m.gmane-mx.org; Sat, 04 Dec 2021 15:58:31 +0100 Original-Received: by mail-ed1-f59.google.com with SMTP id eg20-20020a056402289400b003eb56fcf6easf4860476edb.20 for ; Sat, 04 Dec 2021 06:58:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1638629910; cv=pass; d=google.com; s=arc-20160816; b=oqjiAJqxuB3ORAq/5R69QnW2O1CNTSDiAy40lDawhnaulmLDJpS+wIzq1sB60n6VgL Pv7t8RQ0SEpGCiSn859tBXGSn8H2632lbQFRtQ4L3dMJ9frOUPkSd3hwyHboC3upU9C7 9nGM1br0wFyNl5zgtU+H4qE/PkEnraC+0udI00aKEBfwQbtQwztsYT1TeiMd97N6oX5r brPpuklJg8l4prF9m2JU6/fQnXdzITjsiyiz/2FkMsMo6sf/aZQ8G2+Bfbo9gwfilBdm PPYfknjXrHKcaCOiHliIyZNNRLZzz6MzzoXa1524atCrTEITy0Fuyh7HICAx3iup8K+4 pDgw== 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=vjV0Rdr4GXcOFBNPEBwdEQPbRo4M/Uq//HCwRVd4Xkg=; b=hRdHxdWVkIIVFS7pyPGWsHKhhqqUXGpHLsvwIFoNuASPYJJFaiVH974OwVs4/4mLN3 C/GLn/WGKLrmDaaQ0VQJn6i44JvoLDd9ISsrKNTICWvhO39x0dZNGXGxsCi6YpCdGGr+ h8z2T4Z1VG+wEJWGtlCvQThVPRuLmQToJsTfP6D47LhI9Wrl1nXc+1s9zZQ+5NalZpfb q11bO9QJSIH3Qtjk/CdCX9RccUaeRS4GMrsk09xxSlT3whNTX3F20r9kdft5aMe3cv+D nYJhdqHuHP2VDlcPz6/SuXzOK09xsn8ldKYNDuJfRvFQD+d/Ha3xBpYOwUf2N91lvbyk Qt4Q== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.82 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=sender:from:to:subject:thread-topic:thread-index:date:message-id :references:in-reply-to:accept-language:content-language :content-transfer-encoding:mime-version: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=vjV0Rdr4GXcOFBNPEBwdEQPbRo4M/Uq//HCwRVd4Xkg=; b=EXezDAjSyy1bDBzx+adFHipQ10n1Y2/F6vxYDPrV+R0IAgrBMbeTw22kUTV3HRJBoj hkcqCwG+SWaJ9FdchKPUwNxTNBU5kRiT6nhah5luCym9VawQj+GbBbWriw/R5raeZgpZ bhN8P7McJYc9uCwatxpD3ZqtHiDw4V7lqxBwYo+/xsWlrxAcQRTYj2IApQ1NpvsIXb8Y gjGEChrgm2juUKrXosJTeXszgDQeJfY58gCX5Md/Vvz0IY7tmkFtyZckXOZ/ct4gI3ml ubOH7v94702j+8aljeyjMYSG5UHl3AdimAM5fscPOYPXmbQ56B X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:subject:thread-topic:thread-index :date:message-id:references:in-reply-to:accept-language :content-language:content-transfer-encoding:mime-version :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=vjV0Rdr4GXcOFBNPEBwdEQPbRo4M/Uq//HCwRVd4Xkg=; b=VK/6DkZqXa6tWmVjIyZ+V4jcXynOwnmCUGHQ39PoQth5tWxS/RnZqVgHxms4meZPod qzHjSsPGXbVXO1zJDMV0W6YQcPMnK0nyVpNrGxYb+euVlkE/fw87D2NJKDFbOI70r7B+ rWh3W7m57+evEz69LZ3sTNxm4A3XQx8k7TsI35Gazc5hLznihaB4KFC6rDZ0YW86mYbn cdPzeDnnmpn8+6wRQqz9IdZon1GNEXRK2TO2zB6ZiQ9DXJeLB5kohJXnbHo3xazawKZx C3ErM Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM533opSf2JlPsqtmQU6naWf2xwmRZikqircwU8RCAWb2LgISDu8Kc Ib9gb9E/9KPH9CwGKwYVTig= X-Google-Smtp-Source: ABdhPJxlr02eKaDC961StKz6k0dh78EpZiP1CAIeG5GqqtL3ASXGzot+RJxf4hdINNZWooVwu42r2Q== X-Received: by 2002:a17:906:2f97:: with SMTP id w23mr32018604eji.31.1638629910653; Sat, 04 Dec 2021 06:58:30 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:aa7:c517:: with SMTP id o23ls2146641edq.2.gmail; Sat, 04 Dec 2021 06:58:28 -0800 (PST) X-Received: by 2002:a05:6402:440f:: with SMTP id y15mr36884593eda.22.1638629908021; Sat, 04 Dec 2021 06:58:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638629908; cv=none; d=google.com; s=arc-20160816; b=ZDygd3eeppHt4IGLdrqj+7AanRVgAe6HFEYv1FZ406oYhllGIRU9+IfaCl8zswzr45 hlonJuiAYtxUEl6XvIyNDV5noiJnLzLDrU+jotC9wNmscnvXSUVKR+5VSzRV7NMyCrBu 1PtLWvJzAniCevPXSuRhn3YF4NzYa7+K73fEkcGgaiyuWmfkxXzgswkg9O3wQvk+Q6x4 tENDgDhIpl3w0WxJSZ5pRUPo4yjsNJzVWn1K82GAIWAXl2cvW9wilR9lZXLJBH6qiyWt RmYlXR9TSvaA9AJXqhanKyDkUdRO7KRpeuOuhm5QuiMzx+WMENfmBoLWHi3p2oRYo7uw i1Ig== 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; bh=bpWs5tJZ02iKQxW5gBj+GbJC1qEld2fU/kSkTM3Mpjc=; b=qluQ0QpD0lU2qwHYbcoXFHUF0cVBL4d7LkJsJVjia8l4cd8QWxG8CBJsi5Tqab8c2l h7I6B53M14oH3iD/1YRwiENSf3YASfMcDbCOK7XyC5c+I6XuYuYTgKyOZxX4jDum/RdZ 0npAVkGRA2CyB1CD1yMhCziQHZ2TR7IvzN9M05IX0ZGL5ljo0sMJVzKfg3pk/gdGJDSK GY3BZa590jwKEx9p+RuBohvrfuE+3sK1aHhbMS56JCmgGNdna7UtbN58iYpoqMYyEP4p h6XthaHg0ys4LuGcafTb5Moco5M2y3lK62C5KFBnJIR9Dn84+21Op53zecS/5dXqNBn/ iMaA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.82 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-lb1.unibe.ch (mailhub-lb1.unibe.ch. [130.92.0.82]) by gmr-mx.google.com with ESMTPS id fl21si502653ejc.0.2021.12.04.06.58.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Dec 2021 06:58:28 -0800 (PST) Received-SPF: pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.82 as permitted sender) client-ip=130.92.0.82; X-Virus-Scanned: By University of Bern - MGW Original-Received: from mail.campus.unibe.ch (aai-edge-03.campus.unibe.ch [130.92.13.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailhub-lb1.unibe.ch (Postfix) with ESMTPS id B1735500076 for ; Sat, 4 Dec 2021 15:58:26 +0100 (CET) Thread-Topic: Pandoc Document Model in Python Thread-Index: AQHX6RGokE17J35tB0eLtRDrIrd1JqwiXcS8///5/wCAABOrKA== 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; spf=pass (google.com: domain of denis.maier-NSENcxR/0n0@public.gmane.org designates 130.92.0.82 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:29670 Archived-At: Thanks S=C3=A9bastian. So, if I understand correctly, you'll use that in in a script that reads yo= ur markdowns file and outputs another. Correct? (I just mean, usually your = doc will be in your filesystem, not in a python variable.) Best Denis ________________________________________ Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org im A= uftrag von S=C3=A9bastien Boisg=C3=A9rault Gesendet: Samstag, 4. Dezember 2021 15:43:42 An: pandoc-discuss Betreff: Re: Pandoc Document Model in Python (Ooops probably answered Denis only and not the group. Here we go again!) AFAICT filters are document AST to AST transformations. In this Python libr= ary, docs (Pandoc instances) represent this AST, so a typical AST (in-place= ) transform would be: import pandoc from pandoc.types import * def uppercase(doc): for elt in pandoc.iter(doc): if isinstance(elt, Str): elt[0] =3D elt[0].upper() # elt: Str(Text) If you need to make a markdown to markdown transformation instead, you read= the input markdown, transform it then write it back: >>> markdown =3D "Hello world!" >>> doc =3D pandoc.read(markdown) >>> uppercase(doc) >>> markdown =3D pandoc.write(doc) >>> print(markdown) HELLO WORLD! There are more examples here: https://boisgera.github.io/pandoc/examples/ and a documentation of common patterns here: https://boisgera.github.io/pandoc/cookbook/ Cheers, S=C3=A9bastien Le samedi 4 d=C3=A9cembre 2021 =C3=A0 15:06:10 UTC+1, denis...-NSENcxR/0n0@public.gmane.org a = =C3=A9crit : Hi Sebastian Looks interesting. But I don't undertake how you'd use that as an alternati= ve to a filter. Can you give an example? Denis ________________________________________ Von: pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org im Auftrag v= on S=C3=A9bastien Boisg=C3=A9rault Gesendet: Samstag, 4. Dezember 2021 14:20:03 An: pandoc-discuss Betreff: Pandoc Document Model in Python Hi everyone, I have just released the 2.0 version of a pandoc python library which expos= es the Pandoc document model to Python : https://github.com/boisgera/pandoc#-overview The main goal is to enable all kinds of analysis, generation and transforma= tion of documents with Python (roughly speaking, an alternative to pandoc f= ilters); it is not to convert from one format to another (it can do it, but= so can the standard pandoc command-line tool). Feedback welcome ! Cheers, S=C3=A9bastien -- 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org. To view this discussion on the web visit https://groups.google.com/d/msgid/= pandoc-discuss/f224cd2c-7d68-40b4-a855-7d4d0d7aa442n%40googlegroups.com. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org. To view this discussion on the web visit https://groups.google.com/d/msgid/= pandoc-discuss/de1fd005-0d0d-49a2-86cc-5a72c764835dn%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/fafa9cffd5e4437c865e71875b2f58a2%40unibe.ch.