From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/22500 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: BP Jonsson Newsgroups: gmane.text.pandoc Subject: Re: A writer for PreTeXt Date: Thu, 11 Apr 2019 12:48:19 +0200 Message-ID: <008eebaf-2dd4-32c6-9d68-63fc99fa1e27@gmail.com> References: <9b82655a-3067-4696-8123-5b0b99496a70@googlegroups.com> <4b209782-0203-41f8-be61-707985d10afa@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8"; format=flowed Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="52028"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org, Oscar Levin Original-X-From: pandoc-discuss+bncBDIY76M674FRB5NWXTSQKGQE7QUK3DI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Apr 11 12:48:23 2019 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-wm1-f58.google.com ([209.85.128.58]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1hEXFm-000DOI-PT for gtp-pandoc-discuss@m.gmane.org; Thu, 11 Apr 2019 12:48:22 +0200 Original-Received: by mail-wm1-f58.google.com with SMTP id o8sf3445489wma.4 for ; Thu, 11 Apr 2019 03:48:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1554979702; cv=pass; d=google.com; s=arc-20160816; b=FTA2vckjZuqHUJpTuhWEZWXQQ9evlxgcHk19WrbmQ5lBsb10MffcV8fHvz86fJYknp 31bkcPvwdmTmLxZG2H9IF7odG1FM3WXoOkM/XRViJ+QJy/Ok9x51i/0h4iKfqR1nsNUZ Zi3Jy15VT2ApOSN6xyeUlyeCIuS3SHQMk9ZpDZNsCXWWjVruY9o48yMeCMqGRZY/Vk4C g5pHJGVDRuaQjRqzZICcDRTEg5H4n/24LJ+IzA3oL/UjJ6zcDq4W74Yd2XYqz17e/7M2 ParuI/yYTXZj5CIcxnTp5ExEF9dsqKsogkM0xy5XY0RMbRM3LEXR2OWLrLm8YQdWDXL6 cSBA== 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:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:sender:dkim-signature:dkim-signature; bh=XC/oG9q2zFNIHneNTInjn+1n8eVdJyyBWxwmp2UFY+c=; b=PbBQRlU4gs8EoGOqxKi8j5xUtd1gchE4CGreGCkis/b3GsuRbjtlUvVWbfg5iathVQ hNPUBzFvrx/SxB4DzyFE/fJHkOSIzj+IJ3gT6Uw8XdHw01k0W6b1y/ip3KC1uXLtlMBE eesSaqLlPZ/Rym93J/ZmLevVpyz0e/8M+nnSjX99r06V8kR56XhsXjaW8c4PQ9rX2yfu AVzIvYriq0MQ32RXl2jRw5fFKzPf85nuoXfyfljqAViN5+pcOUO/BRP6rPkvMQNQyJoM zAn24TVzxYo6qOSPP3La+Ca9nn0K3OfuPZqqvAc29mdLzLChGakhG56bgkkzePRktPi0 ubRw== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pDtT2U1C; spf=pass (google.com: domain of bpjonsson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::130 as permitted sender) smtp.mailfrom=bpjonsson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language: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=XC/oG9q2zFNIHneNTInjn+1n8eVdJyyBWxwmp2UFY+c=; b=IwMeqEjggLupkuG0E0CVvtLuhDdk07BgIqAgxL51v3yMqlC+pegP9T18zlQbZG6gCG reurG1OxXq5GKVi7A+EzYJ1gkD9HgxMvsa2gjXj8CQK9c72MA4Bks/FyNOC9uJGzpwT/ 7YVQ/H2s7WKfSU9UZzehTOxrahkhqFWk2hDqECd2fMBX+HLQflabtOXlmwThokGhxkq+ VEYeiox/zfWW7vO7kObIatvuOFH2wQ1SqIHo6Xb5i2QOpTqdo2kCVAUiEEcib6v8T9e9 OemWTRKnvTP3Sz1+i3SDPZnH9AQB0oSOSWmPJwiLRPj5E2snR41Sca3jSktwTrxOwAjP 08Xw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language: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=XC/oG9q2zFNIHneNTInjn+1n8eVdJyyBWxwmp2UFY+c=; b=pWE4h6cGDqIu/S8/aoV4vTZjgdl9gRSM/Z198QFR8Aq3Ey7yZfI+hPwog1Ff6+MvOP xEq8qZdbBKRodaDLuN4AwCIs3IFiNpsI2yIjCxDSOkIr4Stqzalc9ZOdf4g5oSXmAy89 d+22iHt/Q9FHTl8v/dgD3Cke0PZWWObKMPr2rF13sM5DlYKP+q20EgSMW8MCUkyFY7na NoW5GiY8o082SOm9LL9vXm+4jgwYX7e2iEBkXYkdd62D9P1WO0Qczs99qmM8kFCST2iQ GBMP16J9TxEqTRM7ETetKTbahftG5PJO8PhzacZ9Jm6eB2VZHfOkBCYUGASgl+pU7UE4 tXDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :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=XC/oG9q2zFNIHneNTInjn+1n8eVdJyyBWxwmp2UFY+c=; b=PEp628E3jJ9BOrRyf0LTqsgv0cwBGJ8eJsOBF3gNeS79rzM6vvIAP7jLY70jEEHtl+ BlIetGlk0RZKZlb5ORXPLvtGqUB78y2xWyGWdvq7E8ffJXB1NeRzIkCMff8gSXl5ZCai QDUFp2IcWXFkpZNXKwW1YSwCenGn3VUgmpg+0zZQ8scDBbzhE7DJMTGZtJGw8nXm6ofX V9YpzJWuEoug5DVobpDQMlGGkkKftE298MdyHMBMdrCgOg80FgbaGnR6sAFblQBLuziM 5d9v0DWECUG1j+JBBXu7zRuR6eFUXs1tvanaez2xZwaib8w2/57kfz6l2dfr2zAnlc/J Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: APjAAAXM9neeUXRh+RHmPYClOJrfZT1bIdrcLcfWFk0b9oebb83vY/Ar iBWuwoBJdaODMbr1Zz2UXbA= X-Google-Smtp-Source: APXvYqySgmxsTm19rmZ+eMosTdP0kIq0Y8gE8TTeOY8MlGJrEXUgUn6TvRnK40frQHlQWryeKe1sKA== X-Received: by 2002:adf:ef0b:: with SMTP id e11mr19455064wro.244.1554979702298; Thu, 11 Apr 2019 03:48:22 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:600c:2292:: with SMTP id 18ls1651081wmf.3.canary-gmail; Thu, 11 Apr 2019 03:48:21 -0700 (PDT) X-Received: by 2002:a1c:b782:: with SMTP id h124mr553521wmf.8.1554979701528; Thu, 11 Apr 2019 03:48:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554979701; cv=none; d=google.com; s=arc-20160816; b=RGqCP78ZJEZ7G2UZFDO27le6jZ4DWluKkYeoA/2VDw+o7jilQj7abq9Aah4kQsI2+p 2CIDV5Hco9ViPAhDkTDNqmUKATAC9+8rP+6WhfoR/jVqtAM7B3VJ/8ccH7rWJ/qo22na ieyIhp/p7p3HwZbK/aTYZya7c4UMWOdQN6IcRehI7duWRE8yQk8cA+rIK6HsIVx5mNKj oYwV+0iKBuHlhek5fW2HnR1c4ZG/0q+/b1Fc+ENuGvsHpZajnS6xc7uN3DTbpBgD45fA NTpBlladwcpWV8q2d7Diqo2afhh1tdQ/7L4i4xLEjWmQ/StMTPBsHlLRCoLCTuSo5M8Y I1DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:to:subject :dkim-signature; bh=lzEsDOphmvrtTivTX9muvybCzOg2cEymsACYbGXPPMA=; b=v0W40axU6UzQRjRnF5pdwk4qRYgKGhrfDhRnXTAylsW5BrrBp1y0nrnh1NbLUNXRrT lGo9ydMefeQwKqs9o115xcUL4SZFz56ZguRBlR1YO9N4MUcSPJFFcOCYhsyiX7kd+2fi 39WANrCE1/nYdQXCIju6Ro9QEenXlpWWXHOmsusiq8XGRU422iWpyrz7x1wIvd1P6vpR xCakPk25RCGDSsqKxc3lWWUMPEQMZUg5Q7mSxRDkJ2oRDZKl5Q2/sxXQuDyCLHlCl4Mg BJm9G+VwzTP81pcV1JPg+C8lSJsscmrbTOLE2TShQGLKkWBntgeyBQzfsioYyQ8kaZ8A vKGw== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pDtT2U1C; spf=pass (google.com: domain of bpjonsson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::130 as permitted sender) smtp.mailfrom=bpjonsson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com. [2a00:1450:4864:20::130]) by gmr-mx.google.com with ESMTPS id p14si280750wmh.2.2019.04.11.03.48.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Apr 2019 03:48:21 -0700 (PDT) Received-SPF: pass (google.com: domain of bpjonsson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::130 as permitted sender) client-ip=2a00:1450:4864:20::130; Original-Received: by mail-lf1-x130.google.com with SMTP id w23so4306939lfc.9 for ; Thu, 11 Apr 2019 03:48:21 -0700 (PDT) X-Received: by 2002:ac2:4285:: with SMTP id m5mr25999229lfh.103.1554979700937; Thu, 11 Apr 2019 03:48:20 -0700 (PDT) Original-Received: from [192.168.1.110] (user243.82-197-226.netatonce.net. [82.197.226.243]) by smtp.gmail.com with ESMTPSA id z8sm7642411ljc.50.2019.04.11.03.48.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Apr 2019 03:48:19 -0700 (PDT) In-Reply-To: <4b209782-0203-41f8-be61-707985d10afa-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Content-Language: sv-SE X-Original-Sender: bpjonsson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pDtT2U1C; spf=pass (google.com: domain of bpjonsson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::130 as permitted sender) smtp.mailfrom=bpjonsson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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.org gmane.text.pandoc:22500 Archived-At: You need to familiarize yourself with how different elements are represnted in the Pandoc AST. In my experience the best way to do that is not to read the documentation (althou8gh you want to do that too of course[^1]) but to type examples of the kinds of structures you want to work with in Markdown and study what they look like in native and json output. A JSON prettyprinter which adds spacing and indentation is a very good help. Start with simple things like `[text]{#id .class1 .class2 attr1=val1 attr2=val2}` and go in to more complicated/nested structures once you understand them. To help me with visualizing the Lua objects I use the table dumping function[^2] from the Penlight libraries[^3] enhanced by the following custom function which makes a copy of (the non-metatable parts of) the lua objects, adding a key for the element type which otherwise is buried in the metatables: ````lua local pl_pretty = require "pl.pretty" -- visualize a (tree of) Lua Pandoc elements -- without destroying the originals function showit (x) if 'table' == type(x) then local y = {} -- the "copy" for k, v in pairs(x) do y[k] = showit(v) -- expand recursively end -- show the tag from the metatable if y._t then -- if y._t already exists (it shouldn't) don't clobber it y._t = { _t = y._t, t = x.t } else -- otherwise just assign the value of x.t from the metatable to it y._t = x.t end return y else return x end end function dumpit (x) pl_pretty.dump(showit(x)) end ```` I have these living in my `~/.pandoc/init.lua` so that they are always available. Saying `dumpit(element)` will then pretty-print the element structure to stderr. [^1]: Above all the Lua filter documentation but also the element type definitions (which were all we had before the advent of lua filters. (may not be the latest version). [^2]: [^3]: Den 2019-04-11 kl. 06:43, skrev Oscar Levin: > Hi John, > > Thanks for the hint. I've been trying to wrap my head around all this > (filters and their relation to custom writers, plus the logical structure > of how the writer "walks" the AST, if that is even the right way of > thinking about it), so far with little luck. Maybe I'm stuck in the > mindset of how xslt processes xml. I'll keep hacking away. > > I found an old custom JATS writer, but that seems abandoned (since there is > regular writer for it now): there sections were handled by putting >
where headers go, and then removing the first >
and adding one at the end of the document. That approach would > not work for me, since I would like . I assume the > hierarchicalize would allow for this? So far I've been unable to figure it > out though. > > While I keep thinking about this, here is a little more about PreTeXt. I'm > not the author of it, but as I see it, the big advantage over docbook is > math support (it was previously called MathBook XML). I like it for my > textbooks because it allows for theorems/proofs, and exercises/solutions, > and so on. The HTML output you get (via xslt) can put solutions or proofs > in "knowls": a link you click on that expands a box with the content. > Cross references also work this way (if you reference an earlier theorem, > clicking on the link opens a box with the statement of the theorem, for > example). You can also process the xml into LaTeX for pdf output. > > In terms of users, I can only speculate on lower bounds: the "gallery" of > textbook projects on the PreTeXt website lists 33 completed books, and I > know of at least a dozen more books currently under development. The > github repository (https://github.com/rbeezer/mathbook) has been forked 82 > times. I'm not sure what you would consider a reasonable number of users; > I would like to see the number of users grow, and I see having an easy way > to get people started by converting a latex or word document into PreTeXt > as a good step in that direction. > > Thanks, > Oscar. > > On Friday, April 5, 2019 at 11:27:19 AM UTC-6, John MacFarlane wrote: >> >> >> To group content into sections, you should be able to >> use the function hierarchicalize from pandoc.utils: >> >> https://pandoc.org/lua-filters.html#utils-hierarchicalize >> >> This wraps the function that the Haskell writers use. >> >> A regular writer might be considered, but I'd like to >> know more about PreTeXt. What is the advantage over >> using, say, plain DocBook? How many users are there? >> >> Oscar Levin writes: >> >>> I am working on a custom (lua) writer for PreTeXt ( >> https://pretextbook.org/), >>> which I use to write open math textbooks. In terms of syntax, PreTeXt >> is >>> xml and is very similar to docbook, so a lot of what I need was easily >>> modified from the sample.lau custom writer. >>> >>> What I haven't been able to figure out is how to wrap sections in >>
>>> tags. That is, in the built in docbook writer, if you have a header, I >>> think it creates a section with a title around the appropriate content. >> Is >>> there any way to do this with a custom lua writer? >>> >>> Perhaps a better approach would be to contribute a new built in writer >> by >>> modifying the docbook writer. I think there would be a good number of >>> people who would find this writer useful. Would such a contribution be >>> considered? >>> >>> Thanks, >>> Oscar. >>> >> >