* filename variable @ 2022-07-25 8:10 'juh' via pandoc-discuss 2022-07-25 8:43 ` William Lupton 2022-07-25 15:56 ` John MacFarlane 0 siblings, 2 replies; 8+ messages in thread From: 'juh' via pandoc-discuss @ 2022-07-25 8:10 UTC (permalink / raw) To: Pandoc Mailinglist [-- Attachment #1: Type: text/plain, Size: 647 bytes --] Hi all, this is a very silly question but I don't find the answer in the documentation. Is there a filename variable that can be accessed in the templates? I have two output files: html and pdf. Can I do something like this in the output html? <a href="$filename$.pdf">Download as PDF</a> I know that I can set a metadata variable in the yaml part of the input file, but I would like to avoid manual setting. juh -- Autoren-Homepage: ......... http://literatur.hasecke.com Satiren & Essays: ......... http://www.sudelbuch.de Privater Blog: ............ http://www.hasecke.eu Netzliteratur-Projekt: .... http://www.generationenprojekt.de ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: filename variable 2022-07-25 8:10 filename variable 'juh' via pandoc-discuss @ 2022-07-25 8:43 ` William Lupton [not found] ` <CAEe_xxjZ8wNK068AP-gtieFKk+5iD1b4BLJ7iS6WuG8o-667tA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2022-07-25 15:56 ` John MacFarlane 1 sibling, 1 reply; 8+ messages in thread From: William Lupton @ 2022-07-25 8:43 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1: Type: text/plain, Size: 1856 bytes --] I'm not sure if there's an existing template variable for this (I don't see one) but I think that this lua filter will work: function Pandoc(pandoc) pandoc.meta.output_file = PANDOC_STATE.output_file return pandoc end On Mon, 25 Jul 2022 at 09:11, 'juh' via pandoc-discuss < pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> wrote: > Hi all, > > this is a very silly question but I don't find the answer in the > documentation. > > Is there a filename variable that can be accessed in the templates? > > I have two output files: html and pdf. > > Can I do something like this in the output html? > > <a href="$filename$.pdf">Download as PDF</a> > > I know that I can set a metadata variable in the yaml part of the input > file, but I would like to avoid manual setting. > > juh > > -- > Autoren-Homepage: ......... http://literatur.hasecke.com > Satiren & Essays: ......... http://www.sudelbuch.de > Privater Blog: ............ http://www.hasecke.eu > Netzliteratur-Projekt: .... http://www.generationenprojekt.de > > > -- > 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/Yt5QDs//8XSpI776%40odysseus > . > -- 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_xxjZ8wNK068AP-gtieFKk%2B5iD1b4BLJ7iS6WuG8o-667tA%40mail.gmail.com. [-- Attachment #2: Type: text/html, Size: 3155 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <CAEe_xxjZ8wNK068AP-gtieFKk+5iD1b4BLJ7iS6WuG8o-667tA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: filename variable [not found] ` <CAEe_xxjZ8wNK068AP-gtieFKk+5iD1b4BLJ7iS6WuG8o-667tA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2022-07-25 12:33 ` 'Jan Ulrich Hasecke' via pandoc-discuss [not found] ` <e0252aa7-3e87-6381-a1a9-4f67acf7fbce-cl+VPiYnx/1AfugRpC6u6w@public.gmane.org> 0 siblings, 1 reply; 8+ messages in thread From: 'Jan Ulrich Hasecke' via pandoc-discuss @ 2022-07-25 12:33 UTC (permalink / raw) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw Am 25.07.22 um 10:43 schrieb William Lupton: > function Pandoc(pandoc) > pandoc.meta.output_file = PANDOC_STATE.output_file > return pandoc > end Thanks a lot. I tried to strip the extension like this: function Pandoc(pandoc) pandoc.meta.output_file = PANDOC_STATE.output_file:sub(0, - 5) return pandoc end But this only works with a three character extension. I guess it should be easy to strip everything after the colon with regexp, if one is not a regexp illiterate like me. juh -- 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/e0252aa7-3e87-6381-a1a9-4f67acf7fbce%40mailbox.org. ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <e0252aa7-3e87-6381-a1a9-4f67acf7fbce-cl+VPiYnx/1AfugRpC6u6w@public.gmane.org>]
* Re: filename variable [not found] ` <e0252aa7-3e87-6381-a1a9-4f67acf7fbce-cl+VPiYnx/1AfugRpC6u6w@public.gmane.org> @ 2022-07-25 12:55 ` William Lupton [not found] ` <CAEe_xxjdkVBoGTUXRPUgnGXEYAf0JZbAabEWjr=wNGq6joD4wg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 8+ messages in thread From: William Lupton @ 2022-07-25 12:55 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1: Type: text/plain, Size: 1593 bytes --] something like this perhaps? local name = file:gsub('%.[a-z]*$', '') On Mon, 25 Jul 2022 at 13:33, 'Jan Ulrich Hasecke' via pandoc-discuss < pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> wrote: > Am 25.07.22 um 10:43 schrieb William Lupton: > > function Pandoc(pandoc) > > pandoc.meta.output_file = PANDOC_STATE.output_file > > return pandoc > > end > > Thanks a lot. > > I tried to strip the extension like this: > > function Pandoc(pandoc) > pandoc.meta.output_file = PANDOC_STATE.output_file:sub(0, - 5) > return pandoc > end > > But this only works with a three character extension. > > I guess it should be easy to strip everything after the colon with > regexp, if one is not a regexp illiterate like me. > > juh > > -- > 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/e0252aa7-3e87-6381-a1a9-4f67acf7fbce%40mailbox.org > . > -- 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_xxjdkVBoGTUXRPUgnGXEYAf0JZbAabEWjr%3DwNGq6joD4wg%40mail.gmail.com. [-- Attachment #2: Type: text/html, Size: 2606 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <CAEe_xxjdkVBoGTUXRPUgnGXEYAf0JZbAabEWjr=wNGq6joD4wg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: filename variable [not found] ` <CAEe_xxjdkVBoGTUXRPUgnGXEYAf0JZbAabEWjr=wNGq6joD4wg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2022-07-25 12:57 ` William Lupton [not found] ` <CAEe_xxgM8dPsst5ceKWDfhb0BrR4gNVHC+=ZFTatRHtqrfiG3Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 8+ messages in thread From: William Lupton @ 2022-07-25 12:57 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1: Type: text/plain, Size: 1925 bytes --] (perhaps also allow digits in the extension, or anything other than dots) but no there's a better way; see https://pandoc.org/lua-filters.html#pandoc.path.split_extension On Mon, 25 Jul 2022 at 13:55, William Lupton <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org> wrote: > something like this perhaps? > > local name = file:gsub('%.[a-z]*$', '') > > On Mon, 25 Jul 2022 at 13:33, 'Jan Ulrich Hasecke' via pandoc-discuss < > pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> wrote: > >> Am 25.07.22 um 10:43 schrieb William Lupton: >> > function Pandoc(pandoc) >> > pandoc.meta.output_file = PANDOC_STATE.output_file >> > return pandoc >> > end >> >> Thanks a lot. >> >> I tried to strip the extension like this: >> >> function Pandoc(pandoc) >> pandoc.meta.output_file = PANDOC_STATE.output_file:sub(0, - 5) >> return pandoc >> end >> >> But this only works with a three character extension. >> >> I guess it should be easy to strip everything after the colon with >> regexp, if one is not a regexp illiterate like me. >> >> juh >> >> -- >> 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/e0252aa7-3e87-6381-a1a9-4f67acf7fbce%40mailbox.org >> . >> > -- 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_xxgM8dPsst5ceKWDfhb0BrR4gNVHC%2B%3DZFTatRHtqrfiG3Q%40mail.gmail.com. [-- Attachment #2: Type: text/html, Size: 3283 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <CAEe_xxgM8dPsst5ceKWDfhb0BrR4gNVHC+=ZFTatRHtqrfiG3Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: filename variable [not found] ` <CAEe_xxgM8dPsst5ceKWDfhb0BrR4gNVHC+=ZFTatRHtqrfiG3Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2022-07-25 15:05 ` 'Jan Ulrich Hasecke' via pandoc-discuss 0 siblings, 0 replies; 8+ messages in thread From: 'Jan Ulrich Hasecke' via pandoc-discuss @ 2022-07-25 15:05 UTC (permalink / raw) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw Dear William, Am 25.07.22 um 14:57 schrieb William Lupton: > (perhaps also allow digits in the extension, or anything other than dots) thanks a lot for this code snippet. It works. > but no there's a better way; see > https://pandoc.org/lua-filters.html#pandoc.path.split_extension > <https://pandoc.org/lua-filters.html#pandoc.path.split_extension> I found this in the documentation but cannot apply this. I'll dig deeper into Lua. juh ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: filename variable 2022-07-25 8:10 filename variable 'juh' via pandoc-discuss 2022-07-25 8:43 ` William Lupton @ 2022-07-25 15:56 ` John MacFarlane [not found] ` <BC4CAE33-E18F-405C-A6E5-C13D04542B3C-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 1 sibling, 1 reply; 8+ messages in thread From: John MacFarlane @ 2022-07-25 15:56 UTC (permalink / raw) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw The outputfile variable is set automatically and you can use it in your template. However, you can't substitute the extension in the template itself; for that you need a filter. > On Jul 25, 2022, at 1:10 AM, 'juh' via pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> wrote: > > Hi all, > > this is a very silly question but I don't find the answer in the > documentation. > > Is there a filename variable that can be accessed in the templates? > > I have two output files: html and pdf. > > Can I do something like this in the output html? > > <a href="$filename$.pdf">Download as PDF</a> > > I know that I can set a metadata variable in the yaml part of the input > file, but I would like to avoid manual setting. > > juh > > -- > Autoren-Homepage: ......... http://literatur.hasecke.com > Satiren & Essays: ......... http://www.sudelbuch.de > Privater Blog: ............ http://www.hasecke.eu > Netzliteratur-Projekt: .... http://www.generationenprojekt.de > > > -- > 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/Yt5QDs//8XSpI776%40odysseus. ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <BC4CAE33-E18F-405C-A6E5-C13D04542B3C-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: filename variable [not found] ` <BC4CAE33-E18F-405C-A6E5-C13D04542B3C-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2022-07-25 16:43 ` William Lupton 0 siblings, 0 replies; 8+ messages in thread From: William Lupton @ 2022-07-25 16:43 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1: Type: text/plain, Size: 2491 bytes --] Sorry, I missed that! For some reason I only searched for output-file. On Mon, 25 Jul 2022 at 16:57, John MacFarlane <fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > The outputfile variable is set automatically and you can use it in your > template. > > However, you can't substitute the extension in the template itself; for > that you need a filter. > > > > On Jul 25, 2022, at 1:10 AM, 'juh' via pandoc-discuss < > pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> wrote: > > > > Hi all, > > > > this is a very silly question but I don't find the answer in the > > documentation. > > > > Is there a filename variable that can be accessed in the templates? > > > > I have two output files: html and pdf. > > > > Can I do something like this in the output html? > > > > <a href="$filename$.pdf">Download as PDF</a> > > > > I know that I can set a metadata variable in the yaml part of the input > > file, but I would like to avoid manual setting. > > > > juh > > > > -- > > Autoren-Homepage: ......... http://literatur.hasecke.com > > Satiren & Essays: ......... http://www.sudelbuch.de > > Privater Blog: ............ http://www.hasecke.eu > > Netzliteratur-Projekt: .... http://www.generationenprojekt.de > > > > > > -- > > 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/Yt5QDs//8XSpI776%40odysseus > . > > -- > 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/BC4CAE33-E18F-405C-A6E5-C13D04542B3C%40gmail.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/CAEe_xxg6FL3rtguoR0bpvW%2BtpxoCm7JufFqJtdEoUYHqiEDhHw%40mail.gmail.com. [-- Attachment #2: Type: text/html, Size: 4229 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-07-25 16:43 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-07-25 8:10 filename variable 'juh' via pandoc-discuss 2022-07-25 8:43 ` William Lupton [not found] ` <CAEe_xxjZ8wNK068AP-gtieFKk+5iD1b4BLJ7iS6WuG8o-667tA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2022-07-25 12:33 ` 'Jan Ulrich Hasecke' via pandoc-discuss [not found] ` <e0252aa7-3e87-6381-a1a9-4f67acf7fbce-cl+VPiYnx/1AfugRpC6u6w@public.gmane.org> 2022-07-25 12:55 ` William Lupton [not found] ` <CAEe_xxjdkVBoGTUXRPUgnGXEYAf0JZbAabEWjr=wNGq6joD4wg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2022-07-25 12:57 ` William Lupton [not found] ` <CAEe_xxgM8dPsst5ceKWDfhb0BrR4gNVHC+=ZFTatRHtqrfiG3Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2022-07-25 15:05 ` 'Jan Ulrich Hasecke' via pandoc-discuss 2022-07-25 15:56 ` John MacFarlane [not found] ` <BC4CAE33-E18F-405C-A6E5-C13D04542B3C-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2022-07-25 16:43 ` 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).