rstudio / rmarkdown

Dynamic Documents for R
https://rmarkdown.rstudio.com
GNU General Public License v3.0
2.88k stars 977 forks source link

Enabling toc_float strips the text format #1548

Closed codetrainee closed 5 years ago

codetrainee commented 5 years ago

Enabling toc_float strips the text format such as italic, blod or superscript.

---
output:
  html_document:
    toc: yes
    toc_float: yes
    toc_depth: 3
---

## test *italic*

## test **bold**

## test 10^6^

image

yihui commented 5 years ago

I'm afraid that is expected. All formatting will be removed in the floating TOC. I guess this could be fixed (use node.innerHTML instead of node.innerText in JS), but I don't have time for it. Sorry.

codetrainee commented 5 years ago

Update

Based on Yihui's advice, the item.html(self.html) is utilised to avoid the undesirable effect that may be introduced by <p> tag.

if (this.options.theme !== "bootstrap3") {

          item.append($("<a/>", {

            "html": self.html()

          }));

        } else {

         item.html(self.html());

        }

Hi Yihui,

Thanks for your advice. I've figured out a workaround here.

We need to modified the jquery.tocify.js file:

if (this.options.theme !== "bootstrap3") {

          item.append($("<a/>", {

            "html": self.html()

          }));

        } else {

          item.append($("<p/>", {

            "html": self.html()

          }));
        }

image

github-actions[bot] commented 3 years ago

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.