From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/30867 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Albert Krewinkel Newsgroups: gmane.text.pandoc Subject: Re: manipulating headline level Date: Wed, 29 Jun 2022 14:08:03 +0200 Message-ID: <87ilojbqsp.fsf@zeitkraut.de> References: 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="792"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCZJF7XJTILRBG4J6GKQMGQE7APQJMY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed Jun 29 14:25:03 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-wr1-f57.google.com ([209.85.221.57]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1o6Wkh-000AaQ-Gy for gtp-pandoc-discuss@m.gmane-mx.org; Wed, 29 Jun 2022 14:25:03 +0200 Original-Received: by mail-wr1-f57.google.com with SMTP id q15-20020a5d61cf000000b0021bc2461141sf1782034wrv.5 for ; Wed, 29 Jun 2022 05:25:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1656505503; cv=pass; d=google.com; s=arc-20160816; b=cEU2sBn7hzlLXN3ERuB/T+jGWwfj5y+x/C+i8cE2IAePlW4bswHkusuziLiiRCa+67 h0r68+IJjUwbBvthr5jM4uCP+A1O4+VzCYD7od5sUINBxcMS1az0yMX9VvAr8XBgdN0n F38q9DlsrNyW6kx0Av5l7eXLosXud9Lxq8GWJ31IfWkVKSDbaOGl+6Cva8YMpFmMI5wb cAFHzwphN8V6TfK9+PirxeKwBhdcLU+XWUjjE8x9Hmg7euTRK69jI2zmUUgG3T/zjw6Z KNMAEvdL5ssZ/QyBtPizLL8L/mqETxw4ZPbVigTMI1EWkHcNQUAR4QDDP7+H6HWUBTk6 ckgQ== 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=s2yf6COgnUm+9QXjOkEInY0c1HhUz8LoA2+NWN7tGX4=; b=G1FVD9YjzfflcEQG48otvB1UmMRRpkhs8XOqOmcFcviG86KIw0BqaRP+hTNIBHsEJj sZsgr/PEz3TVoE6p9/EOGEXVQzVSZynyjLyCPMBr5hRNccT8wNWY9dENvlriglDyuRRp ykVCIVzzOZCX+2GxD1FBHeP6xLdi92TQWRh0DlCtVbJzUfWg1i4KwPEnvvxLxUnDObHw KVW2QA1NoKrYbKxT55AYgnvRrHxMsgjYyrWgznKiAyrESMATahBv3fHoc7Shk6IfdCn9 tLfGtm2vv5aLCtf9FIZJMfZiou+lhZxsAezj3v4GidVBZLSUphUZ55ivSciMWRWBo8F0 x3ng== 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.151 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=sender:references:from:to:subject:date:in-reply-to:message-id :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=s2yf6COgnUm+9QXjOkEInY0c1HhUz8LoA2+NWN7tGX4=; b=gfKEgEaPojG2lExhvzLtA0OKKL0GmNCpWo8Bnk2e+u3pz+i7XrEgvikPz2iUN3WrZR GGLF43cYxQCFPJ1qvdL23ppjUqFNuG8os2s10wgF7qTL9dGG1DunwBifJl3umhES7F84 YReQ/HX3vvtUVIP40VafrS6YBi6lumSGwkrUiT419x/Qd97wYguvtB2M4J5oPwuoiaU5 DUatuMgRS6Ff4xNqNpx41LNIxaA/ZCTcCvTd9RF0SrjdAObbHh4OW9v8o2y6jRnkHgJ+ 2rnIEVVc7gHr70qQ4EcU+ErT3q6JSxZ8reipgmwNAptslXiiDJ1V40ZPnH2TxRHcjrdR YDDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:references:from:to:subject:date :in-reply-to:message-id: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=s2yf6COgnUm+9QXjOkEInY0c1HhUz8LoA2+NWN7tGX4=; b=V6nlRuKbCgX/3ZsiFu9uN7htf7PaLlOeidbTpr2Cl2orxl4wIJA6i7A5lME6YKS2NF dZ7vP8jXsRZn95vwWBOXaqDoyQLKLcEvc0Nrsbg4Nyit7us8+Z1JvAco5ZLE5mxNqT8v T9e/J0co8n+iRue4+VlwlrphdWMVChXMxj/llo/QBz6Z/jBMlYjh0HHGmLHWMQVLtjPb uz6iRUBaexCQflobCePAmpgZrxjDuvkv0t102aIJsnNS0kgyYNWE/6LadyBahmKvnMGq X/WZJs3Q2Edl5FYpnL8zC2bmfh6hYXPlK2Y79GXXGw7M0XTUhkXbFquyYXUgkQkWsx0g JHXQ== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AJIora/JWkeg18GOR4c9tHNBRLcELnZBPZyLmmAuGhUHQmUM0JS1fb9F 6SXl+yhDSKgFQzh+R9xQ7f0= X-Google-Smtp-Source: AGRyM1tluXPjaKsOE5dX1TRidoub3rpInBJfqANoq9ADzJyORIw2L5rOkpTcpolRqgwe1YOs03SDNw== X-Received: by 2002:a05:600c:41d1:b0:3a0:301d:f75f with SMTP id t17-20020a05600c41d100b003a0301df75fmr5309376wmh.31.1656505503113; Wed, 29 Jun 2022 05:25:03 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:600c:2204:b0:3a0:4611:be94 with SMTP id z4-20020a05600c220400b003a04611be94ls1553657wml.3.gmail; Wed, 29 Jun 2022 05:24:58 -0700 (PDT) X-Received: by 2002:a05:600c:3659:b0:3a0:3915:8700 with SMTP id y25-20020a05600c365900b003a039158700mr3263659wmq.127.1656505498736; Wed, 29 Jun 2022 05:24:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656505498; cv=none; d=google.com; s=arc-20160816; b=HPuloJwDLEhBOqk3QXHfRlJefhKDeG1MDB+yPEoBvs9SIfUNWxs+udHaytAn7V+dI7 5IOmAGxovs6US8C+Vaxs5HPs7e8TuRv/hA8n98fKWtsCR+Onhl95QrrYaRf0d5YNwVKP /xofB5gVwBZ8rUCKVwbC6ljCSkCO2Z3b2GVcdT3eRZlctNHukrMwi+eQRXdqeYFTMCmU 2Bfk2q5ZnU7GkYA23d9x2F4o5AVJymhSmlFPxaxIiwI3l3WnelRr38BLK02ywEVRRFsj fUrXmEwIwnmSHdltXcr3aMJnitV2t5976p68twKh8OxACatHlqGb8i6Gu9AjDVVaLqGy EMwg== 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=HGvZsjmVhIfn9oCd6LFk9XVkspD+BJL8vfGkej0Ux50=; b=Uslc2qPTCZmGs9visTQQBmM9wZjruOdOsMBMq/zZcD2f5qg9m7NEOtwOUYgl1+11Tv gEYMvluduOxwytmVBLHGhifbmEWO8Cj1J1Y9nLOyyMJF19AxbaQ/j9dHh8mAiq/GeU3V B5d58Me+5IP8ZwRE/5hOEAL8kDpFWAm/Wm/xNOExCpDTm3nlK/BXi8T0yuemWLu2T2RP tKASm++eaxxJJIhl8/v4Klf7AmlnLdUlckjNgKCwduSjZ810UP4STVj7cv7EYnMj4CzE v9H6agWERRI550cjCnxnYVhusqiquboQKLm1VQzmFlv94c6GEpqTJoXkL7MoPnpnxFYz AoPA== 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.151 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org Original-Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org. [80.241.56.151]) by gmr-mx.google.com with ESMTPS id ay11-20020a05600c1e0b00b0039c4133ae38si110580wmb.2.2022.06.29.05.24.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 05:24:58 -0700 (PDT) Received-SPF: pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.56.151 as permitted sender) client-ip=80.241.56.151; Original-Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (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-101.mailbox.org (Postfix) with ESMTPS id 4LY0yw3mZcz9sQG for ; Wed, 29 Jun 2022 14:24:56 +0200 (CEST) In-reply-to: X-Rspamd-Queue-Id: 4LY0yw3mZcz9sQG 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.151 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:30867 Archived-At: Dear juh, "'juh' via pandoc-discuss" writes: > Many markdown-files hierarchically ordered in folders. > Every file starts with the top-level headline mark "#". > > I want to convert these files like this: > > pandoc $(cat outline.txt) -o target.html > > where outline.txt contains the relative pathes to all files. > > > 00.md > 01/00.md > 01/01/00.md > 01/01/01.md > 01/01/02.md > > Is there a way to tell pandoc that it should regard the headline levels > according to the folder structure? Pandoc can't do this out of the box, but you could use a custom reader to correct the headings. The below requires the current dev version (nightly build), but could be rewritten to work with a released version, too. The script - iterates over all input files, - parses their contents as a separate document, - shifts headers in each document by the number of subdirs the respective file is in, and - concatenates the individual per-file documents into a single document that is then returned. Pass the reader file to pandoc via the `--from` parameter. ``` lua local format = 'markdown+smart' function Reader (sources, opts) local doc = pandoc.Pandoc{} for _, source in ipairs(sources) do local path_components = #pandoc.path.split(source.name) -- last path component is the filename local depth = path_components - 1 doc = doc .. pandoc.read(source, format, opts):walk { Header = function (h) h.level = h.level + depth return h end } end return doc end ``` -- Albert Krewinkel GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124