* Citeproc/Order of filters being called @ 2023-11-29 13:28 'Thomas J.' via pandoc-discuss [not found] ` <15e09292-83a1-4e28-ba84-d0c518be709dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: 'Thomas J.' via pandoc-discuss @ 2023-11-29 13:28 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1.1: Type: text/plain, Size: 1265 bytes --] Hi everyone, Since pandoc-fignos isn't working anymore (at least, with my Pandoc version), I have written a Lua filter that basically does what fignos does, namely replacing tags such as @fig:fig1 with anchors/refs to the figures in html/latex. Now, if I am trying to use this filter without citeproc, everthing works as expected. The moment I use --citeproc, I get the error message "fig:fig1 citation not found" and I have no link in my output file. I am actually calling the lua filter BEFORE --citeproc in the command line... pandoc --lua-filter=filter/pandoc-figref.lua --citeproc --number-sections --from markdown --template=templates/phimisci-1-5.html --bibliography= $BIBLIOGRAPHY --csl=csl/apa7-single-spaced.csl yaml/gen-metadata.yaml article/$1 article/$2 -o $HTMLFILE What am I missing? Thanks for the help! Best wishes, Thomas -- 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/15e09292-83a1-4e28-ba84-d0c518be709dn%40googlegroups.com. [-- Attachment #1.2: Type: text/html, Size: 2651 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <15e09292-83a1-4e28-ba84-d0c518be709dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>]
* Re: Citeproc/Order of filters being called [not found] ` <15e09292-83a1-4e28-ba84-d0c518be709dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> @ 2023-11-29 14:49 ` 'William Lupton' via pandoc-discuss [not found] ` <CAEe_xxid8YRTLJKC=8jvD2ps4a7YoQe=ZS3DMMt0VJ3d0e-04Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: 'William Lupton' via pandoc-discuss @ 2023-11-29 14:49 UTC (permalink / raw) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw [-- Attachment #1: Type: text/plain, Size: 2160 bytes --] From the information given, I think that the AST must still contain a fig:fig1 citation after your filter has run. Are you able to share your filter? On Wed, 29 Nov 2023 at 13:28, 'Thomas J.' via pandoc-discuss < pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> wrote: > Hi everyone, > > Since pandoc-fignos isn't working anymore (at least, with my Pandoc > version), I have written a Lua filter that basically does what fignos does, > namely replacing tags such as @fig:fig1 with anchors/refs to the figures in > html/latex. Now, if I am trying to use this filter without citeproc, > everthing works as expected. The moment I use --citeproc, I get the error > message "fig:fig1 citation not found" and I have no link in my output file. > I am actually calling the lua filter BEFORE --citeproc in the command > line... > > pandoc --lua-filter=filter/pandoc-figref.lua --citeproc --number-sections > --from markdown --template=templates/phimisci-1-5.html --bibliography= > $BIBLIOGRAPHY --csl=csl/apa7-single-spaced.csl yaml/gen-metadata.yaml > article/$1 article/$2 -o $HTMLFILE > > What am I missing? Thanks for the help! > > Best wishes, > Thomas > > -- > 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/15e09292-83a1-4e28-ba84-d0c518be709dn%40googlegroups.com > <https://groups.google.com/d/msgid/pandoc-discuss/15e09292-83a1-4e28-ba84-d0c518be709dn%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/CAEe_xxid8YRTLJKC%3D8jvD2ps4a7YoQe%3DZS3DMMt0VJ3d0e-04Q%40mail.gmail.com. [-- Attachment #2: Type: text/html, Size: 3943 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <CAEe_xxid8YRTLJKC=8jvD2ps4a7YoQe=ZS3DMMt0VJ3d0e-04Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: Citeproc/Order of filters being called [not found] ` <CAEe_xxid8YRTLJKC=8jvD2ps4a7YoQe=ZS3DMMt0VJ3d0e-04Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2023-11-29 18:29 ` 'Thomas J.' via pandoc-discuss [not found] ` <ee97eefb-cb70-4bf9-859c-e75448438894n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: 'Thomas J.' via pandoc-discuss @ 2023-11-29 18:29 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1.1: Type: text/plain, Size: 2701 bytes --] Thanks for the feedback! I simply was not aware of the fact that every @<WORD> string is apparently automatically converted into a Cite block in the AST, even without using citeproc (?). Anyhow, being aware of this fixed the problem. I've attached the filter, if someone is interested. It is still very raw and only for HTML (adding latex shouldnt be a huge problem though). Thanks again for the help! With best wishes, Thomas William Lupton schrieb am Mittwoch, 29. November 2023 um 15:49:45 UTC+1: > From the information given, I think that the AST must still contain a > fig:fig1 citation after your filter has run. Are you able to share your > filter? > > On Wed, 29 Nov 2023 at 13:28, 'Thomas J.' via pandoc-discuss < > pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> wrote: > >> Hi everyone, >> >> Since pandoc-fignos isn't working anymore (at least, with my Pandoc >> version), I have written a Lua filter that basically does what fignos does, >> namely replacing tags such as @fig:fig1 with anchors/refs to the figures in >> html/latex. Now, if I am trying to use this filter without citeproc, >> everthing works as expected. The moment I use --citeproc, I get the error >> message "fig:fig1 citation not found" and I have no link in my output file. >> I am actually calling the lua filter BEFORE --citeproc in the command >> line... >> >> pandoc --lua-filter=filter/pandoc-figref.lua --citeproc --number-sections >> --from markdown --template=templates/phimisci-1-5.html --bibliography= >> $BIBLIOGRAPHY --csl=csl/apa7-single-spaced.csl yaml/gen-metadata.yaml >> article/$1 article/$2 -o $HTMLFILE >> >> What am I missing? Thanks for the help! >> >> Best wishes, >> Thomas >> >> -- >> 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/15e09292-83a1-4e28-ba84-d0c518be709dn%40googlegroups.com >> <https://groups.google.com/d/msgid/pandoc-discuss/15e09292-83a1-4e28-ba84-d0c518be709dn%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/ee97eefb-cb70-4bf9-859c-e75448438894n%40googlegroups.com. [-- Attachment #1.2: Type: text/html, Size: 5083 bytes --] [-- Attachment #2: pandoc-figref.lua --] [-- Type: application/octet-stream, Size: 3894 bytes --] -- filter to reference images/figures in text -- inspired by pandoc-fignos (works with fignos @fig:<label> syntax) -- currently only conversion to PDF & HTML -- tested with Pandoc 3.1 -- written by Thomas Jurczyk -- GLOBAL VARIABLES -- table to store fig-refs found Figref_Table = {} -- counter for figure numbering Counter = 1 -- HELPER FUNCTIONS --- Function to add a Figure str pandoc.Inline Element to a pandoc.Caption -- @param caption The pandoc.Plain block from the figure.caption.long element. -- @return The new figure.caption.long.Plain block now starting with with 'Figure <NUMBER>: '. function addFigureTagToCaption(plain) -- add a "Figure <NUMBER>:" tag at the beginning of a caption table.insert(plain.content, 1, pandoc.Str("Figure")) table.insert(plain.content, 2, pandoc.Space()) table.insert(plain.content, 3, pandoc.Str(Counter .. ":")) table.insert(plain.content, 4 ,pandoc.Space()) return plain end --- Function to find the index of an element in a table. This function is used in setRefsToFigure(). -- @param element The element searched for in the table. -- @param table The table in which the element is searched for. -- @return (str|nil) The index as a STRING. nil if element has not been found. function findIndex(element, table) for index, entry in ipairs(table) do if entry == element then return tostring(index) end end return nil end ---Function to replace a string that matches a figure id with HTML/LaTeX links/refs. -- @param The plain string from Cite.citations[1].id -- @return (pandoc.RawInline|nil) function stringReplacementRef(word) if tableContains(Figref_Table, word) then local referenceNumber = findIndex(word, Figref_Table) if FORMAT:match "html" then return pandoc.RawInline('html', '<a href="#'..word..'">'..referenceNumber..'</a>') --TODO: add LaTeX reference end else return nil end end --- Function to check if an element (here: the identifier used in the fig-reference) is in a table (here: the globale table with all found figure identifiers). -- @param table The table (= global Figref_Table). -- @param element The element to search for (=the identifier used in the in-text reference). -- @return (bool) true or false function tableContains(table, element) for _,value in ipairs(table) do if value == element then return true end end return false end -- MAIN FUNCTIONS --- Checks every pandoc.Figure for identifiers; if one was found, add it to global Figref_Table -- @param figure The pandoc.Figure element. -- @return (nil | pandoc.Figure). New pandoc.Figure element if identifier was found, else nil. function figureParser(figure) -- only exchange caption if output format is 'html' -> LaTeX automatically adds figure-tags like "Figure 1:" to captions if figure.identifier then -- add identifier to global id-collection (used to find in-text refs) table.insert(Figref_Table, Counter, figure.identifier) -- change figure caption in AST: add "Figure <NO>: " to caption if FORMAT:match "html" then figure.caption.long = figure.caption.long:walk { Plain=addFigureTagToCaption } end -- increase global Counter Counter = Counter + 1 return figure else return nil end end --- Function to replace the in-text figure reference (such as @fig:fig1), which is wrapped in a pandoc.Cite element, with the matching link syntax of the output format (HTML/LaTeX). -- @param word The pandoc.Cite element. -- @return (nil|pandoc.RawInline) pandoc.RawInline if reference was found. Else nil. function setRefsToFigure(cite) return stringReplacementRef(cite.citations[1].id) end return { {Figure=figureParser}, {Cite=setRefsToFigure} } ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <ee97eefb-cb70-4bf9-859c-e75448438894n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>]
* Re: Citeproc/Order of filters being called [not found] ` <ee97eefb-cb70-4bf9-859c-e75448438894n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> @ 2023-11-30 9:56 ` 'Thomas J.' via pandoc-discuss 0 siblings, 0 replies; 4+ messages in thread From: 'Thomas J.' via pandoc-discuss @ 2023-11-30 9:56 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1.1: Type: text/plain, Size: 3038 bytes --] Just a quick update: Adding references to LaTeX/PDF should now work as well. I've also refactored parts of the code/docs and put everything into a github repo: https://github.com/thomjur/pandoc-figref Thomas J. schrieb am Mittwoch, 29. November 2023 um 19:29:15 UTC+1: > Thanks for the feedback! I simply was not aware of the fact that every > @<WORD> string is apparently automatically converted into a Cite block in > the AST, even without using citeproc (?). Anyhow, being aware of this fixed > the problem. I've attached the filter, if someone is interested. It is > still very raw and only for HTML (adding latex shouldnt be a huge problem > though). > > Thanks again for the help! > > With best wishes, > Thomas > > William Lupton schrieb am Mittwoch, 29. November 2023 um 15:49:45 UTC+1: > >> From the information given, I think that the AST must still contain a >> fig:fig1 citation after your filter has run. Are you able to share your >> filter? >> >> On Wed, 29 Nov 2023 at 13:28, 'Thomas J.' via pandoc-discuss < >> pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> wrote: >> >>> Hi everyone, >>> >>> Since pandoc-fignos isn't working anymore (at least, with my Pandoc >>> version), I have written a Lua filter that basically does what fignos does, >>> namely replacing tags such as @fig:fig1 with anchors/refs to the figures in >>> html/latex. Now, if I am trying to use this filter without citeproc, >>> everthing works as expected. The moment I use --citeproc, I get the error >>> message "fig:fig1 citation not found" and I have no link in my output file. >>> I am actually calling the lua filter BEFORE --citeproc in the command >>> line... >>> >>> pandoc --lua-filter=filter/pandoc-figref.lua --citeproc >>> --number-sections --from markdown --template=templates/phimisci-1-5.html >>> --bibliography=$BIBLIOGRAPHY --csl=csl/apa7-single-spaced.csl >>> yaml/gen-metadata.yaml article/$1 article/$2 -o $HTMLFILE >>> >>> What am I missing? Thanks for the help! >>> >>> Best wishes, >>> Thomas >>> >>> -- >>> 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/15e09292-83a1-4e28-ba84-d0c518be709dn%40googlegroups.com >>> <https://groups.google.com/d/msgid/pandoc-discuss/15e09292-83a1-4e28-ba84-d0c518be709dn%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/58fb8090-1d03-431d-b631-ae4a70ed08adn%40googlegroups.com. [-- Attachment #1.2: Type: text/html, Size: 5619 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-11-30 9:56 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-11-29 13:28 Citeproc/Order of filters being called 'Thomas J.' via pandoc-discuss [not found] ` <15e09292-83a1-4e28-ba84-d0c518be709dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 2023-11-29 14:49 ` 'William Lupton' via pandoc-discuss [not found] ` <CAEe_xxid8YRTLJKC=8jvD2ps4a7YoQe=ZS3DMMt0VJ3d0e-04Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2023-11-29 18:29 ` 'Thomas J.' via pandoc-discuss [not found] ` <ee97eefb-cb70-4bf9-859c-e75448438894n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 2023-11-30 9:56 ` 'Thomas J.' via pandoc-discuss
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).