* Printing lua tables
@ 2022-06-07 7:57 denis.maier-NSENcxR/0n0
[not found] ` <551a3f2a8d364717bcc569baa974573a-NSENcxR/0n0@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: denis.maier-NSENcxR/0n0 @ 2022-06-07 7:57 UTC (permalink / raw)
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw
[-- Attachment #1: Type: text/plain, Size: 595 bytes --]
Hi,
When playing around with filters I use pprint.lua or inspect.lua to visualize lua tables. Would it make sense to include some sort of <print the contents of this table> to pandoc ?
Best,
Denis
--
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/551a3f2a8d364717bcc569baa974573a%40unibe.ch.
[-- Attachment #2: Type: text/html, Size: 2474 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Printing lua tables
[not found] ` <551a3f2a8d364717bcc569baa974573a-NSENcxR/0n0@public.gmane.org>
@ 2022-06-07 10:44 ` William Lupton
[not found] ` <CAEe_xxiL81rUdVtCeKovjYeo=KaKP1GAbwEiM6_9byZY8t_XvA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: William Lupton @ 2022-06-07 10:44 UTC (permalink / raw)
To: pandoc-discuss
[-- Attachment #1.1: Type: text/plain, Size: 2199 bytes --]
I think I've mentioned this before... but I'd be happy to contribute (in a
suitable form) the somewhat-pandoc-aware utility that I use for this.
Given this input:
*% *cat doc.md
---
a: 1
b: |
2 3 4
---
# Header
This is a sentence (and a paragraph).
* This is a list item
* And another
| Right | Left | Default | Center |
|------:|:-----|---------|:------:|
| 12 | 12 | 12 | 12 |
| 123 | 123 | 123 | 123 |
| 1 | 1 | 1 | 1 |
: Demonstration of pipe table syntax.
and this filter:
*% *cat rep.lua
local utils = require 'utils'
-- do it this way to avoid reporting MetaBlocks twice
function Pandoc(doc)
utils.temp('meta', doc.meta)
utils.temp('blocks', doc.blocks)
end
this command:
pandoc doc.md -L rep.lua >/dev/null 2>doc.txt
generates the attached.
On Tue, 7 Jun 2022 at 08:57, <denis.maier-NSENcxR/0n0@public.gmane.org> wrote:
> Hi,
>
> When playing around with filters I use pprint.lua or inspect.lua to
> visualize lua tables. Would it make sense to include some sort of «print
> the contents of this table» to pandoc ?
>
> Best,
>
> Denis
>
> --
> 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/551a3f2a8d364717bcc569baa974573a%40unibe.ch
> <https://groups.google.com/d/msgid/pandoc-discuss/551a3f2a8d364717bcc569baa974573a%40unibe.ch?utm_medium=email&utm_source=footer>
> .
>
--
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/CAEe_xxiL81rUdVtCeKovjYeo%3DKaKP1GAbwEiM6_9byZY8t_XvA%40mail.gmail.com.
[-- Attachment #1.2: Type: text/html, Size: 14808 bytes --]
[-- Attachment #2: doc.txt --]
[-- Type: text/plain, Size: 9159 bytes --]
(#) meta {
a: MetaInlines {
[1] Str text: "1"
}
b: MetaBlocks {
[1] content: Para {
[1] Str text: "2"
[2] Space {}
[3] Str text: "3"
[4] Space {}
[5] Str text: "4"
}
}
}
(#) blocks {
[1] Header {
attr: Attr {
attributes: {}
classes: {}
identifier: "header"
}
content: {
[1] Str text: "Header"
}
level: 1
}
[2] content: Para {
[1] Str text: "This"
[2] Space {}
[3] Str text: "is"
[4] Space {}
[5] Str text: "a"
[6] Space {}
[7] Str text: "sentence"
[8] Space {}
[9] Str text: "(and"
[10] Space {}
[11] Str text: "a"
[12] Space {}
[13] Str text: "paragraph)."
}
[3] content: BulletList {
[1] {
[1] content: Plain {
[1] Str text: "This"
[2] Space {}
[3] Str text: "is"
[4] Space {}
[5] Str text: "a"
[6] Space {}
[7] Str text: "list"
[8] Space {}
[9] Str text: "item"
}
}
[2] {
[1] content: Plain {
[1] Str text: "And"
[2] Space {}
[3] Str text: "another"
}
}
}
[4] Table {
attr: Attr {
attributes: {}
classes: {}
identifier: ""
}
bodies: {
[1] {
body: {
[1] {
[1] Attr {
attributes: {}
classes: {}
identifier: ""
}
[2] {
[1] {
col_span: 1
contents: {
[1] content: Plain {
[1] Str text: "12"
}
}
alignment: "AlignDefault"
row_span: 1
attr: {
[1] ""
[2] {}
[3] {}
}
}
[2] {
col_span: 1
contents: {
[1] content: Plain {
[1] Str text: "12"
}
}
alignment: "AlignDefault"
row_span: 1
attr: {
[1] ""
[2] {}
[3] {}
}
}
[3] {
col_span: 1
contents: {
[1] content: Plain {
[1] Str text: "12"
}
}
alignment: "AlignDefault"
row_span: 1
attr: {
[1] ""
[2] {}
[3] {}
}
}
[4] {
col_span: 1
contents: {
[1] content: Plain {
[1] Str text: "12"
}
}
alignment: "AlignDefault"
row_span: 1
attr: {
[1] ""
[2] {}
[3] {}
}
}
}
}
[2] {
[1] Attr {
attributes: {}
classes: {}
identifier: ""
}
[2] {
[1] {
col_span: 1
contents: {
[1] content: Plain {
[1] Str text: "123"
}
}
alignment: "AlignDefault"
row_span: 1
attr: {
[1] ""
[2] {}
[3] {}
}
}
[2] {
col_span: 1
contents: {
[1] content: Plain {
[1] Str text: "123"
}
}
alignment: "AlignDefault"
row_span: 1
attr: {
[1] ""
[2] {}
[3] {}
}
}
[3] {
col_span: 1
contents: {
[1] content: Plain {
[1] Str text: "123"
}
}
alignment: "AlignDefault"
row_span: 1
attr: {
[1] ""
[2] {}
[3] {}
}
}
[4] {
col_span: 1
contents: {
[1] content: Plain {
[1] Str text: "123"
}
}
alignment: "AlignDefault"
row_span: 1
attr: {
[1] ""
[2] {}
[3] {}
}
}
}
}
[3] {
[1] Attr {
attributes: {}
classes: {}
identifier: ""
}
[2] {
[1] {
col_span: 1
contents: {
[1] content: Plain {
[1] Str text: "1"
}
}
alignment: "AlignDefault"
row_span: 1
attr: {
[1] ""
[2] {}
[3] {}
}
}
[2] {
col_span: 1
contents: {
[1] content: Plain {
[1] Str text: "1"
}
}
alignment: "AlignDefault"
row_span: 1
attr: {
[1] ""
[2] {}
[3] {}
}
}
[3] {
col_span: 1
contents: {
[1] content: Plain {
[1] Str text: "1"
}
}
alignment: "AlignDefault"
row_span: 1
attr: {
[1] ""
[2] {}
[3] {}
}
}
[4] {
col_span: 1
contents: {
[1] content: Plain {
[1] Str text: "1"
}
}
alignment: "AlignDefault"
row_span: 1
attr: {
[1] ""
[2] {}
[3] {}
}
}
}
}
}
row_head_columns: 0
head: {}
attr: {
[1] ""
[2] {}
[3] {}
}
}
}
caption: {
long: {
[1] content: Plain {
[1] Str text: "Demonstration"
[2] Space {}
[3] Str text: "of"
[4] Space {}
[5] Str text: "pipe"
[6] Space {}
[7] Str text: "table"
[8] Space {}
[9] Str text: "syntax."
}
}
}
colspecs: {
[1] {
[1] "AlignRight"
}
[2] {
[1] "AlignLeft"
}
[3] {
[1] "AlignDefault"
}
[4] {
[1] "AlignCenter"
}
}
foot: {
[1] Attr {
attributes: {}
classes: {}
identifier: ""
}
[2] {}
}
head: {
[1] Attr {
attributes: {}
classes: {}
identifier: ""
}
[2] {
[1] {
[1] Attr {
attributes: {}
classes: {}
identifier: ""
}
[2] {
[1] {
col_span: 1
contents: {
[1] content: Plain {
[1] Str text: "Right"
}
}
alignment: "AlignDefault"
row_span: 1
attr: {
[1] ""
[2] {}
[3] {}
}
}
[2] {
col_span: 1
contents: {
[1] content: Plain {
[1] Str text: "Left"
}
}
alignment: "AlignDefault"
row_span: 1
attr: {
[1] ""
[2] {}
[3] {}
}
}
[3] {
col_span: 1
contents: {
[1] content: Plain {
[1] Str text: "Default"
}
}
alignment: "AlignDefault"
row_span: 1
attr: {
[1] ""
[2] {}
[3] {}
}
}
[4] {
col_span: 1
contents: {
[1] content: Plain {
[1] Str text: "Center"
}
}
alignment: "AlignDefault"
row_span: 1
attr: {
[1] ""
[2] {}
[3] {}
}
}
}
}
}
}
}
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Printing lua tables
[not found] ` <CAEe_xxiL81rUdVtCeKovjYeo=KaKP1GAbwEiM6_9byZY8t_XvA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2022-06-07 13:55 ` John MacFarlane
[not found] ` <m2y1y8fuij.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: John MacFarlane @ 2022-06-07 13:55 UTC (permalink / raw)
To: William Lupton, pandoc-discuss
That looks nice. Can you share your utils.lua?
William Lupton <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org> writes:
> I think I've mentioned this before... but I'd be happy to contribute (in a
> suitable form) the somewhat-pandoc-aware utility that I use for this.
>
> Given this input:
>
> *% *cat doc.md
>
> ---
>
> a: 1
>
> b: |
>
> 2 3 4
>
> ---
>
>
> # Header
>
>
> This is a sentence (and a paragraph).
>
>
> * This is a list item
>
> * And another
>
>
> | Right | Left | Default | Center |
>
> |------:|:-----|---------|:------:|
>
> | 12 | 12 | 12 | 12 |
>
> | 123 | 123 | 123 | 123 |
>
> | 1 | 1 | 1 | 1 |
>
>
> : Demonstration of pipe table syntax.
>
> and this filter:
>
> *% *cat rep.lua
>
> local utils = require 'utils'
>
>
> -- do it this way to avoid reporting MetaBlocks twice
>
> function Pandoc(doc)
>
> utils.temp('meta', doc.meta)
>
> utils.temp('blocks', doc.blocks)
>
> end
>
> this command:
>
> pandoc doc.md -L rep.lua >/dev/null 2>doc.txt
>
> generates the attached.
>
> On Tue, 7 Jun 2022 at 08:57, <denis.maier-NSENcxR/0n0@public.gmane.org> wrote:
>
>> Hi,
>>
>> When playing around with filters I use pprint.lua or inspect.lua to
>> visualize lua tables. Would it make sense to include some sort of «print
>> the contents of this table» to pandoc ?
>>
>> Best,
>>
>> Denis
>>
>> --
>> 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/551a3f2a8d364717bcc569baa974573a%40unibe.ch
>> <https://groups.google.com/d/msgid/pandoc-discuss/551a3f2a8d364717bcc569baa974573a%40unibe.ch?utm_medium=email&utm_source=footer>
>> .
>>
>
> --
> 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/CAEe_xxiL81rUdVtCeKovjYeo%3DKaKP1GAbwEiM6_9byZY8t_XvA%40mail.gmail.com.
> (#) meta {
> a: MetaInlines {
> [1] Str text: "1"
> }
> b: MetaBlocks {
> [1] content: Para {
> [1] Str text: "2"
> [2] Space {}
> [3] Str text: "3"
> [4] Space {}
> [5] Str text: "4"
> }
> }
> }
> (#) blocks {
> [1] Header {
> attr: Attr {
> attributes: {}
> classes: {}
> identifier: "header"
> }
> content: {
> [1] Str text: "Header"
> }
> level: 1
> }
> [2] content: Para {
> [1] Str text: "This"
> [2] Space {}
> [3] Str text: "is"
> [4] Space {}
> [5] Str text: "a"
> [6] Space {}
> [7] Str text: "sentence"
> [8] Space {}
> [9] Str text: "(and"
> [10] Space {}
> [11] Str text: "a"
> [12] Space {}
> [13] Str text: "paragraph)."
> }
> [3] content: BulletList {
> [1] {
> [1] content: Plain {
> [1] Str text: "This"
> [2] Space {}
> [3] Str text: "is"
> [4] Space {}
> [5] Str text: "a"
> [6] Space {}
> [7] Str text: "list"
> [8] Space {}
> [9] Str text: "item"
> }
> }
> [2] {
> [1] content: Plain {
> [1] Str text: "And"
> [2] Space {}
> [3] Str text: "another"
> }
> }
> }
> [4] Table {
> attr: Attr {
> attributes: {}
> classes: {}
> identifier: ""
> }
> bodies: {
> [1] {
> body: {
> [1] {
> [1] Attr {
> attributes: {}
> classes: {}
> identifier: ""
> }
> [2] {
> [1] {
> col_span: 1
> contents: {
> [1] content: Plain {
> [1] Str text: "12"
> }
> }
> alignment: "AlignDefault"
> row_span: 1
> attr: {
> [1] ""
> [2] {}
> [3] {}
> }
> }
> [2] {
> col_span: 1
> contents: {
> [1] content: Plain {
> [1] Str text: "12"
> }
> }
> alignment: "AlignDefault"
> row_span: 1
> attr: {
> [1] ""
> [2] {}
> [3] {}
> }
> }
> [3] {
> col_span: 1
> contents: {
> [1] content: Plain {
> [1] Str text: "12"
> }
> }
> alignment: "AlignDefault"
> row_span: 1
> attr: {
> [1] ""
> [2] {}
> [3] {}
> }
> }
> [4] {
> col_span: 1
> contents: {
> [1] content: Plain {
> [1] Str text: "12"
> }
> }
> alignment: "AlignDefault"
> row_span: 1
> attr: {
> [1] ""
> [2] {}
> [3] {}
> }
> }
> }
> }
> [2] {
> [1] Attr {
> attributes: {}
> classes: {}
> identifier: ""
> }
> [2] {
> [1] {
> col_span: 1
> contents: {
> [1] content: Plain {
> [1] Str text: "123"
> }
> }
> alignment: "AlignDefault"
> row_span: 1
> attr: {
> [1] ""
> [2] {}
> [3] {}
> }
> }
> [2] {
> col_span: 1
> contents: {
> [1] content: Plain {
> [1] Str text: "123"
> }
> }
> alignment: "AlignDefault"
> row_span: 1
> attr: {
> [1] ""
> [2] {}
> [3] {}
> }
> }
> [3] {
> col_span: 1
> contents: {
> [1] content: Plain {
> [1] Str text: "123"
> }
> }
> alignment: "AlignDefault"
> row_span: 1
> attr: {
> [1] ""
> [2] {}
> [3] {}
> }
> }
> [4] {
> col_span: 1
> contents: {
> [1] content: Plain {
> [1] Str text: "123"
> }
> }
> alignment: "AlignDefault"
> row_span: 1
> attr: {
> [1] ""
> [2] {}
> [3] {}
> }
> }
> }
> }
> [3] {
> [1] Attr {
> attributes: {}
> classes: {}
> identifier: ""
> }
> [2] {
> [1] {
> col_span: 1
> contents: {
> [1] content: Plain {
> [1] Str text: "1"
> }
> }
> alignment: "AlignDefault"
> row_span: 1
> attr: {
> [1] ""
> [2] {}
> [3] {}
> }
> }
> [2] {
> col_span: 1
> contents: {
> [1] content: Plain {
> [1] Str text: "1"
> }
> }
> alignment: "AlignDefault"
> row_span: 1
> attr: {
> [1] ""
> [2] {}
> [3] {}
> }
> }
> [3] {
> col_span: 1
> contents: {
> [1] content: Plain {
> [1] Str text: "1"
> }
> }
> alignment: "AlignDefault"
> row_span: 1
> attr: {
> [1] ""
> [2] {}
> [3] {}
> }
> }
> [4] {
> col_span: 1
> contents: {
> [1] content: Plain {
> [1] Str text: "1"
> }
> }
> alignment: "AlignDefault"
> row_span: 1
> attr: {
> [1] ""
> [2] {}
> [3] {}
> }
> }
> }
> }
> }
> row_head_columns: 0
> head: {}
> attr: {
> [1] ""
> [2] {}
> [3] {}
> }
> }
> }
> caption: {
> long: {
> [1] content: Plain {
> [1] Str text: "Demonstration"
> [2] Space {}
> [3] Str text: "of"
> [4] Space {}
> [5] Str text: "pipe"
> [6] Space {}
> [7] Str text: "table"
> [8] Space {}
> [9] Str text: "syntax."
> }
> }
> }
> colspecs: {
> [1] {
> [1] "AlignRight"
> }
> [2] {
> [1] "AlignLeft"
> }
> [3] {
> [1] "AlignDefault"
> }
> [4] {
> [1] "AlignCenter"
> }
> }
> foot: {
> [1] Attr {
> attributes: {}
> classes: {}
> identifier: ""
> }
> [2] {}
> }
> head: {
> [1] Attr {
> attributes: {}
> classes: {}
> identifier: ""
> }
> [2] {
> [1] {
> [1] Attr {
> attributes: {}
> classes: {}
> identifier: ""
> }
> [2] {
> [1] {
> col_span: 1
> contents: {
> [1] content: Plain {
> [1] Str text: "Right"
> }
> }
> alignment: "AlignDefault"
> row_span: 1
> attr: {
> [1] ""
> [2] {}
> [3] {}
> }
> }
> [2] {
> col_span: 1
> contents: {
> [1] content: Plain {
> [1] Str text: "Left"
> }
> }
> alignment: "AlignDefault"
> row_span: 1
> attr: {
> [1] ""
> [2] {}
> [3] {}
> }
> }
> [3] {
> col_span: 1
> contents: {
> [1] content: Plain {
> [1] Str text: "Default"
> }
> }
> alignment: "AlignDefault"
> row_span: 1
> attr: {
> [1] ""
> [2] {}
> [3] {}
> }
> }
> [4] {
> col_span: 1
> contents: {
> [1] content: Plain {
> [1] Str text: "Center"
> }
> }
> alignment: "AlignDefault"
> row_span: 1
> attr: {
> [1] ""
> [2] {}
> [3] {}
> }
> }
> }
> }
> }
> }
> }
> }
--
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/m2y1y8fuij.fsf%40johnmacfarlane.net.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Printing lua tables
[not found] ` <m2y1y8fuij.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2022-06-07 14:13 ` William Lupton
[not found] ` <CAEe_xxiVFhQ8PqSq_37yhMm-8-Pnb2ZgY4eDkO7kdCZQt6bNkA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: William Lupton @ 2022-06-07 14:13 UTC (permalink / raw)
To: John MacFarlane; +Cc: pandoc-discuss
[-- Attachment #1: Type: text/plain, Size: 14611 bytes --]
I'll need to extract the reporting functions. I'll do that soon, and post
the result. This is currently working in pandoc 2.16.1 (and earlier). I
haven't yet bitten the bullet of the move to 2.18.
On Tue, 7 Jun 2022 at 14:55, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:
>
> That looks nice. Can you share your utils.lua?
>
> William Lupton <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org> writes:
>
> > I think I've mentioned this before... but I'd be happy to contribute (in
> a
> > suitable form) the somewhat-pandoc-aware utility that I use for this.
> >
> > Given this input:
> >
> > *% *cat doc.md
> >
> > ---
> >
> > a: 1
> >
> > b: |
> >
> > 2 3 4
> >
> > ---
> >
> >
> > # Header
> >
> >
> > This is a sentence (and a paragraph).
> >
> >
> > * This is a list item
> >
> > * And another
> >
> >
> > | Right | Left | Default | Center |
> >
> > |------:|:-----|---------|:------:|
> >
> > | 12 | 12 | 12 | 12 |
> >
> > | 123 | 123 | 123 | 123 |
> >
> > | 1 | 1 | 1 | 1 |
> >
> >
> > : Demonstration of pipe table syntax.
> >
> > and this filter:
> >
> > *% *cat rep.lua
> >
> > local utils = require 'utils'
> >
> >
> > -- do it this way to avoid reporting MetaBlocks twice
> >
> > function Pandoc(doc)
> >
> > utils.temp('meta', doc.meta)
> >
> > utils.temp('blocks', doc.blocks)
> >
> > end
> >
> > this command:
> >
> > pandoc doc.md -L rep.lua >/dev/null 2>doc.txt
> >
> > generates the attached.
> >
> > On Tue, 7 Jun 2022 at 08:57, <denis.maier-NSENcxR/0n0@public.gmane.org> wrote:
> >
> >> Hi,
> >>
> >> When playing around with filters I use pprint.lua or inspect.lua to
> >> visualize lua tables. Would it make sense to include some sort of «print
> >> the contents of this table» to pandoc ?
> >>
> >> Best,
> >>
> >> Denis
> >>
> >> --
> >> 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/551a3f2a8d364717bcc569baa974573a%40unibe.ch
> >> <
> https://groups.google.com/d/msgid/pandoc-discuss/551a3f2a8d364717bcc569baa974573a%40unibe.ch?utm_medium=email&utm_source=footer
> >
> >> .
> >>
> >
> > --
> > 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/CAEe_xxiL81rUdVtCeKovjYeo%3DKaKP1GAbwEiM6_9byZY8t_XvA%40mail.gmail.com
> .
> > (#) meta {
> > a: MetaInlines {
> > [1] Str text: "1"
> > }
> > b: MetaBlocks {
> > [1] content: Para {
> > [1] Str text: "2"
> > [2] Space {}
> > [3] Str text: "3"
> > [4] Space {}
> > [5] Str text: "4"
> > }
> > }
> > }
> > (#) blocks {
> > [1] Header {
> > attr: Attr {
> > attributes: {}
> > classes: {}
> > identifier: "header"
> > }
> > content: {
> > [1] Str text: "Header"
> > }
> > level: 1
> > }
> > [2] content: Para {
> > [1] Str text: "This"
> > [2] Space {}
> > [3] Str text: "is"
> > [4] Space {}
> > [5] Str text: "a"
> > [6] Space {}
> > [7] Str text: "sentence"
> > [8] Space {}
> > [9] Str text: "(and"
> > [10] Space {}
> > [11] Str text: "a"
> > [12] Space {}
> > [13] Str text: "paragraph)."
> > }
> > [3] content: BulletList {
> > [1] {
> > [1] content: Plain {
> > [1] Str text: "This"
> > [2] Space {}
> > [3] Str text: "is"
> > [4] Space {}
> > [5] Str text: "a"
> > [6] Space {}
> > [7] Str text: "list"
> > [8] Space {}
> > [9] Str text: "item"
> > }
> > }
> > [2] {
> > [1] content: Plain {
> > [1] Str text: "And"
> > [2] Space {}
> > [3] Str text: "another"
> > }
> > }
> > }
> > [4] Table {
> > attr: Attr {
> > attributes: {}
> > classes: {}
> > identifier: ""
> > }
> > bodies: {
> > [1] {
> > body: {
> > [1] {
> > [1] Attr {
> > attributes: {}
> > classes: {}
> > identifier: ""
> > }
> > [2] {
> > [1] {
> > col_span: 1
> > contents: {
> > [1] content: Plain {
> > [1] Str text: "12"
> > }
> > }
> > alignment: "AlignDefault"
> > row_span: 1
> > attr: {
> > [1] ""
> > [2] {}
> > [3] {}
> > }
> > }
> > [2] {
> > col_span: 1
> > contents: {
> > [1] content: Plain {
> > [1] Str text: "12"
> > }
> > }
> > alignment: "AlignDefault"
> > row_span: 1
> > attr: {
> > [1] ""
> > [2] {}
> > [3] {}
> > }
> > }
> > [3] {
> > col_span: 1
> > contents: {
> > [1] content: Plain {
> > [1] Str text: "12"
> > }
> > }
> > alignment: "AlignDefault"
> > row_span: 1
> > attr: {
> > [1] ""
> > [2] {}
> > [3] {}
> > }
> > }
> > [4] {
> > col_span: 1
> > contents: {
> > [1] content: Plain {
> > [1] Str text: "12"
> > }
> > }
> > alignment: "AlignDefault"
> > row_span: 1
> > attr: {
> > [1] ""
> > [2] {}
> > [3] {}
> > }
> > }
> > }
> > }
> > [2] {
> > [1] Attr {
> > attributes: {}
> > classes: {}
> > identifier: ""
> > }
> > [2] {
> > [1] {
> > col_span: 1
> > contents: {
> > [1] content: Plain {
> > [1] Str text: "123"
> > }
> > }
> > alignment: "AlignDefault"
> > row_span: 1
> > attr: {
> > [1] ""
> > [2] {}
> > [3] {}
> > }
> > }
> > [2] {
> > col_span: 1
> > contents: {
> > [1] content: Plain {
> > [1] Str text: "123"
> > }
> > }
> > alignment: "AlignDefault"
> > row_span: 1
> > attr: {
> > [1] ""
> > [2] {}
> > [3] {}
> > }
> > }
> > [3] {
> > col_span: 1
> > contents: {
> > [1] content: Plain {
> > [1] Str text: "123"
> > }
> > }
> > alignment: "AlignDefault"
> > row_span: 1
> > attr: {
> > [1] ""
> > [2] {}
> > [3] {}
> > }
> > }
> > [4] {
> > col_span: 1
> > contents: {
> > [1] content: Plain {
> > [1] Str text: "123"
> > }
> > }
> > alignment: "AlignDefault"
> > row_span: 1
> > attr: {
> > [1] ""
> > [2] {}
> > [3] {}
> > }
> > }
> > }
> > }
> > [3] {
> > [1] Attr {
> > attributes: {}
> > classes: {}
> > identifier: ""
> > }
> > [2] {
> > [1] {
> > col_span: 1
> > contents: {
> > [1] content: Plain {
> > [1] Str text: "1"
> > }
> > }
> > alignment: "AlignDefault"
> > row_span: 1
> > attr: {
> > [1] ""
> > [2] {}
> > [3] {}
> > }
> > }
> > [2] {
> > col_span: 1
> > contents: {
> > [1] content: Plain {
> > [1] Str text: "1"
> > }
> > }
> > alignment: "AlignDefault"
> > row_span: 1
> > attr: {
> > [1] ""
> > [2] {}
> > [3] {}
> > }
> > }
> > [3] {
> > col_span: 1
> > contents: {
> > [1] content: Plain {
> > [1] Str text: "1"
> > }
> > }
> > alignment: "AlignDefault"
> > row_span: 1
> > attr: {
> > [1] ""
> > [2] {}
> > [3] {}
> > }
> > }
> > [4] {
> > col_span: 1
> > contents: {
> > [1] content: Plain {
> > [1] Str text: "1"
> > }
> > }
> > alignment: "AlignDefault"
> > row_span: 1
> > attr: {
> > [1] ""
> > [2] {}
> > [3] {}
> > }
> > }
> > }
> > }
> > }
> > row_head_columns: 0
> > head: {}
> > attr: {
> > [1] ""
> > [2] {}
> > [3] {}
> > }
> > }
> > }
> > caption: {
> > long: {
> > [1] content: Plain {
> > [1] Str text: "Demonstration"
> > [2] Space {}
> > [3] Str text: "of"
> > [4] Space {}
> > [5] Str text: "pipe"
> > [6] Space {}
> > [7] Str text: "table"
> > [8] Space {}
> > [9] Str text: "syntax."
> > }
> > }
> > }
> > colspecs: {
> > [1] {
> > [1] "AlignRight"
> > }
> > [2] {
> > [1] "AlignLeft"
> > }
> > [3] {
> > [1] "AlignDefault"
> > }
> > [4] {
> > [1] "AlignCenter"
> > }
> > }
> > foot: {
> > [1] Attr {
> > attributes: {}
> > classes: {}
> > identifier: ""
> > }
> > [2] {}
> > }
> > head: {
> > [1] Attr {
> > attributes: {}
> > classes: {}
> > identifier: ""
> > }
> > [2] {
> > [1] {
> > [1] Attr {
> > attributes: {}
> > classes: {}
> > identifier: ""
> > }
> > [2] {
> > [1] {
> > col_span: 1
> > contents: {
> > [1] content: Plain {
> > [1] Str text: "Right"
> > }
> > }
> > alignment: "AlignDefault"
> > row_span: 1
> > attr: {
> > [1] ""
> > [2] {}
> > [3] {}
> > }
> > }
> > [2] {
> > col_span: 1
> > contents: {
> > [1] content: Plain {
> > [1] Str text: "Left"
> > }
> > }
> > alignment: "AlignDefault"
> > row_span: 1
> > attr: {
> > [1] ""
> > [2] {}
> > [3] {}
> > }
> > }
> > [3] {
> > col_span: 1
> > contents: {
> > [1] content: Plain {
> > [1] Str text: "Default"
> > }
> > }
> > alignment: "AlignDefault"
> > row_span: 1
> > attr: {
> > [1] ""
> > [2] {}
> > [3] {}
> > }
> > }
> > [4] {
> > col_span: 1
> > contents: {
> > [1] content: Plain {
> > [1] Str text: "Center"
> > }
> > }
> > alignment: "AlignDefault"
> > row_span: 1
> > attr: {
> > [1] ""
> > [2] {}
> > [3] {}
> > }
> > }
> > }
> > }
> > }
> > }
> > }
> > }
>
--
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/CAEe_xxiVFhQ8PqSq_37yhMm-8-Pnb2ZgY4eDkO7kdCZQt6bNkA%40mail.gmail.com.
[-- Attachment #2: Type: text/html, Size: 22193 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Printing lua tables
[not found] ` <CAEe_xxiVFhQ8PqSq_37yhMm-8-Pnb2ZgY4eDkO7kdCZQt6bNkA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2022-06-07 15:24 ` William Lupton
[not found] ` <CAEe_xxjopWC0y3Nk-ZrHSWDoAAj71szfHhivi=c42zK_aFpZ4Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: William Lupton @ 2022-06-07 15:24 UTC (permalink / raw)
To: John MacFarlane; +Cc: pandoc-discuss
[-- Attachment #1.1: Type: text/plain, Size: 3577 bytes --]
All,
I've split this out into two functions (each currently in its own [attached
as .lua.txt] file):
- dump(value, maxlen=70) that returns a possibly multi-line string
representation of a value
- output(...) that's a utility function that outputs space-separated
arguments, each passed to dump() and with a terminating newline if needed
Here's an updated example filter (it uses output() and doesn't call dump()
directly):
local output = require 'output'
function Pandoc(doc)
output('meta', doc.meta)
output('blocks', doc.blocks)
end
Please feel free to do whatever you like with these functions.
In my environment I have an additional layer in which I derive a log-level
from PANDOC_STATE.{trace,verbosity} and use this in a set of logging
functions like this one (*please let me know if you'd like me to supply
these too*):
function error(...)
if logLevel >= -1 then
output('(E)', ...)
end
end
Cheers,
William
On Tue, 7 Jun 2022 at 15:13, William Lupton <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org>
wrote:
> I'll need to extract the reporting functions. I'll do that soon, and post
> the result. This is currently working in pandoc 2.16.1 (and earlier). I
> haven't yet bitten the bullet of the move to 2.18.
>
> On Tue, 7 Jun 2022 at 14:55, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:
>
>>
>> That looks nice. Can you share your utils.lua?
>>
>> William Lupton <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org> writes:
>>
>> > I think I've mentioned this before... but I'd be happy to contribute
>> (in a
>> > suitable form) the somewhat-pandoc-aware utility that I use for this.
>> >
>> > Given this input:
>> >
>> > *% *cat doc.md
>> >
>> > ---
>> >
>> > a: 1
>> >
>> > b: |
>> >
>> > 2 3 4
>> >
>> > ---
>> >
>> >
>> > # Header
>> >
>> >
>> > This is a sentence (and a paragraph).
>> >
>> >
>> > * This is a list item
>> >
>> > * And another
>> >
>> >
>> > | Right | Left | Default | Center |
>> >
>> > |------:|:-----|---------|:------:|
>> >
>> > | 12 | 12 | 12 | 12 |
>> >
>> > | 123 | 123 | 123 | 123 |
>> >
>> > | 1 | 1 | 1 | 1 |
>> >
>> >
>> > : Demonstration of pipe table syntax.
>> >
>> > and this filter:
>> >
>> > *% *cat rep.lua
>> >
>> > local utils = require 'utils'
>> >
>> >
>> > -- do it this way to avoid reporting MetaBlocks twice
>> >
>> > function Pandoc(doc)
>> >
>> > utils.temp('meta', doc.meta)
>> >
>> > utils.temp('blocks', doc.blocks)
>> >
>> > end
>> >
>> > this command:
>> >
>> > pandoc doc.md -L rep.lua >/dev/null 2>doc.txt
>> >
>> > generates the attached.
>> >
>> > On Tue, 7 Jun 2022 at 08:57, <denis.maier-NSENcxR/0n0@public.gmane.org> wrote:
>> >
>> >> Hi,
>> >>
>> >> When playing around with filters I use pprint.lua or inspect.lua to
>> >> visualize lua tables. Would it make sense to include some sort of
>> «print
>> >> the contents of this table» to pandoc ?
>> >>
>> >> Best,
>> >>
>> >> Denis
>> >>
>> >> --
>>
>
--
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/CAEe_xxjopWC0y3Nk-ZrHSWDoAAj71szfHhivi%3Dc42zK_aFpZ4Q%40mail.gmail.com.
[-- Attachment #1.2: Type: text/html, Size: 5605 bytes --]
[-- Attachment #2: output.lua.txt --]
[-- Type: text/plain, Size: 555 bytes --]
-- output() outputs to stderr
local dump = require 'dump'
local function output(...)
local need_newline = false
for i, item in ipairs({...}) do
-- XXX space logic could be cleverer, e.g. no space after newline
local maybe_space = i > 1 and ' ' or ''
local text = ({table=1, userdata=1})[type(item)] and
dump(item) or tostring(item)
io.stderr:write(maybe_space, text)
need_newline = text:sub(-1) ~= '\n'
end
if need_newline then
io.stderr:write('\n')
end
end
return output
[-- Attachment #3: dump.lua.txt --]
[-- Type: text/plain, Size: 3734 bytes --]
-- pandoc-aware object dumper
-- helper function to return a sensible typename
-- XXX is there a better way of doing this? using metatables?
local function getTypename(value)
local typ = type(value)
if typ == 'table' and value.tag and value.t then
return value.tag
elseif typ == 'userdata' then
if value.tag and value.t then
return value.tag
else
-- e.g., Attributes is userdata but doesn't have tag and t
return typ
end
else
return typ
end
end
-- helper function
-- note: don't use anything from the pandoc module (so can test standalone)
-- XXX should detect repetition/recursion
-- XXX would like maxlen logic to apply at all levels? but not trivial
local function helper(prefix, value, maxlen, level, add)
local buffer = {}
if prefix == nil then prefix = '' end
if level == nil then level = 0 end
if add == nil then add = function(item) table.insert(buffer, item) end end
local indent = maxlen and '' or (' '):rep(level)
local typename = getTypename(value)
local typ = (({boolean=1, number=1, string=1, table=1, userdata=1})
[typename] and '' or typename)
if ({table=1, userdata=1})[type(value)] then
local numKeys, lastKey = 0, nil
for key, val in pairs(value) do
-- pandoc >= 2.15 includes 'tag', nil values and functions
if key ~= 'tag' and val and type(val) ~= 'function' then
numKeys = numKeys + 1
lastKey = key
end
end
if numKeys == 0 then
-- XXX this wouldn't be needed with proper maxlen handling
value = '{}'
elseif numKeys == 1 and lastKey == 'content' then
typ = string.format('content: %s', typ)
value = value.content
elseif numKeys == 1 and lastKey == 'text' and typename == 'Str' then
typename = 'string'
typ = 'Str text:'
value = value.text
end
end
local presep = #prefix > 0 and ' ' or ''
local typsep = #typ > 0 and ' ' or ''
local valtyp = type(value)
if ({boolean=1, number=1, string=1})[valtyp] then
local fmt = typename == 'string' and '%q' or '%s'
add(string.format('%s%s%s%s%s' .. fmt, indent, prefix, presep,
typ, typsep, value))
elseif ({table=1, userdata=1})[valtyp] then
add(string.format('%s%s%s%s%s{', indent, prefix, presep, typ, typsep))
-- Attr and Attr.attributes have both numeric and string keys, so
-- ignore the numeric ones (no longer the case for pandoc >= 2.15?)
if prefix ~= 'attributes:' and typ ~= 'Attr' then
for i, val in ipairs(value) do
local pre = maxlen and i > 1 and ', ' or ''
local text = helper(string.format('%s[%s]', pre, i), val,
maxlen, level + 1, add)
end
end
local first = true
for key, val in pairs(value) do
-- pandoc >= 2.15 includes 'tag'
if not tonumber(key) and key ~= 'tag' then
local pre = maxlen and not first and ', ' or ''
local text = helper(string.format('%s%s:', pre, key), val,
maxlen, level + 1, add)
end
first = false
end
add(string.format('%s}', indent))
end
return table.concat(buffer, maxlen and '' or '\n')
end
local function dump(value, maxlen)
if maxlen == nil then maxlen = 70 end
local text = helper(nil, value, maxlen)
if #text > maxlen then
text = helper(nil, value, nil)
end
return text
end
return dump
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Printing lua tables
[not found] ` <CAEe_xxjopWC0y3Nk-ZrHSWDoAAj71szfHhivi=c42zK_aFpZ4Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2022-06-23 12:25 ` William Lupton
[not found] ` <CAEe_xxhcoCqPPYx5Ob-ZT083vTx9wDbnBg+8-cVGnhExLFnXXw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: William Lupton @ 2022-06-23 12:25 UTC (permalink / raw)
To: pandoc-discuss
[-- Attachment #1: Type: text/plain, Size: 3939 bytes --]
I've created https://github.com/jgm/pandoc/issues/8146 to continue this
discussion.
On Tue, 7 Jun 2022 at 16:24, William Lupton <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org>
wrote:
> All,
>
> I've split this out into two functions (each currently in its own
> [attached as .lua.txt] file):
>
> - dump(value, maxlen=70) that returns a possibly multi-line string
> representation of a value
> - output(...) that's a utility function that outputs space-separated
> arguments, each passed to dump() and with a terminating newline if needed
>
> Here's an updated example filter (it uses output() and doesn't call dump()
> directly):
>
> local output = require 'output'
> function Pandoc(doc)
> output('meta', doc.meta)
> output('blocks', doc.blocks)
> end
>
> Please feel free to do whatever you like with these functions.
>
> In my environment I have an additional layer in which I derive a log-level
> from PANDOC_STATE.{trace,verbosity} and use this in a set of logging
> functions like this one (*please let me know if you'd like me to supply
> these too*):
>
> function error(...)
> if logLevel >= -1 then
> output('(E)', ...)
> end
> end
>
> Cheers,
> William
>
> On Tue, 7 Jun 2022 at 15:13, William Lupton <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org>
> wrote:
>
>> I'll need to extract the reporting functions. I'll do that soon, and post
>> the result. This is currently working in pandoc 2.16.1 (and earlier). I
>> haven't yet bitten the bullet of the move to 2.18.
>>
>> On Tue, 7 Jun 2022 at 14:55, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:
>>
>>>
>>> That looks nice. Can you share your utils.lua?
>>>
>>> William Lupton <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org> writes:
>>>
>>> > I think I've mentioned this before... but I'd be happy to contribute
>>> (in a
>>> > suitable form) the somewhat-pandoc-aware utility that I use for this.
>>> >
>>> > Given this input:
>>> >
>>> > *% *cat doc.md
>>> >
>>> > ---
>>> >
>>> > a: 1
>>> >
>>> > b: |
>>> >
>>> > 2 3 4
>>> >
>>> > ---
>>> >
>>> >
>>> > # Header
>>> >
>>> >
>>> > This is a sentence (and a paragraph).
>>> >
>>> >
>>> > * This is a list item
>>> >
>>> > * And another
>>> >
>>> >
>>> > | Right | Left | Default | Center |
>>> >
>>> > |------:|:-----|---------|:------:|
>>> >
>>> > | 12 | 12 | 12 | 12 |
>>> >
>>> > | 123 | 123 | 123 | 123 |
>>> >
>>> > | 1 | 1 | 1 | 1 |
>>> >
>>> >
>>> > : Demonstration of pipe table syntax.
>>> >
>>> > and this filter:
>>> >
>>> > *% *cat rep.lua
>>> >
>>> > local utils = require 'utils'
>>> >
>>> >
>>> > -- do it this way to avoid reporting MetaBlocks twice
>>> >
>>> > function Pandoc(doc)
>>> >
>>> > utils.temp('meta', doc.meta)
>>> >
>>> > utils.temp('blocks', doc.blocks)
>>> >
>>> > end
>>> >
>>> > this command:
>>> >
>>> > pandoc doc.md -L rep.lua >/dev/null 2>doc.txt
>>> >
>>> > generates the attached.
>>> >
>>> > On Tue, 7 Jun 2022 at 08:57, <denis.maier-NSENcxR/0n0@public.gmane.org> wrote:
>>> >
>>> >> Hi,
>>> >>
>>> >> When playing around with filters I use pprint.lua or inspect.lua to
>>> >> visualize lua tables. Would it make sense to include some sort of
>>> «print
>>> >> the contents of this table» to pandoc ?
>>> >>
>>> >> Best,
>>> >>
>>> >> Denis
>>> >>
>>> >> --
>>>
>>
--
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/CAEe_xxhcoCqPPYx5Ob-ZT083vTx9wDbnBg%2B8-cVGnhExLFnXXw%40mail.gmail.com.
[-- Attachment #2: Type: text/html, Size: 6226 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Printing lua tables
[not found] ` <CAEe_xxhcoCqPPYx5Ob-ZT083vTx9wDbnBg+8-cVGnhExLFnXXw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2022-07-18 8:46 ` William Lupton
0 siblings, 0 replies; 7+ messages in thread
From: William Lupton @ 2022-07-18 8:46 UTC (permalink / raw)
To: pandoc-discuss
[-- Attachment #1: Type: text/plain, Size: 4695 bytes --]
All,
Here's a shameless plug to let everyone know that these pandoc-aware
logging functions are now available at
https://github.com/wlupton/pandoc-lua-logging and will soon be referenced
from https://pandoc.org/lua-filters.html#debugging-lua-filters.
Things have moved on a bit since I sent the message below. Please do take a
look; I hope that people will find them useful. All feedback is welcome.
Thanks,
William
PS, These functions work with (at least) pandoc 2.16.1 and 2.18.
On Thu, 23 Jun 2022 at 13:25, William Lupton <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org>
wrote:
> I've created https://github.com/jgm/pandoc/issues/8146 to continue this
> discussion.
>
> On Tue, 7 Jun 2022 at 16:24, William Lupton <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org>
> wrote:
>
>> All,
>>
>> I've split this out into two functions (each currently in its own
>> [attached as .lua.txt] file):
>>
>> - dump(value, maxlen=70) that returns a possibly multi-line string
>> representation of a value
>> - output(...) that's a utility function that outputs space-separated
>> arguments, each passed to dump() and with a terminating newline if needed
>>
>> Here's an updated example filter (it uses output() and doesn't call
>> dump() directly):
>>
>> local output = require 'output'
>> function Pandoc(doc)
>> output('meta', doc.meta)
>> output('blocks', doc.blocks)
>> end
>>
>> Please feel free to do whatever you like with these functions.
>>
>> In my environment I have an additional layer in which I derive a
>> log-level from PANDOC_STATE.{trace,verbosity} and use this in a set of
>> logging functions like this one (*please let me know if you'd like me to
>> supply these too*):
>>
>> function error(...)
>> if logLevel >= -1 then
>> output('(E)', ...)
>> end
>> end
>>
>> Cheers,
>> William
>>
>> On Tue, 7 Jun 2022 at 15:13, William Lupton <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org>
>> wrote:
>>
>>> I'll need to extract the reporting functions. I'll do that soon, and
>>> post the result. This is currently working in pandoc 2.16.1 (and earlier).
>>> I haven't yet bitten the bullet of the move to 2.18.
>>>
>>> On Tue, 7 Jun 2022 at 14:55, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:
>>>
>>>>
>>>> That looks nice. Can you share your utils.lua?
>>>>
>>>> William Lupton <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org> writes:
>>>>
>>>> > I think I've mentioned this before... but I'd be happy to contribute
>>>> (in a
>>>> > suitable form) the somewhat-pandoc-aware utility that I use for this.
>>>> >
>>>> > Given this input:
>>>> >
>>>> > *% *cat doc.md
>>>> >
>>>> > ---
>>>> >
>>>> > a: 1
>>>> >
>>>> > b: |
>>>> >
>>>> > 2 3 4
>>>> >
>>>> > ---
>>>> >
>>>> >
>>>> > # Header
>>>> >
>>>> >
>>>> > This is a sentence (and a paragraph).
>>>> >
>>>> >
>>>> > * This is a list item
>>>> >
>>>> > * And another
>>>> >
>>>> >
>>>> > | Right | Left | Default | Center |
>>>> >
>>>> > |------:|:-----|---------|:------:|
>>>> >
>>>> > | 12 | 12 | 12 | 12 |
>>>> >
>>>> > | 123 | 123 | 123 | 123 |
>>>> >
>>>> > | 1 | 1 | 1 | 1 |
>>>> >
>>>> >
>>>> > : Demonstration of pipe table syntax.
>>>> >
>>>> > and this filter:
>>>> >
>>>> > *% *cat rep.lua
>>>> >
>>>> > local utils = require 'utils'
>>>> >
>>>> >
>>>> > -- do it this way to avoid reporting MetaBlocks twice
>>>> >
>>>> > function Pandoc(doc)
>>>> >
>>>> > utils.temp('meta', doc.meta)
>>>> >
>>>> > utils.temp('blocks', doc.blocks)
>>>> >
>>>> > end
>>>> >
>>>> > this command:
>>>> >
>>>> > pandoc doc.md -L rep.lua >/dev/null 2>doc.txt
>>>> >
>>>> > generates the attached.
>>>> >
>>>> > On Tue, 7 Jun 2022 at 08:57, <denis.maier-NSENcxR/0n0@public.gmane.org> wrote:
>>>> >
>>>> >> Hi,
>>>> >>
>>>> >> When playing around with filters I use pprint.lua or inspect.lua to
>>>> >> visualize lua tables. Would it make sense to include some sort of
>>>> «print
>>>> >> the contents of this table» to pandoc ?
>>>> >>
>>>> >> Best,
>>>> >>
>>>> >> Denis
>>>> >>
>>>> >> --
>>>>
>>>
--
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/CAEe_xxhWAxdJJ5LYj0QXoLTfUSpREBqDwxiUfPFoMB8GQNrdJA%40mail.gmail.com.
[-- Attachment #2: Type: text/html, Size: 7367 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-07-18 8:46 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-07 7:57 Printing lua tables denis.maier-NSENcxR/0n0
[not found] ` <551a3f2a8d364717bcc569baa974573a-NSENcxR/0n0@public.gmane.org>
2022-06-07 10:44 ` William Lupton
[not found] ` <CAEe_xxiL81rUdVtCeKovjYeo=KaKP1GAbwEiM6_9byZY8t_XvA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-06-07 13:55 ` John MacFarlane
[not found] ` <m2y1y8fuij.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2022-06-07 14:13 ` William Lupton
[not found] ` <CAEe_xxiVFhQ8PqSq_37yhMm-8-Pnb2ZgY4eDkO7kdCZQt6bNkA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-06-07 15:24 ` William Lupton
[not found] ` <CAEe_xxjopWC0y3Nk-ZrHSWDoAAj71szfHhivi=c42zK_aFpZ4Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-06-23 12:25 ` William Lupton
[not found] ` <CAEe_xxhcoCqPPYx5Ob-ZT083vTx9wDbnBg+8-cVGnhExLFnXXw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-07-18 8:46 ` William Lupton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).