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

`{.tabset}` does not support Chinese #1149

Closed
psychelzh opened this Issue Sep 27, 2017 · 15 comments

Comments

Projects
None yet
2 participants
@psychelzh

psychelzh commented Sep 27, 2017

Here I include an example rmarkdown text:

---
title: 你好世界
output: html_document
---

# 标题 {.tabset}

## 标签一

内容

## 标签二

内容

And the output is as follows:

image

But interestingly, when I substitute "一" and "二" with 1 and 2 respectively, it works!

---
title: 你好世界
output: html_document
---

# 标题 {.tabset}

## 标签1

内容

## 标签2

内容

Then the output is right. Further trials indicate that there must be one visible alphanum character at the end of each tab title if you want it be right.

image

SessionInfo:

R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936  LC_CTYPE=Chinese (Simplified)_China.936   
[3] LC_MONETARY=Chinese (Simplified)_China.936 LC_NUMERIC=C                              
[5] LC_TIME=Chinese (Simplified)_China.936    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] RevoUtilsMath_10.0.0

loaded via a namespace (and not attached):
 [1] compiler_3.4.1   backports_1.1.0  magrittr_1.5     RevoUtils_10.0.5 rprojroot_1.2   
 [6] htmltools_0.3.6  tools_3.4.1      yaml_2.1.14      Rcpp_0.12.12     stringi_1.1.5   
[11] rmarkdown_1.6    knitr_1.17       stringr_1.2.0    digest_0.6.12    evaluate_0.10.1
@yihui

This comment has been minimized.

Member

yihui commented Sep 27, 2017

You have to assign ID's manually to the tab titles, e.g.

---
title: 你好世界
output: html_document
---

# 标题 {.tabset}

## 标签一 {#tab-1}

内容

## 标签二 {#tab-2}

内容

This is because Pandoc cannot generate an ID when there are no alphanumeric characters in a section heading.

@psychelzh

This comment has been minimized.

psychelzh commented Sep 27, 2017

@yihui Thank you for you quick response. I wonder if these tab titles can be further used, too; e.g., cross-reference?

@yihui

This comment has been minimized.

Member

yihui commented Sep 27, 2017

Without tabsets, you can use ID's to reference a section, e.g. [see Tab 1](#tab-1). But you cannot reference tab titles (at least for now).

@psychelzh

This comment has been minimized.

psychelzh commented Sep 27, 2017

I think I know it now. I will add a tab title to every tabs in a tabset, but I cannot reference these tabs (I think it okay for now); if I want to refence a tab, change it to a section (do not append {.tabset}). Am I right?

And by now it is also very useful even without reference. Thank you for developing these inspiring packages! @yihui

@yihui

This comment has been minimized.

Member

yihui commented Sep 27, 2017

Your understanding is correct.

@psychelzh

This comment has been minimized.

psychelzh commented Sep 28, 2017

Thank you. After one-day trying this feature, I found that the tab titles could not be repeated, just as intuition, which is quite annoying when the number of tabs to display increases. I am wondering whether a better support for Chinese without tab names is possible or not, although acceptable if not.

@yihui yihui added this to the v1.7 milestone Oct 10, 2017

@yihui yihui added the Question label Oct 10, 2017

@yihui

This comment has been minimized.

Member

yihui commented Oct 10, 2017

I don't know what you mean by "the tab titles could not be repeated". I think tab titles should be different by definition, and I don't know why someone wants to use the same title for two different tabs.

@yihui yihui closed this Oct 10, 2017

@psychelzh

This comment has been minimized.

psychelzh commented Oct 10, 2017

I agree with you. But there is a misunderstanding. I meant to say that if there are more and more tabs to display, one have to add a unique tab title to each of them, which is an otherwise unnecessary demanding task.

@yihui

This comment has been minimized.

Member

yihui commented Oct 10, 2017

Do you mean a unique ID or a unique title?

@psychelzh

This comment has been minimized.

psychelzh commented Oct 11, 2017

Unique ID.

To be clearer, what I expected is just the support of Chinese tabs without adding ID's.

@yihui

This comment has been minimized.

Member

yihui commented Oct 11, 2017

That is not possible, because Pandoc cannot generate automatic ID's for headers that do not contain any alphanumeric characters (e.g. pure Chinese): http://pandoc.org/MANUAL.html#header-identifiers You will have to file a feature request to Pandoc.

@psychelzh

This comment has been minimized.

psychelzh commented Oct 11, 2017

I got it! And thank you very much for your kind response.

@psychelzh

This comment has been minimized.

psychelzh commented Mar 14, 2018

@yihui I am sorry to disturb you again, but I have filed an issue (jgm/pandoc#4452) at the Pandoc side. Then the developers there stated that Pandoc supports generating automatic identifiers for Chinese headers.

Here is the result:

% pandoc -t html
# 标题 {.tabset}

## 标签一

内容

## 标签二

内容
^D
<h1 id="标题" class="tabset">标题</h1>
<h2 id="标签一">标签一</h2>
<p>内容</p>
<h2 id="标签二">标签二</h2>
<p>内容</p>

Now I wonder what the true issue is.

@yihui

This comment has been minimized.

Member

yihui commented Mar 14, 2018

Actually we enabled the ascii_identifiers extension. The tabs will work if you remove the extension:

---
title: 你好世界
output:
  html_document:
    md_extensions: -ascii_identifiers
---

# 标题 {.tabset}

## 标签一

内容1

## 标签二

内容2
@psychelzh

This comment has been minimized.

psychelzh commented Mar 15, 2018

Thank you. @yihui It is of great help! 👍

psychelzh added a commit to iquizoo/docs that referenced this issue Mar 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment