diff --git a/Changelog.md b/Changelog.md index 0c49ecc4..d9aaf3d4 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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. diff --git a/Sources/swift-doc/Supporting Types/Page.swift b/Sources/swift-doc/Supporting Types/Page.swift index 7e4886c2..29ba9da3 100644 --- a/Sources/swift-doc/Supporting Types/Page.swift +++ b/Sources/swift-doc/Supporting Types/Page.swift @@ -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) }