-
-
Notifications
You must be signed in to change notification settings - Fork 334
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
TOC Flashes and Disappears #567
Comments
Hi @mrkaye97, We understand you did not manage to create a reprex however, can you share some details on what you are trying to do ? The SO post you linked to is about Also,
What are you using for the TOC ? Can you share more details on this issue you encounter so that we can look into it more ? |
@cderv thanks for getting back on this! Here's a screen recording of how it looks: toc.recording.movThe flash and disappearance of the TOC happens on the RHS. I tried to slow-mo it but wasn't sure how to. You might need to watch it a couple of times. I think it looks worse in an actual browser (as opposed to when it's server locally. probably a response time thing). The R Script in that test ^ is just:
I've tried a few different things for the YAML. This is how it is set up for the recording:
I've also tried this:
and this:
And I think a few others (can't remember all of them). I've also tried making the extension on the file Let me know if you have any ideas! I think that the feature not being supported by Pandoc is a good guess. Is there any way to make |
@mrkaye97 Just to be sure to understand correctly: is this toc feature you want to use part of a specific them you are using ? or is it the same toc that you can have using I see a flash in your video but can't really see what it should looks like. Regarding .Rmd to .md, there is a new I think this could be theme related so I need to have more info as I don't have a reproducible example. Thanks. BTW:
|
@cderv Honestly, I'm not sure if it's part of the theme or just whatever I can do using |
Thanks. Knowing the theme helps a lot as I found what I needed to check. It corresponds to what I thought you were using. You are indeed using a feature of Hugo which is that the Hugo's Markdown Parser Goldmark can parse a Table of content to be used in a template. See https://gohugo.io/content-management/toc/ I tested quickly on a new site using your theme and I can reproduce the flashing when using .Rmd file. This is because Rmd to Html is done with Pandoc by default. You need to use BTW the configuration for the toc in this theme, following their exampleSite, is autoCollapseToc: true either per post in the YAML or for the all site in the config file. Also for such theme, you could be interested in the Happy to explain more if you have some issue with that still. In the meantime, I close this issue as we now know the why. |
Thanks @cderv! I'll give it a test drive later and let you know how it goes |
Yes, I think the solution is to either use the file extension Without that, it is possible to make it work, but it would require the theme author's support. I think I know how to do it (e.g., TOC works for the hugo-prose theme no matter what your file extension or build method is), but it has to be done on a theme by theme basis, and I can't provide a universal solution. |
So, some good news and some bad news: Good news: using the Bad news: It seems like mathjax isn't working with
Thanks again for all the help, and all the awesome work you guys do! |
If you are not using Pandoc, there is indeed a possibility that math does not work well with Goldmark as it is not supported out of the box (I think there is a goldmark extension that can do it but don't know how to configure it with hugo). Anyway, as the doc you linked above says, it depends on your theme used to have a MathJax support. Luckily, yours have it. See https://hugo-theme-even.netlify.app/post/even-preview/#math, the config part and the code This works for me in ---
title: "Hello R Markdown"
author: "Frida Gomam"
date: 2020-12-01T21:13:14-05:00
categories: ["R"]
tags: ["R Markdown", "plot", "regression"]
autoCollapseToc: true
mathjax: true
mathjaxEnableSingleDollar: yes
mathjaxEnableAutoNumber: yes
---
# Some Math
inline math: $ evidence\_{i}=\sum\_{j}W\_{ij}x\_{j}+b\_{i} $
Display math
$$
E(\mathbf{v}, \mathbf{h}) = -\sum_{i,j}w_{ij}v_i h_j - \sum_i b_i v_i - \sum_j c_j h_j
$$
\\[3 < 4\\]
\begin{equation}
E = mc^2
\end{equation}
As you see if you try, special chars are escaped with See
You would need to add this script to the theme, or modify the theme to configure mathjax to skip the So, at the end, this will also require to modify the theme as Math are not yet supported by default in Hugo markdown renderer. This is the same as for the TOC: to make it available for .Rmd and .Rmarkdown, it would require to adapt the theme the How-o part in the book shows an example. BTW @yihui the last equation with |
@cderv That sounds like a bug of my JS code: https://github.com/rbind/yihui/blob/ad46b111ac16b58701fef041912f8594e5d5b1d9/static/js/math-code.js#L13 The @mrkaye97 In case you you'd like to learn more background information about this problem: https://yihui.org/en/2018/07/latex-math-markdown/ |
Awesome! Thanks again guys |
@yihui I understood the I understood blogdown will add the backtick and you need the JS script to remove. When you don't have the JS script, maybe it could be interested to deactivate the backtick insertion ? So I don't think this is bug in your script. I may have misexplain what I tried 😅 |
…ers to not protect math content via options(blogdown.protect.math = FALSE) this problem was also mentioned in #567
@cderv Oh I see now. Yes, |
I can't
reprex
this, but for myblogdown
site, I've been playing around with a bunch of different ways of specifying the TOC in the YAML, but it seems like every combination I try ends up with the TOC flashing and then disappearing. It's the same issue referenced in this SO post. I'm not sure if this is ablogdown
issue, a Hugo issue, or a theme issue, but the TOC seems to work fine inexample_post.md
but fails forexample_post.Rmd
, as in: I can use a TOC fine in pure markdown, but it's flashing and then disappearing in Rmarkdown, and I'm not sure why.Has anyone else run into this issue and found a fix? I've tried a bunch of different ideas in the YAML already per @yihui's suggestions in other issues and SO posts, and no dice.
The text was updated successfully, but these errors were encountered: