From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/31690 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Albert Krewinkel Newsgroups: gmane.text.pandoc Subject: Re: Transform a fenced div to mkdocs markdown admonition format Date: Sat, 05 Nov 2022 09:03:20 +0100 Message-ID: <87a6556cg2.fsf@zeitkraut.de> References: <7AF275BD-12EB-4424-84E5-1A45FF675520@gmail.com> <87h6zf698z.fsf@zeitkraut.de> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13474"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCZJF7XJTILRBAVZTCNQMGQE4W6QZTY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sat Nov 05 09:19:19 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-lj1-f192.google.com ([209.85.208.192]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1orEOd-0003ND-FG for gtp-pandoc-discuss@m.gmane-mx.org; Sat, 05 Nov 2022 09:19:19 +0100 Original-Received: by mail-lj1-f192.google.com with SMTP id t8-20020a2e9548000000b0027702e8a5b2sf2350339ljh.20 for ; Sat, 05 Nov 2022 01:19:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667636359; cv=pass; d=google.com; s=arc-20160816; b=TFyZM4i8YpprYw4DW0bsh0v74E1gLuWxmZEv/AWNUpvCtEPKnER+iXIAl1xyG7ZdTS tiUsXy3WLATduZXlU12K1K9Qt4IDpBCVKVvxkoYqq0fvxAEWl0B9LDfl/YMAWW1OVGy1 x8RaftbSRH8ZRdj5q8/4llTxoYt92eM8Hx10SGTJvSqjiJr++1QBgjItogE+dzdaRbXh ybGmCCEp/DHd7zB/XIoxQEMJ13Y9DQ2e5ezM+6VVhJgjZkFMMfVjaFMkRmk7Uv32u2Ej JcteTzt57p/e8GgqF6g52kFyiZRfssnoGXCxRf/0fIyrs4CWaa9754ICgXa5K6Hop80U nudA== 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:message-id :in-reply-to:date:subject:to:from:references:sender:dkim-signature; bh=LPlN4npXR/n22oCsSV5n5YZ9mmgvD1wUXIgaogwXyFg=; b=y++gdM2H5CH5rHtlk/sqe97sZ/BSgDb/Tg64UGh/HFv+67Af2WPVwBHseMkf01DJjl PurMI35vZfp8iKCSCBtXsq9XYaJwNataZp9OCkqvHOlVg79o/AlHiM9XL4miKnXuKb4U 1ZKSwlSVkxS9tgSeZPCQfxWbmMNsFfQj2Ze5qelTMIF3k3YJlYa3glrj2prY08Ux91ee reivROD4lpDJ0shP46cbeoZdMQDHB27m7606g6RDVSV9st8kVcnquEMA8I4s6aN/o5ZP Sx/X68VcTI4oIs1QNu6ng0UjDaDRgn4ETUGZHB2qicIS3j9dYM+i3Lq6zAOkzmHsJi5N UqzQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.56.172 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org 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 :message-id:in-reply-to:date:subject:to:from:references:sender:from :to:cc:subject:date:message-id:reply-to; bh=LPlN4npXR/n22oCsSV5n5YZ9mmgvD1wUXIgaogwXyFg=; b=YojRVdwgZAV8lbGCGHUO4mHcusXM7btsXTE51bdAba+cdNibzRQYu35fpSrXXJJuX8 n+FtbxPjUCojk3GC0UIcJC+WpWVP5gcg5I/9grsPXiUrPYJTshtlziLF9aY1VVu0XDp6 CbCwxZ8egQ6cLyz5MSyQcF9pzz+4QjJPyGE6CoRy4tBFxx+QWgY73+Qc2yjJ80iYlHWA 9nHcpoALWcCS++0zBVMKmr6qNwyBf9Q54SXScbhEjbrtW8VrM/8JHFUZFKmwjgroO3a/ /fW6AF13KLVNnFGlQXmvhXKVHVzqPYs2ZEtj2WOSprWDFwVVuQCidRNwsI8V4G61ZNqJ gruQ== 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 :message-id:in-reply-to:date:subject:to:from:references :x-gm-message-state:sender:from:to:cc:subject:date:message-id :reply-to; bh=LPlN4npXR/n22oCsSV5n5YZ9mmgvD1wUXIgaogwXyFg=; b=dAsq1gzbexo0NhLOQeNwOW8ofUBlQpfgCWs/Jz8GTCnUtRcDAz6+1FMfV+wV3/oNUB k4u344MZWwtAAqlCs9ZvhLEk9SU3VZKjSV+3QTj6oML5JNEGW6Ut/BozCeJN6J5a8vIZ qASLAPzMaxLRdT1AOfCqGh+zUaspcuXPDmwpts+hLsftr4iYEgNSNU1Efb00OOuYuUkY IxWK2zOFDpGhB/RsKy7x3P5nrnM8HfYJbn/dD3WbfhUb0YU3ZtkxAE5G8ccUqeKSnWw4 pY8Yp6ZH1LlgGm2ruwET60HuRR8+kYRh+2WbIAGb2BGx4I Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: ACrzQf3OqS50SBOvkr6OeNFbtF1Bs0BSAih/5cpV5AxnfCGU1MCPv8t7 m/Xvg9z6nvaCRr/luPukCIA= X-Google-Smtp-Source: AMsMyM7X0Lm16hhiS1tmTKlRZLuiyxVVwnd23D9P3GjWnQyjbYMd+EUjjtm5YVwgP/f3Dy77kNZBtA== X-Received: by 2002:a2e:a490:0:b0:277:e5b:ec07 with SMTP id h16-20020a2ea490000000b002770e5bec07mr15328645lji.371.1667636358850; Sat, 05 Nov 2022 01:19:18 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a2e:93c4:0:b0:26b:ff81:b7cb with SMTP id p4-20020a2e93c4000000b0026bff81b7cbls1444445ljh.6.-pod-prod-gmail; Sat, 05 Nov 2022 01:19:13 -0700 (PDT) X-Received: by 2002:a2e:8948:0:b0:277:749:f737 with SMTP id b8-20020a2e8948000000b002770749f737mr14204410ljk.54.1667636353471; Sat, 05 Nov 2022 01:19:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667636353; cv=none; d=google.com; s=arc-20160816; b=HfMgQtyNaFSVQ1lVroponOEf5i0Mo/zv//55HK1ou4KsEMyvjeUZfUeyKNP3YlIcjG 5L8eQxRTuy8mSBvgJIUh4Vj9dnbQm10dNS5S8CyGmZKe33qEH93SjMgZXXYYdILJ/A1K sSkW1IKDF03rxaa0nn3ncQEB3W1SBZ2BXkt1d/rPZTUTLtwZxcjasKjfCnvAD1bIU7A5 jz6Ry7x8PqQSXPCMsEsX559T0IPklvmXy8psnke4a/FtomJT5qwb+3qtISMlfU5NfwDj rofkO3H9nHhUZIYgzxf7NmX17jlZeX4AuCfqVJBMQVfVNVyO7PnI0H0DqMrJIhVTSwLD qEtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:message-id:in-reply-to:date:subject:to:from:references; bh=HjGB4bB9/VFYlcDm+xLyPi0taUfVdwpIauBEA0/kTr4=; b=vdJ+85GsOx9m7WgxKiQqlnxa5Agai6PqvKMlGSA112rnjkwMtGR3RPO10AYYdUYehu Sf9r2ulM4Wx5X/xp/8EoB+txysvY326c/LW/ihxHxjQk2rYwCeDuzW7tMCUuEw6Tf0jU aml9PoMkZwlTw+yWdsMrmL7+AyFa1oblL5y2SRPU7uXf+fPYmU3ZxKlC0u3KoaMFHRcG l1rZCI9dF2mignHWyIfnPv2vyKsbz1U6jXTMxY3asvpA0Of2m5K7rTkOYDq9vn8syykv rrq4MQQeEv6zcEDhL0bhmnXneBm2KMGFTOhE8O2Jq+IAnMEik4xLmJ7xGB2xpN7dGkrE 5f7Q== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.56.172 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org Original-Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org. [80.241.56.172]) by gmr-mx.google.com with ESMTPS id w17-20020a05651234d100b004a222ff195esi42184lfr.11.2022.11.05.01.19.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Nov 2022 01:19:13 -0700 (PDT) Received-SPF: pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.56.172 as permitted sender) client-ip=80.241.56.172; Original-Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4N49Pp53cqz9sml for ; Sat, 5 Nov 2022 09:19:10 +0100 (CET) In-reply-to: X-Rspamd-Queue-Id: 4N49Pp53cqz9sml X-Original-Sender: albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.56.172 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@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.io gmane.text.pandoc:31690 Archived-At: Aidan Reilly writes: > Trying this, but it's just passing the text of the admonition block > through The order of spaces and newline in the replacement was switched. After some playing around, this is the filter I came up with: ``` lua local admonitions = { warning = '!!! warning', note = '!!! note', tip = '!!! tip', important = '!!! important', caution = '!!! caution' } local opts = PANDOC_WRITER_OPTIONS -- reuse options to render snippets opts.columns = opts.columns - 4 -- admons are indented by four spaces opts.template = nil -- render a snippet function Div (div) local admonition_text = admonitions[div.classes[1]] if not admonition_text then return nil end -- not an admonition: bail local md = admonition_text .. '\n' .. pandoc.write(pandoc.Pandoc(div.content), 'markdown', opts) return pandoc.RawBlock( 'markdown', md:gsub('\n*$', '') -- remove trailing newlines :gsub('\n', '\n ') -- indent block ) end ``` -- Albert Krewinkel GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124