* Overriding default writer behavior @ 2022-03-24 11:00 AustinLe [not found] ` <3aa35ec0-4912-4fd7-9e11-8a78296f9da4n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: AustinLe @ 2022-03-24 11:00 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1.1: Type: text/plain, Size: 1302 bytes --] I've been searching for a few days and as I could find what I wanted, I'd like to confirm if my conclusion is correct. In particular, I'd like to overwrite a small writer behavior, e.g. the Cite tag of the default HTML writer, by adding an extra field in the tag. I'm checking the custom writer tag and it seems like I have to re-write the whole writer for all AST elements, and not just replacing `function Cite` in the `sample.lua` with what I needed. This seems to be quite a hassle as the provided `sample.lua` doesn't produce the same document as the default HTML writer does (missing table of content, math formulas aren't rendered, question about that here <https://groups.google.com/g/pandoc-discuss/c/3x6N8uP5ZM8> ). Is it correct that I have to provide the writer for the all AST elements, or am I missing something and we can actually override just a function only? -- 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/3aa35ec0-4912-4fd7-9e11-8a78296f9da4n%40googlegroups.com. [-- Attachment #1.2: Type: text/html, Size: 1692 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <3aa35ec0-4912-4fd7-9e11-8a78296f9da4n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>]
* Re: Overriding default writer behavior [not found] ` <3aa35ec0-4912-4fd7-9e11-8a78296f9da4n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> @ 2022-03-24 13:44 ` BPJ 2022-03-24 18:33 ` John MacFarlane 1 sibling, 0 replies; 6+ messages in thread From: BPJ @ 2022-03-24 13:44 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1: Type: text/plain, Size: 3514 bytes --] Since it's Cite maybe you would be better of modifying a CSL style? As for the general case what I did was creating a filter which totally ate the builtin writer's brains for selected elements by replacing them with a crafted mixture of pieces of the content of the original element and RawInline/RawBlock elements which contained the desired target markup. (I even wrote a "filter" which turned the output of the plain writer into an unsupported markup language long before there were custom writers!) I ended up with the occasional ghost span/div just to hold content though. I suppose you could go through the hassle of using `pandoc.write` on snippets, remove excess markup with Lua's string functions and splice them into one big RawBlock/RawInline, but it's hardly worth it. Perhaps a set of "example" custom writers which behave like the default writers as nearly as possible which people could modify could be set up. I would gladly contribute if there is a middle ground between reading the Haskell code (which I can't) and just deducing from output in the various formats. Perhaps deducing from test cases so that one knows what to go after. Note that filters can do multiple passes, and that you can run "local" filters on the children of individual elements with the `walk` functions, which is very useful. Or do the Haskell writers work in such a way that keyhole surgery via Lua functions is possible or could reasonably be made possible? I suspect they were written without any hooks... Den tors 24 mars 2022 12:01AustinLe <lhoangan.nl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev: > I've been searching for a few days and as I could find what I wanted, I'd > like to confirm if my conclusion is correct. > > In particular, I'd like to overwrite a small writer behavior, e.g. the > Cite tag of the default HTML writer, by adding an extra field in the tag. > I'm checking the custom writer tag and it seems like I have to re-write the > whole writer for all AST elements, and not just replacing `function Cite` > in the `sample.lua` with what I needed. > > This seems to be quite a hassle as the provided `sample.lua` doesn't > produce the same document as the default HTML writer does (missing table of > content, math formulas aren't rendered, question about that here > <https://groups.google.com/g/pandoc-discuss/c/3x6N8uP5ZM8> ). > > Is it correct that I have to provide the writer for the all AST elements, > or am I missing something and we can actually override just a function only? > > -- > 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/3aa35ec0-4912-4fd7-9e11-8a78296f9da4n%40googlegroups.com > <https://groups.google.com/d/msgid/pandoc-discuss/3aa35ec0-4912-4fd7-9e11-8a78296f9da4n%40googlegroups.com?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/CADAJKhAkkoqQ4tuft197DH9TwkFLrtMgO9e88mMmTr8WmOYGsw%40mail.gmail.com. [-- Attachment #2: Type: text/html, Size: 4699 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Overriding default writer behavior [not found] ` <3aa35ec0-4912-4fd7-9e11-8a78296f9da4n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 2022-03-24 13:44 ` BPJ @ 2022-03-24 18:33 ` John MacFarlane [not found] ` <m235j7kxp2.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org> 1 sibling, 1 reply; 6+ messages in thread From: John MacFarlane @ 2022-03-24 18:33 UTC (permalink / raw) To: AustinLe, pandoc-discuss Indeed, it is quite a hassle. Actually, in the dev version @tarleb has created a new way of creating a writer, which will allow you to override just one function. It's not yet in a released version, but it is in the nightlies now. https://github.com/jgm/pandoc/commit/0f0b042139e3a82673590f14b70e5fcb5e57ea61 AustinLe <lhoangan.nl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: > I've been searching for a few days and as I could find what I wanted, I'd > like to confirm if my conclusion is correct. > > In particular, I'd like to overwrite a small writer behavior, e.g. the Cite > tag of the default HTML writer, by adding an extra field in the tag. I'm > checking the custom writer tag and it seems like I have to re-write the > whole writer for all AST elements, and not just replacing `function Cite` > in the `sample.lua` with what I needed. > > This seems to be quite a hassle as the provided `sample.lua` doesn't > produce the same document as the default HTML writer does (missing table of > content, math formulas aren't rendered, question about that here > <https://groups.google.com/g/pandoc-discuss/c/3x6N8uP5ZM8> ). > > Is it correct that I have to provide the writer for the all AST elements, > or am I missing something and we can actually override just a function only? > > -- > 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/3aa35ec0-4912-4fd7-9e11-8a78296f9da4n%40googlegroups.com. ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <m235j7kxp2.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>]
* Re: Overriding default writer behavior [not found] ` <m235j7kxp2.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org> @ 2022-03-24 19:28 ` Hoàng-Ân Lê [not found] ` <CAKY_PKvwyyt29JZhqKxjOG2Cyte9WBwqbWkEYJvvy4yHDmN+-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Hoàng-Ân Lê @ 2022-03-24 19:28 UTC (permalink / raw) To: John MacFarlane; +Cc: pandoc-discuss [-- Attachment #1: Type: text/plain, Size: 2469 bytes --] Sounds tempting, thanks for the updates. For the moment I started to think a simple lua-filter could be used as a post-processing step. On Thu, 24 Mar 2022 at 19:33, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote: > > Indeed, it is quite a hassle. > > Actually, in the dev version @tarleb has created a new way > of creating a writer, which will allow you to override just > one function. It's not yet in a released version, but it is > in the nightlies now. > > > https://github.com/jgm/pandoc/commit/0f0b042139e3a82673590f14b70e5fcb5e57ea61 > > > > AustinLe <lhoangan.nl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: > > > I've been searching for a few days and as I could find what I wanted, > I'd > > like to confirm if my conclusion is correct. > > > > In particular, I'd like to overwrite a small writer behavior, e.g. the > Cite > > tag of the default HTML writer, by adding an extra field in the tag. I'm > > checking the custom writer tag and it seems like I have to re-write the > > whole writer for all AST elements, and not just replacing `function > Cite` > > in the `sample.lua` with what I needed. > > > > This seems to be quite a hassle as the provided `sample.lua` doesn't > > produce the same document as the default HTML writer does (missing table > of > > content, math formulas aren't rendered, question about that here > > <https://groups.google.com/g/pandoc-discuss/c/3x6N8uP5ZM8> ). > > > > Is it correct that I have to provide the writer for the all AST > elements, > > or am I missing something and we can actually override just a function > only? > > > > -- > > 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/3aa35ec0-4912-4fd7-9e11-8a78296f9da4n%40googlegroups.com > . > -- 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/CAKY_PKvwyyt29JZhqKxjOG2Cyte9WBwqbWkEYJvvy4yHDmN%2B-g%40mail.gmail.com. [-- Attachment #2: Type: text/html, Size: 3892 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <CAKY_PKvwyyt29JZhqKxjOG2Cyte9WBwqbWkEYJvvy4yHDmN+-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: Overriding default writer behavior [not found] ` <CAKY_PKvwyyt29JZhqKxjOG2Cyte9WBwqbWkEYJvvy4yHDmN+-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2022-08-04 20:21 ` Sterling Hooten [not found] ` <49abfd29-599e-4055-bd0e-ba53468d6a54n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 0 siblings, 1 reply; 6+ messages in thread From: Sterling Hooten @ 2022-08-04 20:21 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1.1: Type: text/plain, Size: 3290 bytes --] Is there an example of this? (ie, replacing the behavior of just a single type of object). I'm trying to write web clipper for emacs org mode, and want a filter or writer which will replace the "file:" prefix in an org mode link with "attachment:" (and perhaps some org-id information). I've written a custom filter but this seems to still be passed to the org.hs writer which has no concept of "attachment". It seems like my options are either editing the org.hs file directly (and then compile from source?) or rewrite the *entire *writer in Lua. I'm a novice, but is there a way to alter types (like Image) to a different type so that the built-in org writer won't recognize them? On Thursday, March 24, 2022 at 3:29:10 PM UTC-4 AustinLe wrote: > Sounds tempting, thanks for the updates. > > For the moment I started to think a simple lua-filter could be used as a > post-processing step. > > > On Thu, 24 Mar 2022 at 19:33, John MacFarlane <j...-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote: > >> >> Indeed, it is quite a hassle. >> >> Actually, in the dev version @tarleb has created a new way >> of creating a writer, which will allow you to override just >> one function. It's not yet in a released version, but it is >> in the nightlies now. >> >> >> https://github.com/jgm/pandoc/commit/0f0b042139e3a82673590f14b70e5fcb5e57ea61 >> >> >> >> AustinLe <lhoan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: >> >> > I've been searching for a few days and as I could find what I wanted, >> I'd >> > like to confirm if my conclusion is correct. >> > >> > In particular, I'd like to overwrite a small writer behavior, e.g. the >> Cite >> > tag of the default HTML writer, by adding an extra field in the tag. >> I'm >> > checking the custom writer tag and it seems like I have to re-write the >> > whole writer for all AST elements, and not just replacing `function >> Cite` >> > in the `sample.lua` with what I needed. >> > >> > This seems to be quite a hassle as the provided `sample.lua` doesn't >> > produce the same document as the default HTML writer does (missing >> table of >> > content, math formulas aren't rendered, question about that here >> > <https://groups.google.com/g/pandoc-discuss/c/3x6N8uP5ZM8> ). >> > >> > Is it correct that I have to provide the writer for the all AST >> elements, >> > or am I missing something and we can actually override just a function >> only? >> > >> > -- >> > 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/pandoc-discuss/3aa35ec0-4912-4fd7-9e11-8a78296f9da4n%40googlegroups.com >> . >> > -- 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/49abfd29-599e-4055-bd0e-ba53468d6a54n%40googlegroups.com. [-- Attachment #1.2: Type: text/html, Size: 5477 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <49abfd29-599e-4055-bd0e-ba53468d6a54n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>]
* Re: Overriding default writer behavior [not found] ` <49abfd29-599e-4055-bd0e-ba53468d6a54n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> @ 2022-08-04 20:24 ` Sukil Etxenike arizaleta 0 siblings, 0 replies; 6+ messages in thread From: Sukil Etxenike arizaleta @ 2022-08-04 20:24 UTC (permalink / raw) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw [-- Attachment #1: Type: text/plain, Size: 4433 bytes --] There is one example in the writers' manual, see <https://pandoc.org/custom-writers.html#new-style> Hth, Sukil El 04/08/2022 a las 22:21, Sterling Hooten escribió: > Is there an example of this? (ie, replacing the behavior of just a > single type of object). > > I'm trying to write web clipper for emacs org mode, and want a filter > or writer which will replace the "file:" prefix in an org mode link > with "attachment:" (and perhaps some org-id information). > > I've written a custom filter but this seems to still be passed to the > org.hs writer which has no concept of "attachment". > > It seems like my options are either editing the org.hs file directly > (and then compile from source?) or rewrite the /entire /writer in Lua. > > I'm a novice, but is there a way to alter types (like Image) to a > different type so that the built-in org writer won't recognize them? > > On Thursday, March 24, 2022 at 3:29:10 PM UTC-4 AustinLe wrote: > > Sounds tempting, thanks for the updates. > > For the moment I started to think a simple lua-filter could be > used as a post-processing step. > > > On Thu, 24 Mar 2022 at 19:33, John MacFarlane <j...-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> > wrote: > > > Indeed, it is quite a hassle. > > Actually, in the dev version @tarleb has created a new way > of creating a writer, which will allow you to override just > one function. It's not yet in a released version, but it is > in the nightlies now. > > https://github.com/jgm/pandoc/commit/0f0b042139e3a82673590f14b70e5fcb5e57ea61 > > > > AustinLe <lhoan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: > > > I've been searching for a few days and as I could find what > I wanted, I'd > > like to confirm if my conclusion is correct. > > > > In particular, I'd like to overwrite a small writer > behavior, e.g. the Cite > > tag of the default HTML writer, by adding an extra field in > the tag. I'm > > checking the custom writer tag and it seems like I have to > re-write the > > whole writer for all AST elements, and not just replacing > `function Cite` > > in the `sample.lua` with what I needed. > > > > This seems to be quite a hassle as the provided > `sample.lua` doesn't > > produce the same document as the default HTML writer does > (missing table of > > content, math formulas aren't rendered, question about that > here > > <https://groups.google.com/g/pandoc-discuss/c/3x6N8uP5ZM8> ). > > > > Is it correct that I have to provide the writer for the all > AST elements, > > or am I missing something and we can actually override just > a function only? > > > > -- > > 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-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To view this discussion on the web visit > https://groups.google.com/d/msgid/pandoc-discuss/3aa35ec0-4912-4fd7-9e11-8a78296f9da4n%40googlegroups.com. > > -- > 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/49abfd29-599e-4055-bd0e-ba53468d6a54n%40googlegroups.com > <https://groups.google.com/d/msgid/pandoc-discuss/49abfd29-599e-4055-bd0e-ba53468d6a54n%40googlegroups.com?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/8aac07f5-1e1f-20f4-7832-28ebdb96fffb%40gmail.com. [-- Attachment #2: Type: text/html, Size: 8679 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-08-04 20:24 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-03-24 11:00 Overriding default writer behavior AustinLe [not found] ` <3aa35ec0-4912-4fd7-9e11-8a78296f9da4n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 2022-03-24 13:44 ` BPJ 2022-03-24 18:33 ` John MacFarlane [not found] ` <m235j7kxp2.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org> 2022-03-24 19:28 ` Hoàng-Ân Lê [not found] ` <CAKY_PKvwyyt29JZhqKxjOG2Cyte9WBwqbWkEYJvvy4yHDmN+-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2022-08-04 20:21 ` Sterling Hooten [not found] ` <49abfd29-599e-4055-bd0e-ba53468d6a54n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 2022-08-04 20:24 ` Sukil Etxenike arizaleta
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).