Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Issues with Pandoc versions < 2.8 #5

Open
ahcyip opened this issue Nov 27, 2020 · 12 comments
Open

Issues with Pandoc versions < 2.8 #5

ahcyip opened this issue Nov 27, 2020 · 12 comments

Comments

@ahcyip
Copy link
Contributor

ahcyip commented Nov 27, 2020

This will finally get me to make a website! But I ran into this error:

processing file: test.Rmd
|......................................................................| 100%
ordinary text without R code

[...]

"template" (line 34, column 26):
unexpected "/"
expecting "." or ")$"
Error: pandoc document conversion failed with error 5
Execution halted

which points to the / in $for(it/pairs)$

@petbrueck
Copy link

I was just about to write the same.

  1. I also finally got the motivation to make a minimal website. Thanks for the package!

  2. Same issue as @ahcyip. (e.g. line 39 in jolla_blue.html). Some system details that might be of help (?):

OS Version   : Windows 10 x64
R Version    : 4.0.3
rmarkdown    : 2.5
knitr        : 1.30
pandoc       : 2.7.3

@crsh
Copy link
Contributor

crsh commented Nov 27, 2020

Maybe this has something to do with the pandoc version? I get the same error with release version of RStudio but not with the preview release.

> rmarkdown::pandoc_version()
[1] ‘2.7.3
> rmarkdown::pandoc_version()
[1] ‘2.11.2

@seankross
Copy link
Owner

seankross commented Nov 27, 2020

I also think this is a pandoc version issue. If you install the latest version of pandoc you can use rmarkdown::find_pandoc() to make rmarkdown aware of your latest pandoc version. I just opened a question on stackoverflow with a reproducible example to try to solicit other solutions.

@elinw elinw mentioned this issue Nov 27, 2020
@seankross
Copy link
Owner

#8 is an attempt at a fix, I would appreciate it if you could try it out. Install with:

remotes::install_github("seankross/postcards#8")

@seankross seankross changed the title issue with slash in trestles? Issues with Pandoc versions < 2.8 Nov 27, 2020
@elinw
Copy link
Contributor

elinw commented Nov 28, 2020

That makes it work for me! This is on RStudioServer which is pandoc 2.7.3.

@petbrueck
Copy link

Just to confirm: I also got it working with the latest pandoc version.

I now switched back to release version of RStudio and

rmarkdown::pandoc_version()
[1] ‘2.7.3’

With postcards#8 I can succesfully knit the document. However, the LinkedIn/Twitter Boxes below the horizontal line are not rendered any longer.

processing file: Untitled.Rmd
  |......................................................................| 100%
  ordinary text without R code

output file: Untitled.knit.md
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS Untitled.utf8.md --to html4 --from markdown+tex_math_single_backslash-autolink_bare_uris 
--output Untitled.html 
--lua-filter "C:\Users\Peter\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\pagebreak.lua" 
--lua-filter "C:\Users\Peter\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\latex-div.lua"
--email-obfuscation none --standalone --section-divs 
--template "C:\Users\Peter\Documents\R\win-library\4.0\postcards\pandoc_templates\jolla-blue-pandoc-old.html" 
--highlight-style pygments 
--include-in-header "C:\Users\Peter\AppData\Local\Temp\Rtmpuu332R\rmarkdown-str38906ae12040.html" 

Output created: Untitled.html

jolla_blue

@zorgster
Copy link

zorgster commented Nov 28, 2020

Yes, this works for me too.... the error is not thrown.

However, the resulting Links <ul> block is empty and the HTML in the browser looks like the CSS has not linked up.

@zorgster
Copy link

Pandoc externalised the doctemplates functionality - https://github.com/jgm/doctemplates

The functionality for pipes and filters was cleaned in 2.8.

"Pandoc templates now support a number of new features that have been added in doctemplates: notably, elseif, it, partials, filters, and syntax to control nesting and reflowing of text. These changes make pandoc more suitable out of the box for generating plain-text documents from data in YAML metadata. It can create enumerated lists and even tabular structures."
Pandoc Releases: 2.8

PS: Adding data-external="1" to the <img> tag in the template allows one to have images that are separate from the standalone HTML. Which is great if you have images that need updating frequently or being re-used on the website elsewhere.

Adding data-external="1" to the bootstrap link tag in the header, fixed the template for me. Trestles now shows up as intended, before this, the CSS was not applied. (This perhaps defeats the purpose of self-contained HTML, but those are links to external bootstrap CSS anyway. (But not yet these links)

@zorgster
Copy link

zorgster commented Nov 28, 2020

This sorts it out for me completely. (Posted to the stackoverflow as well) - although the links block is not as neat/compact as in your original version; it remains flexible.

Pandoc 2.7.3 can't handle the 'pairs' in 2.8, but you can define lists in the header YAML. (By explicit specification of the nested variables within the links object - (requires two tabs before 'url').

---
title: "Frank Hermosillo"
image: "frank.jpg"
links:
  - site: LinkedIn
    url: "https://linkedin.com/"
  - site: Twitter
    url: "https://twitter.com/"
  - site: GitHub
    url: "https://github.com/"
  - site: Email
    url: "mailto:email@email.com"
output:
  postcards::trestles
---

Then in the template you can just refer to the field names:

                <ul class="list-inline">
                  $for(links)$
                  <li class="list-inline-item">
                    <a href=$links.url$>
                      <button type="button" class="btn btn-outline-dark">
                        To $links.site$
                      </button>
                    </a>
                  </li>
                  $endfor$
                </ul>

Does that work for later versions as well?

I knitted to index.html - in a folder - then in RStudio (because this is a Git Project) committed and pushed to Git. My Git is hooked up to Netlify and Netlify is pointed to the same folder (so all that is automated [as recommended]):

https://me.speechlets.com/

@seankross
Copy link
Owner

Hi all, would you mind trying out #10 ?

remotes::install_github("seankross/postcards#10")

Thanks @zorgster for these ideas.

@ahcyip
Copy link
Contributor Author

ahcyip commented Nov 29, 2020

Thanks - it knits without error for me now (and I didn't change anything with my RStudio/packages/pandoc)

@zorgster
Copy link

Yes, for me too. Jolla-Blue and Trestles both knitted without error.

I see the CSS, scripts and image have not been encoded in the HTML and there's no 'data-external' attribute in the html... is that achieved elsewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants