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 issue that headline with chinese characters only No links generated #1241

heavenzone opened this Issue Jan 10, 2018 · 2 comments


None yet
2 participants
Copy link

heavenzone commented Jan 10, 2018

I don't know if this is an issue.

If the headline has chinese characters only, the output htmldocument's source code of this position #TOC ul li a does not create the href attribute. And the div wrapping the headline <h2></h2> does not create the id attribute.

here's the result.

test env

i'v tested for both version 1.8 and version 1.8.5.
both of them caused this issue.

> packageVersion("rmarkdown")
[1] ‘1.8’
> packageVersion("rmarkdown")
[1] ‘1.8.5’

rmarkdown file

title: "rmarkdown toc that headline with chinese characters only issue"
  - test
	toc: true

## 中文标题

chinese characters only

## 标题headline


## headline

english only

output html source code

<div id="TOC">
<li><a href="#headline">标题headline</a></li>
<li><a href="#headline-1">headline</a></li>

<div class="section level2">
<p>chinese characters only</p>
<div id="headline" class="section level2">
<div id="headline-1" class="section level2">
<p>english only</p>

blogdown has the same issue.


This comment has been minimized.

Copy link

yihui commented Jan 10, 2018

Duplicate of #1149

It is a Pandoc issue, but I don't think Pandoc can automatically solve it. You have manually add IDs to your pure Chinese titles. Thanks!

@yihui yihui marked this as a duplicate of #1149 Jan 10, 2018

@yihui yihui closed this Jan 10, 2018

@yihui yihui added this to the v1.9 milestone Jan 10, 2018

@yihui yihui added the Question label Jan 10, 2018


This comment has been minimized.

Copy link

heavenzone commented Jan 11, 2018

@yihui thanks for pointing out the details of this issue.
I think this issue could solve by javascript easily. so i searched "markdown toc" for another solution.
then I found this two repos:

now i just easily paste these codes into rmarkdown files, Then the toc with pure Chinese makes sense.

<script type="text/javascript">
        var tag = $(item).get(0).localName;
        $("#category").append('<a class="new'+tag+'" href="#wow'+i+'">'+$(this).text()+'</a></br>');
<div id="category"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment