File tree Expand file tree Collapse file tree 2 files changed +6
-15
lines changed
Sources/SourceKit/sourcekitd Expand file tree Collapse file tree 2 files changed +6
-15
lines changed Original file line number Diff line number Diff line change @@ -444,22 +444,13 @@ extension SwiftLanguageServer {
444
444
return
445
445
}
446
446
447
- /// Prepend backslash to all ASCII punctuation , to prevent it
447
+ /// Prepend backslash to `*` and `_` , to prevent them
448
448
/// from being interpreted as markdown.
449
- ///
450
- /// Any ASCII punctuation character may be backslash-escaped.
451
- /// https://spec.commonmark.org/0.29/#backslash-escapes
452
- func escapeMarkdown( _ str: String ) -> String {
453
- func isAsciiPunctuation( _ char: Character ) -> Bool {
454
- let asciiPunctuation = Set < Character > ( ##"""
455
- !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
456
- """## )
457
- return asciiPunctuation. contains ( char)
458
- }
459
- return String ( str. flatMap ( { isAsciiPunctuation ( $0) ? [ " \\ " , $0] : [ $0] } ) )
449
+ func escapeNameMarkdown( _ str: String ) -> String {
450
+ return String ( str. flatMap ( { ( $0 == " * " || $0 == " _ " ) ? [ " \\ " , $0] : [ $0] } ) )
460
451
}
461
452
462
- var result = " # \( escapeMarkdown ( name) ) "
453
+ var result = " # \( escapeNameMarkdown ( name) ) "
463
454
if let doc = cursorInfo. documentationXML {
464
455
result += """
465
456
Original file line number Diff line number Diff line change @@ -648,7 +648,7 @@ final class LocalSwiftTests: XCTestCase {
648
648
XCTAssertNil ( hover. range)
649
649
XCTAssertEqual ( hover. contents. kind, . markdown)
650
650
XCTAssertEqual ( hover. contents. value, ##"""
651
- # test\ (\_\ :\_\:\ )
651
+ # test(\_:\_: )
652
652
```
653
653
func test(_ a: Int, _ b: Int)
654
654
```
@@ -668,7 +668,7 @@ final class LocalSwiftTests: XCTestCase {
668
668
XCTAssertNil ( hover. range)
669
669
XCTAssertEqual ( hover. contents. kind, . markdown)
670
670
XCTAssertEqual ( hover. contents. value, ##"""
671
- # \*\ %\*\ (\_\ :\_\:\ )
671
+ # \*%\*(\_:\_: )
672
672
```
673
673
func *%* (lhs: String, rhs: String)
674
674
```
You can’t perform that action at this time.
0 commit comments