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

Preserve non-fancy quotes in code chunks #75

Closed
riccardoporreca opened this issue Jul 20, 2019 · 4 comments

Comments

@riccardoporreca
Copy link

commented Jul 20, 2019

Using output: pinp::pinp, the quotes in the code chunks are converted to fancy quotes.

I quickly constructed a minimal example as follows

---
title: "Test pinp quotes"
output: pinp::pinp
---

Pinp's quotes in regular text: "dquoted", 'squoted', \`bquoted\`.

Pinp's quotes in inline verbatim text: `"dquoted"`, `'squoted'`.

```r
"dquoted"
'squoted'
`bquoted`
#' Xyz's "dquoted" 'squoted' `bquoted`

(I did not find a nice way to render the closing ``` of the code chunk)

This results in
image

Not sure if this is a desired behavior (I noticed it for the Rcpp vignettes), but in case I tried a quick fix by using LaTeX package upquote. In particular, adding

\RequirePackage{upquote} % For keeping actual quotes in verbatim

to the class definition pinp.cls seemed to indeed help:
image

My LaTeX skills are a bit rusty, so maybe there are more convenient / appropriate ways to achieve the same.

@eddelbuettel

This comment has been minimized.

Copy link
Owner

commented Jul 20, 2019

Nice catch. I may be a little dense but the desired effect is just for the verbatim chunk, correct? Inline does not seem to change. Or am I missing something?

@riccardoporreca

This comment has been minimized.

Copy link
Author

commented Jul 20, 2019

the desired effect is just for the verbatim chunk, correct? Inline does not seem to change. Or am I missing something?

From what I see it doesn't seem to affect anything inline (even verbatim inline which was already OK), since inline stuff do not use any of the verbatim-related LaTeX affected by upquote, see the generated LaTeX code:

Pinp's quotes in regular text: ``dquoted'', `squoted', `bquoted`.

Pinp's quotes in inline verbatim text: \texttt{"dquoted"},
\texttt{\textquotesingle{}squoted\textquotesingle{}}.

\begin{Shaded}
\begin{Highlighting}[]
\StringTok{"dquoted"}
\StringTok{'squoted'}
\StringTok{`}\DataTypeTok{bquoted}\StringTok{`}
\CommentTok{#' Xyz's "dquoted" 'squoted' `bquoted`}
\end{Highlighting}
\end{Shaded}

(I have updated the example with something a little more accurate / sensible)

@eddelbuettel

This comment has been minimized.

Copy link
Owner

commented Jul 20, 2019

Ok, I just tossed that in with a simple commit. Thanks again for the suggestion!

@riccardoporreca

This comment has been minimized.

Copy link
Author

commented Jul 20, 2019

Cool, I will be trying it out very soon while drafting a review of the Rcpp-modules vignette as discussed in RcppCore/Rcpp#976 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.