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

HTML output of Stan chunks can be malformed #907

Closed
bgoodri opened this issue Dec 13, 2016 · 7 comments
Closed

HTML output of Stan chunks can be malformed #907

bgoodri opened this issue Dec 13, 2016 · 7 comments
Labels
duplicate already another issue about this
Milestone

Comments

@bgoodri
Copy link

bgoodri commented Dec 13, 2016

With RStudio >= 1.0, when knitting a RMarkdown file to HTML, a chunk with Stan code can render improperly unless extra spacing is included.

For example, this chunk

```{stan output.var="test", eval = FALSE}
parameters {real < lower = 0 > theta;}
model {target += exponential_lpdf(theta | 1);}
```

looks okay when knit to HTML.

However, without the extra space before and after the angle brackets, as in

```{stan output.var="test", eval = FALSE}
parameters {real<lower = 0> theta;}
model {target += exponential_lpdf(theta | 1);}
```

the HTML file omits the <.

Similarly, without the extra spaces before and after the equal sign, as in

```{stan output.var="test", eval = FALSE}
parameters {real < lower=0 > theta;}
model {target += exponential_lpdf(theta | 1);}
```

the HTML omits the first =.

If you knit to PDF, none of these problems occur, so I think it is probably as issue that < and > need to be interpreted literally in the HTML. The Stan language is whitespace insensitive, so it is a bit odd to have to add extra whitespace to get decent HTML output.

@jjallaire
Copy link
Member

@yihui Any idea why this might be the case?

@jmcphers
Copy link
Member

FWIW I was able to repro this trivially (had rmarkdown 1.2.9000 and knitr 1.15.1 locally). I wonder if it's actually a bug in the highlighter as the output from knitr looks fine prior to the highlight pass (HTML entities properly escaped):

<pre class="stan"><code>parameters {real &lt;lower = 0&gt; theta;}
model {target += exponential_lpdf(theta | 1);}</code></pre>

@yihui
Copy link
Member

yihui commented Dec 13, 2016

I just tested it, and I think it is a highlight.js bug. We are still using 1.1, and the official version is 9.8.0 now: https://highlightjs.org/ I tested 9.8.0 and it works fine.

@jjallaire
Copy link
Member

jjallaire commented Dec 13, 2016 via email

@jjallaire
Copy link
Member

For now I'd say the workaround is to change the highlighter to "tango", "pygments", "kate", "monochrome", "espresso", "zenburn", or "haddock"

@yihui
Copy link
Member

yihui commented Sep 2, 2017

Duplicate of #988.

@yihui yihui closed this as completed Sep 2, 2017
@yihui yihui added the duplicate already another issue about this label Sep 2, 2017
@github-actions
Copy link

github-actions bot commented Nov 3, 2020

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate already another issue about this
Projects
None yet
Development

No branches or pull requests

4 participants