pugjs / pug-www

The website for Pug.
16 stars 12 forks source link

Add specified-anchor syntax for multilingual, using `~~` #12

Closed LionNatsu closed 8 years ago

LionNatsu commented 8 years ago

By default, anchor is not suitable for multilanguage in most situation, not only because the encoding is hard to "slugify", but also the "compatibility" between itself and "the standard upstream" 's URL. So when the website comes to be multilingual, it needs a way to fix the content of headings that it was (in English).

For example,

# Title

This is a file written in Markdown.

## The syntax

The new syntax I am using is `~~ anchor title`.

We are using markdown-it-anchor now right? So that we get two anchor: #title and #the-syntax.

After we translate it into, let's say, zh-CN:

# 标题

这是一份用 Markdown 书写的文件。

## 语法

我使用的新语法是 `~~ 用于锚的标题`。

These the anchors turn to # (nothing),and it break down the links in other page.

Using the specified-anchor syntax, we can write translations in this way:

# 标题 ~~ Title

这是一份用 Markdown 书写的文件。

## 语法 ~~ The syntax

我使用的新语法是 `~~ 用于锚的标题`。

The visible result is equivalent to the former one. The difference is there are the same anchors in the original one.

LionNatsu commented 8 years ago

New changes have been deployed.