From 37018ccf7c618a8d03a1bb554ab204012cc2c86a Mon Sep 17 00:00:00 2001 From: Pawel Protas Date: Sat, 13 Jan 2024 13:35:57 +0100 Subject: [PATCH 1/2] feat: support escape slash in wikilinks Ref: https://github.com/artempyanykh/marksman/issues/288 The pipe operator used in WikiLinks can now be escaped with a backwards slash `\`. --- Marksman/Misc.fs | 2 +- Tests/MiscTests.fs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Marksman/Misc.fs b/Marksman/Misc.fs index 3f7193b..2c49ac7 100644 --- a/Marksman/Misc.fs +++ b/Marksman/Misc.fs @@ -75,7 +75,7 @@ type String with sb.ToString() member this.EncodeForWiki() : string = - let replacement = [| "#", "%23"; "[", "%5B"; "]", "%5D"; "|", "%7C" |] + let replacement = [| "#", "%23"; "[", "%5B"; "]", "%5D"; "|", "%7C"; "\\|", "%7C" |] replacement |> Array.fold (fun (sb: StringBuilder) -> sb.Replace) (StringBuilder(this)) diff --git a/Tests/MiscTests.fs b/Tests/MiscTests.fs index 912ad47..80d884b 100644 --- a/Tests/MiscTests.fs +++ b/Tests/MiscTests.fs @@ -93,8 +93,8 @@ module StringExtensionsTests = [] let encodeForWiki_2 () = - let original = "blah #blah [] () |" - let expected = "blah %23blah %5B%5D () %7C" + let original = "blah #blah [] () | \\|" + let expected = "blah %23blah %5B%5D () %7C %7C" let actual = original.EncodeForWiki() Assert.Equal(expected, actual) Assert.Equal(original, actual.UrlDecode()) From 2b80dbe08accbca08a75176da89ea0c335312be2 Mon Sep 17 00:00:00 2001 From: Pawel Protas Date: Mon, 15 Jan 2024 10:56:42 +0100 Subject: [PATCH 2/2] format: fix formatting using fantomas --- Marksman/Misc.fs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Marksman/Misc.fs b/Marksman/Misc.fs index 2c49ac7..4c39df7 100644 --- a/Marksman/Misc.fs +++ b/Marksman/Misc.fs @@ -75,7 +75,8 @@ type String with sb.ToString() member this.EncodeForWiki() : string = - let replacement = [| "#", "%23"; "[", "%5B"; "]", "%5D"; "|", "%7C"; "\\|", "%7C" |] + let replacement = + [| "#", "%23"; "[", "%5B"; "]", "%5D"; "|", "%7C"; "\\|", "%7C" |] replacement |> Array.fold (fun (sb: StringBuilder) -> sb.Replace) (StringBuilder(this))