Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit aeed63c

Browse files
authored
Add zero width space to escape emoji shortcodes (#149)
* Add zero width space to escape emoji shortcodes * Add changelog entries for #149
1 parent 7bdcbc5 commit aeed63c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3333
#130 by @mattt.
3434
- Fixed file and directory unexpected permissions.
3535
#146 by @niw.
36+
- Fixed rendering of colon sequences in function signatures
37+
as emoji shortcodes (e.g. `:on:` → 🔛).
38+
#149 by @mattt.
3639
- Fixed declarations for properties without explicit type annotations.
3740
#150 by @mattt.
3841

Sources/swift-doc/Supporting Types/Page.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ extension Page {
2424
let data: Data?
2525
switch format {
2626
case .commonmark:
27-
data = document.render(format: .commonmark).data(using: .utf8)
27+
var text = document.render(format: .commonmark)
28+
// Insert U+200B ZERO WIDTH SPACE
29+
// to prevent colon sequences from being interpreted as
30+
// emoji shortcodes (without wrapping with code element).
31+
// See: https://docs.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax#using-emoji
32+
text = text.replacingOccurrences(of: ":", with: ":\u{200B}")
33+
data = text.data(using: .utf8)
2834
case .html:
2935
data = layout(self).description.data(using: .utf8)
3036
}

0 commit comments

Comments
 (0)