File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
ghcide/src/Development/IDE/Spans Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -79,12 +79,19 @@ emptySpanDoc :: SpanDoc
79
79
emptySpanDoc = SpanDocText [] (SpanDocUris Nothing Nothing )
80
80
81
81
spanDocToMarkdown :: SpanDoc -> [T. Text ]
82
- spanDocToMarkdown (SpanDocString docs uris)
83
- = [(T. pack $ haddockToMarkdown $ H. toRegular $ H. _doc $ H. parseParas Nothing $ unpackHDS docs) <> T. pack " \n " ]
84
- <> spanDocUrisToMarkdown uris
85
- -- Append the extra newlines since this is markdown --- to get a visible newline,
86
- -- you need to have two newlines
87
- spanDocToMarkdown (SpanDocText txt uris) = map (<> T. pack " \n " ) txt <> [" \n " ] <> spanDocUrisToMarkdown uris
82
+ spanDocToMarkdown = \ case
83
+ (SpanDocString docs uris) ->
84
+ let doc = T. pack $ haddockToMarkdown $ H. toRegular $ H. _doc $ H. parseParas Nothing $ unpackHDS docs
85
+ in go [doc] uris
86
+ (SpanDocText txt uris) -> go txt uris
87
+ where
88
+ go [] uris = spanDocUrisToMarkdown uris
89
+ go txt uris = init txt <> [render (last txt)] <> spanDocUrisToMarkdown uris
90
+ -- If the doc is not end with an `'\n'`, we append it.
91
+ render txt
92
+ | T. null txt = txt
93
+ | T. last txt == ' \n ' = txt
94
+ | otherwise = txt <> T. pack " \n "
88
95
89
96
spanDocUrisToMarkdown :: SpanDocUris -> [T. Text ]
90
97
spanDocUrisToMarkdown (SpanDocUris mdoc msrc) = catMaybes
You can’t perform that action at this time.
0 commit comments