Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

better pandoc support #8152

Closed
jirib opened this issue Jan 18, 2021 · 10 comments
Closed

better pandoc support #8152

jirib opened this issue Jan 18, 2021 · 10 comments

Comments

@jirib
Copy link

jirib commented Jan 18, 2021

Hi,

it would be nice to have better pandoc integration as I feel commonmark has limitations and pandoc markdown can do much more things. Examples:

  • ability to have TOC made by pandoc, just like asciidoctor support (enableTOC: false - to pass --toc to pandoc, preserveTOC = false - to override pandoc TOC html code <nav id="TOC" role="doc-toc">with hugo .TableOfContent variable; it would be probably nice also to be able to define css selector to find pandoc TOC as one could change pandoc template.
  • extra args, eg. to define --template <file> or --data-dir <dir> ...
@jirib jirib added the Proposal label Jan 18, 2021
@jwflory
Copy link

jwflory commented Jan 18, 2021

If better Pandoc support means that my toc appear in AsciiDoc-based HTML, that would be a big win. I see it appear in my local previews with the Asciidoctor.js extension, but it would be nice for the table-of-contents attribute to make it to the generated HTML by Hugo for my site.

@jirib
Copy link
Author

jirib commented Jan 19, 2021

If better Pandoc support means that my toc appear in AsciiDoc-based HTML, that would be a big win. I see it appear in my local previews with the Asciidoctor.js extension, but it would be nice for the table-of-contents attribute to make it to the generated HTML by Hugo for my site.

Have you tried this?

By default, Hugo removes the table of contents generated by Asciidoctor and provides it through the built-in variable .TableOfContents to enable further customization and better integration with the various Hugo themes. This option can be set to true to preserve Asciidoctor’s TOC in the generated page.
-- https://gohugo.io/content-management/formats/#external-helper-asciidoctor

@jirib
Copy link
Author

jirib commented Jan 19, 2021

BTW, I more wanted to use pandoc markdown with all its extensions, not just TOC... And IIUC, with pandoc one could write content for hugo in latex for example provided that the file extension is pandoc.

And passing extra vars... I have not read hugo source but IIUC it passes stdin to pandoc and it sets argument to --mathjax. This way pandoc does not know what file hugo read, it would be great to be able to pass somehow name of the file to hugo as variable. Let's take an odd example - people writing content in ODT :) A frontmatter would be in a file with pandoc extension, there would be similar file but with ODT extension. With little pandoc wrapper one could do:

# pandoc wrapper without filtering of input args
#!/bin/bash

set -o pipefail
set -e

# TODO: process args, filter -V filename...
filename=/tmp/Untitled_2.pandoc
newargs=$@ # rest of original args
tmpfile=$(mktemp)

trap "rm -f ${tmpfile}" EXIT
cat > ${tmpfile}

exec /usr/bin/pandoc -f odt -t html5 --toc --template /tmp/templ \
     --metadata-file ${tmpfile} ${filename%.pandoc}.odt ${newargs}
# see what in ODT file

$ /usr/bin/pandoc -f odt -t commonmark /tmp/Untitled_2.odt 
Heading 2
---------

### Heading 3

Text[1]

[1] Footnote
# simulation of hugo using pandoc which converts an ODT file

$ pandoc -V filename=/tmp/Untitled_2.pandoc --mathjax < /tmp/Untitled_2.pandoc 
<h1 class="title">hello world!</h1>
<h2 id="heading-2">Heading 2</h2>
<h3 id="heading-3">Heading 3</h3>
<p>Text<a href="#fn1" class="footnote-ref" id="fnref1" role="doc-noteref"><sup>1</sup></a></p>
<section class="footnotes" role="doc-endnotes">
<hr />
<ol>
<li id="fn1" role="doc-endnote"><p>Footnote<a href="#fnref1" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
</ol>
</section>

I.e. an ability to pass {{.File.LogicalName}} as pandoc variable, for example.

@yaxu
Copy link

yaxu commented Jun 6, 2021

I had a look at making pandoc more configurable today, the first time I've written any go code but getting somewhere - I managed to get citeproc support working.

I noticed the mathjax support doesn't seem to actually work.. Pandoc does the processing but mathjax itself isn't loaded. I'm not a TeX math user so left that as-is.

@yaxu
Copy link

yaxu commented Jun 9, 2021

As far as I can tell, the YAML header doesn't get passed to pandoc, is that intentional? I can add more parameters to this PR #8610 , but it would be nice to set things in the header too.

@jirib
Copy link
Author

jirib commented Jun 10, 2021

FYI PR #7529

@yaxu
Copy link

yaxu commented Jun 10, 2021

Ah thanks, somehow I didn't look for previous PRs and now I see there is this one too: #4800

PR #7529 looks great, far more developed than mine. I think being able to configure the existing pandoc support is a really important feature for a lot of people. It would be great to see this merged.

@danmackinlay
Copy link

In case anyone wants citation support right now you can use blogdown which invokes pandoc in a separate pass and bypasses hugo's hardcoded pandoc rendering.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 16, 2023
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

4 participants