Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions lib/inlines.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,22 @@ var text = function(s) {
// collapse internal space, unicode case fold.
// See commonmark/commonmark.js#168.
var normalizeReference = function(string) {
return string
var trimmed = string
.slice(1, string.length - 1)
.trim()
.replace(/[ \t\r\n]+/g, " ")
.toLowerCase()
.toUpperCase();
.replace(/[ \t\r\n]+/g, " ");
// Dotless i (U+0131) has no default CaseFolding.txt entry, so it folds to
// itself (the I to dotless i mapping is Turkic-only), but it uppercases to
// ASCII I, so toLowerCase/toUpperCase would merge it with i. Fold the runs
// between occurrences instead. A run boundary can only affect final sigma,
// whose two lowercase forms uppercase alike; every other mapping these
// locale-independent methods apply is context-free.
if (trimmed.indexOf("\u0131") === -1) {
return trimmed.toLowerCase().toUpperCase();
}
return trimmed.replace(/[^\u0131]+/g, function(part) {
return part.toLowerCase().toUpperCase();
});
};

// INLINE PARSER
Expand Down
34 changes: 34 additions & 0 deletions test/regression.txt
Original file line number Diff line number Diff line change
Expand Up @@ -591,3 +591,37 @@ Issue #212 - Non-empty blank lines in fenced code ignored when in lists
<pre><code>
</code></pre>
````````````````````````````````

Dotless i (U+0131) is not folded to ASCII i

```````````````````````````````` example
[I]: /a

[ı]: /b

[a][i] [b][ı]
.
<p><a href="/a">a</a> <a href="/b">b</a></p>
````````````````````````````````

Labels containing dotless i still fold their other characters

```````````````````````````````` example
[FIQ]: /a

[Fıq]: /b

[a][fiq] [b][fıQ]
.
<p><a href="/a">a</a> <a href="/b">b</a></p>
````````````````````````````````

A dotless i reference does not resolve against an ASCII I definition

```````````````````````````````` example
[I]: /a

[ı]
.
<p>[ı]</p>
````````````````````````````````
Loading