Skip to content

Commit 89ac197

Browse files
hotfixing truncated markdown in urls
1 parent 1ea0b81 commit 89ac197

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Replies.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ escapeWhere txt suspects =
2222
else t `T.append` T.singleton c
2323
) mempty txt
2424

25+
skipWhere :: T.Text -> [T.Text] -> T.Text
26+
skipWhere txt suspects = T.filter (\t -> T.singleton t `notElem` suspects) txt
27+
2528
mkdSingles :: [T.Text]
2629
mkdSingles = ["_", "*", "`"]
2730

@@ -45,15 +48,15 @@ instance Renderable Feed where
4548
]
4649

4750
instance Renderable SubChat where
48-
render SubChat{..} =
51+
render SubChat{..} =
4952
let adjust c = if c == "0" then "00" else c
5053
interval = case settings_batch_interval sub_settings of
5154
HM vals -> "every day at " `T.append` foldl' (\s (!h, !m) ->
5255
let body = (T.pack . show $ h) `T.append` ":" `T.append` (adjust . T.pack . show $ m)
5356
s' = if s == mempty then s else s `T.append` ", "
5457
in s' `T.append` body) mempty vals
5558
Secs xs -> "every " `T.append` (T.pack . show $ xs) `T.append` " (seconds)"
56-
blacklist =
59+
blacklist =
5760
let bs = filters_blacklist . settings_filters $ sub_settings
5861
in if null bs then "none" else T.intercalate "," bs
5962
in T.intercalate "\n" $ map (\(k, v) -> k `T.append` ": " `T.append` v)
@@ -82,12 +85,12 @@ instance Renderable [Item] where
8285

8386
toHrefEntities :: Maybe Int -> T.Text -> T.Text -> T.Text
8487
toHrefEntities Nothing tag link =
85-
let tag' = "[" `T.append` tag `T.append` "]"
88+
let tag' = "[" `T.append` skipWhere tag (mkdSingles ++ mkdDoubles) `T.append` "]"
8689
link' = "(" `T.append` link `T.append` ")"
8790
in tag' `T.append` link'
8891
toHrefEntities (Just counter) tag link =
8992
let counter' = T.pack . show $ counter
90-
tag' = " [" `T.append` tag `T.append` "]"
93+
tag' = " [" `T.append` skipWhere tag (mkdDoubles ++ mkdSingles) `T.append` "]"
9194
link' = "(" `T.append` link `T.append` ")"
9295
in counter' `T.append` tag' `T.append` link'
9396

0 commit comments

Comments
 (0)