From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/28629 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.text.pandoc Subject: AW: Fenced Div to ConTeXt Environment (was: Markdown Fenced Div to LaTeX Environment) Date: Thu, 17 Jun 2021 08:51:42 +0000 Message-ID: <2570133387e64394bf205ca351294873@unibe.ch> References: <8ba84992-d792-4333-aae0-560147ef79d4n@googlegroups.com> <87pn1uwglb.fsf@zeitkraut.de> <20210616143731.GA29446@sokrates> <5db56b4f1d8d4ca2bec612bcebb7a525@unibe.ch> <493d0aa9-47f5-ca8d-2ef5-8e63f965c529@mailbox.org> <4396a9133ab74e4fbff486f09e22d254@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="17090"; mail-complaints-to="usenet@ciao.gmane.io" To: Original-X-From: pandoc-discuss+bncBCZ27W53TUFBBIE2VSDAMGQEBARADUQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Jun 17 10:51:46 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-wr1-f59.google.com ([209.85.221.59]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ltnkY-0004Dq-Qh for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 17 Jun 2021 10:51:46 +0200 Original-Received: by mail-wr1-f59.google.com with SMTP id x9-20020adfffc90000b02901178add5f60sf2626778wrs.5 for ; Thu, 17 Jun 2021 01:51:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1623919906; cv=pass; d=google.com; s=arc-20160816; b=nKX4NjQko/KgPvhmmh/CviNQn0fNcfEaCxiE/ZkSBVTHt6FoYE1fmfsNAEiYC4c+Wg xT5ZQwznkrnVUxJAkI8nIf9/iYtKqWTrkX+BUCsh5vROLXJz0BGRN87umIGcNdv83fHc JAzLY0+7zVM9LhPYJz9oDPtX7OhVeSXmGGsAlDh2aJwRjjyr/xQfDt+cQ5v4y5xd/1sn GtnKtDzXtq4+Dy+1orzfXGR4qg3JIhCJIf694J12mSvy3nSKS7uE7Qe3Sc0BEUT29QLY CKfZlq99zNW2piwa5//4/1KbcJqJEqNgzHvZVCp5xgtJ7HXLVINihUgRx32srYRV52Ng P3cA== 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=fW5UXhdbKdTrZQ8yzyyt8rC7koHgjsp2YACVia5b5LY=; b=Q7dwp2uHhF1LQFcXni7ZLevJFAK50witV+43JPXmj5VZpy7kHPeWBhjkJ7EVXbJIbZ B0qAV1ldwWBm9UKuCnXSj8bp4uhO5qpKDH7QyouigMGzk+rPyY5GWPWRI2tflsKGPolW TgFTQfSO6OWi5SL3CMaQOodhjD0DtocutzjfN46IEGsc+q1mvEOy1y++Qp1e51xpnBAG 0jLNnKlsZLlw9rSv7tLDauj+Xzy0wZG6RkjjsuCS3yH/xas09eNxugAefwJwuSiJKW5G rWuXBUZdxae9GeNkzHVzvtvJhCJsWU17HDyfk5sQuZR1KCz4F8nBWqXOUZRnqcaRwcxs mZ1Q== 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.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=20161025; 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=fW5UXhdbKdTrZQ8yzyyt8rC7koHgjsp2YACVia5b5LY=; b=K1OGZ72lvtQ9a7xBBq6BiM4IFYylTnvyp0pdxJbk+CkKtFkp1CPfeXnE7IomnZ4xJk NnzX5MRId7mYZfsxtthQV2wlkiozErnXHgknJHv93cNujt1MSwqVVuk8RtD8KkIAjCTO bzvnribuZZIp3ZMD7sUSJ50GBXN0dZ5JCwDoY2ejhokgia6dQAW0PUX+ZFMqASFcwv4Q 78QeR8NPt4MzTG69vn9P3ms22/ey5xOpcvJ9soRMrZooQnO62cKzfOFSBQ+GAD86267Y eK4ced3KothVYaR0PoBqA96daM+ziyuOjMHZb2ekilaOkhWW0g 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: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=fW5UXhdbKdTrZQ8yzyyt8rC7koHgjsp2YACVia5b5LY=; b=mb370VkTSMUV9CmwBKQPudATFfmt2ntWrudr8WfX8JP1A41qgsGfO6/it0ltFsL2qD c/Ivk0rifTe8ZloCZPd9Slc8tId511Ck9Ga1FbfVHoIMTkLPW6HZnvhajy4aT3XuLZUc LtfMOTIjxKvMV2WiGGBw+V3cy21YGRsN5QigS2FTA5Ty3a4YUzPIXcO3Cq6Bvd+pCTUs yzTTzOjy+1F/UY6vvK/cmrSP6wsAQhPWV583vW8jw6JF8vAbAR9PZHB7PO5seFyNtn15 j1DsC Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM533NR0pkTQbK1pkm3+FDHuGK0POiGo46L4rZM0TxkAw0Cx8BCyls 6bR07qxx/XL7LZ5pt8XCbf4= X-Google-Smtp-Source: ABdhPJx69Sha2QXPN3og2LjEARKms4VP2WI7vaVN2NtqKiI2f/Vh9UJ9ZMD/VJx+pf+cyVU84OdDRA== X-Received: by 2002:a5d:6a41:: with SMTP id t1mr4384984wrw.113.1623919906492; Thu, 17 Jun 2021 01:51:46 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:adf:fe4c:: with SMTP id m12ls569017wrs.0.gmail; Thu, 17 Jun 2021 01:51:44 -0700 (PDT) X-Received: by 2002:a5d:6e0d:: with SMTP id h13mr4420030wrz.118.1623919904201; Thu, 17 Jun 2021 01:51:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623919904; cv=none; d=google.com; s=arc-20160816; b=TTarljMZls/lOOTocYtEj9DSaxtpPutT2EGpaZg38cs3hT4Zy9SQVksiI13ReObJjg ZWWC6/sQbliwqG31OiP1/M+sLCKNP5MncdhED7a63kQtUkuWQDjTp2YGS53x2Ly+WgQz ZyPWwI64VnbvutJ/jXB0aMiKC6SYdiqDgJtd2FvXeVrC1MM8o9p1axoxrMKpWo3zDDjH iwOJinRFOWAKw35vAGvTD4PewsWQrkUR4joxE4EKk1wN7DBvgR3eyr9i0fUp7By5kRMz 2tTq9YT1Qrd2qd4S3p6DgHjBUvC/0QDYHScAheVYZ4653pvG1LYTDtUjav/CJ4n3PkEY JudQ== 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=Z470Qsy/CjC6ILdwuLBpyNJBo++JstBT0veN7Pj9gYY=; b=haXSutH6XcQky9XRVSPtdCGequ8idKg9Zs5lr01h7x2fq/0K79IlKvrPQVBJLnY3Ov z+OF7z3wQvwss6znjG1AKb5enL+hVgi5RefSfuVc6L+2L4Iwx/7+yj82W12Npp09tBZZ QtLbegbAe/D6Xli8oi7ATpVmlvd7GymtkhBZaTbSRdBRZGtGo7PD/fUbwX7kjgXH5sCt 54kia/tsrXbLyFFB+0EqDsHfcD7EjVXNHg7hNBeW0mJhYiLQyQ0nWEFsY4iX58aMmWi6 bQx6HTShVxjCwHjT7tQ8PwwvygNcwhS9UuE78nO5m30bibxqgnryyn/ss921Oba675TA H9xQ== 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.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 z70si341204wmc.0.2021.06.17.01.51.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 01:51:44 -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 D70035000C4 for ; Thu, 17 Jun 2021 10:51:42 +0200 (CEST) Thread-Topic: Fenced Div to ConTeXt Environment (was: Markdown Fenced Div to LaTeX Environment) Thread-Index: AQHXYr0sGMc1dR8TLUq6O7E+1ZxI1asWyMKAgABF4oCAAI3pAIAAB8kAgAAQ/QCAACHcMP//6X2AgAAkVEA= In-Reply-To: Accept-Language: de-CH, en-US Content-Language: de-DE x-originating-ip: [172.18.72.2] 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.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:28629 Archived-At: Thanks, that looks nice! > -----Urspr=C3=BCngliche Nachricht----- > Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von Bastien DUMONT > Gesendet: Donnerstag, 17. Juni 2021 10:36 > An: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > Betreff: Re: Fenced Div to ConTeXt Environment (was: Markdown Fenced Div > to LaTeX Environment) >=20 > One possible solution: >=20 > ```lua > ENV_CLASSES =3D { 'intro', 'question', 'solution' } >=20 > local function context(s) > return pandoc.RawBlock('context', s) > end >=20 > local function get_env_class(elem) > if elem.classes then > for i =3D 1, #elem.classes do > for j =3D 1, #ENV_CLASSES do > if elem.classes[i] =3D=3D ENV_CLASSES[j] then return ENV_CLASSES[j]= end > end > end > else > error('function has_class used on an element of type ' .. > elem.t .. ' that cannot have classes.') end end >=20 > function Div(el) > local env_class =3D get_env_class(el) -- nil if there is none > if env_class then -- false if env_class is nil > return { context('\\start'.. env_class), el, context('\\stop'.. env_c= lass) } > end > end > ``` >=20 > Notice that the intro, question or solution class need not be the first o= ne, so > that this would be recognized: >=20 > ::: {.my-class .intro} >=20 > blabla >=20 > ::: >=20 Just to note this that in this case=20 ::: {.my-class .intro. solution} blabla ::: the filter will pick up the first class it knows about, while silently igno= ring the rest. Denis > Le Thursday 17 June 2021 =C3=A0 08:12:06AM, denis.maier-NSENcxR/0n0@public.gmane.org a =C3=A9= crit : > > Yep, this is also what I was getting. > > > > But this minimal shows how to make it work: > > > > ```lua -- works > > function Div(el) > > return {pandoc.RawBlock('context', "\\start"), el, > > pandoc.RawBlock('context', "\\stop")} end ``` > > > > vs. > > > > ```lua -- does not work! > > function Div(el) > > return {pandoc.RawBlock('context', "\\start"), el.content, > > pandoc.RawBlock('context', "\\stop")} end ``` > > > > So, this here works: > > > > ```lua > > function context(s) > > return pandoc.RawBlock('context', s) end > > > > function Div(el) > > if el.classes[1] =3D=3D 'intro' then > > return { context('\\startintro'), el, context('\\stopintro') } > > end > > end > > ``` > > > > Maybe this should be a bit more generic though? > > > > ``` > > function context(s) > > return pandoc.RawBlock('context', s) end > > > > function Div(el) > > if el.classes[1] =3D=3D 'intro' or 'question' or 'solution' then > > return { context('\\start'..el.classes[1]), el, > context('\\stop'..el.classes[1]) } > > end > > end > > ``` > > > > As my lua skills are far below mediocre I bet there ways to make this n= icer, > e.g. by putting the relevant classes into a table and referring to that. = And you > may also want to pass arguments from your divs to the context \start...\s= top > construct. Think of this: > > > > \startquestion[difficulty=3Deasy] > > > > How to build pandoc filters using lua? > > > > \stopquestion? > > > > Denis > > > > > -----Urspr=C3=BCngliche Nachricht----- > > > Von: 'juh' via pandoc-discuss > > > Gesendet: Donnerstag, 17. Juni 2021 09:56 > > > An: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > > > Betreff: Re: Fenced Div to ConTeXt Environment (was: Markdown Fenced > > > Div to LaTeX Environment) > > > > > > > > > Am 17.06.21 um 08:54 schrieb BPJ: > > > > --filter/-F is for JSON filters. Lua filters need --lua-filter/-L > > > > > > Thanks a lot! Now the error message is much more informative. > > > > > > This is my filter: > > > > > > function context(s) > > > return pandoc.RawBlock('context', s) end > > > > > > function Div(el) > > > if el.classes[1] =3D=3D 'intro' then > > > return { context('\\startparagraph{intro}'), el.content, > > > context('\\stopparagraph') } > > > end > > > end > > > > > > > > > This is the error message > > > > > > Error running filter filter.lua: > > > Could not read list: Could not get Block value: untagged value > > > > > > Any hints? > > > juh > > > > > > -- > > > 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/msgid/pandoc-discuss/dc8ef20b-4a8b- > c385- > > > 704c-28c85a5b6820%40mailbox.org. > > > > -- > > 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/msgid/pandoc- > discuss/4396a9133ab74e4fbff486f09e22d254%40unibe.ch. >=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/msgid/pandoc- > discuss/YMsJgXv77qqiw7au%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/2570133387e64394bf205ca351294873%40unibe.ch.