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

Add zero width space to escape emoji shortcodes #149

Merged
merged 3 commits into from
Jul 31, 2020
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
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
#130 by @mattt.
- Fixed file and directory unexpected permissions.
#146 by @niw.
- Fixed rendering of colon sequences in function signatures
as emoji shortcodes (e.g. `:on:` → 🔛).
#149 by @mattt.
- Fixed declarations for properties without explicit type annotations.
#150 by @mattt.

Expand Down
8 changes: 7 additions & 1 deletion Sources/swift-doc/Supporting Types/Page.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ extension Page {
let data: Data?
switch format {
case .commonmark:
data = document.render(format: .commonmark).data(using: .utf8)
var text = document.render(format: .commonmark)
// Insert U+200B ZERO WIDTH SPACE
// to prevent colon sequences from being interpreted as
// emoji shortcodes (without wrapping with code element).
// See: https://docs.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax#using-emoji
text = text.replacingOccurrences(of: ":", with: ":\u{200B}")
data = text.data(using: .utf8)
case .html:
data = layout(self).description.data(using: .utf8)
}
Expand Down