Skip to content

Commit 6460633

Browse files
authored
Apply workaround for Block_line.list_of_string (#4)
1 parent 60c2166 commit 6460633

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

ocaml-lsp-server/src/doc_to_md.ml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ and inline_element_list_to_inlines inlines =
7676
let inlines = List.map ~f:inline_element_to_inline inlines in
7777
Inline.Inlines (inlines, Meta.none)
7878

79+
(** Hack: Because of bug described here:
80+
https://github.com/dbuenzli/cmarkit/issues/7 , we use only first block line.
81+
It contains whole string, which seems good enough for our use cases. To be
82+
removed when: https://github.com/dbuenzli/cmarkit/pull/8 gets merged and
83+
released *)
84+
let block_lines_of_string str = [ List.hd (Block_line.list_of_string str) ]
85+
7986
let rec nestable_block_element_to_block
8087
(nestable :
8188
Odoc_parser.Ast.nestable_block_element Odoc_parser.Loc.with_location) =
@@ -133,18 +140,18 @@ let rec nestable_block_element_to_block
133140
| Some ({ value = lang; location = lang_log }, _env) ->
134141
Some (lang, loc_to_meta lang_log)
135142
in
136-
let block_line = Block_line.list_of_string code in
143+
let block_line = block_lines_of_string code in
137144
let code_block = Block.Code_block.make ?info_string block_line in
138145
let meta = loc_to_meta location in
139146
Block.Code_block (code_block, meta)
140147
| Odoc_parser.Loc.{ value = `Verbatim code; location } ->
141148
let info_string = Some ("verb", Meta.none) in
142-
let block_line = Block_line.list_of_string code in
149+
let block_line = block_lines_of_string code in
143150
let code_block = Block.Code_block.make ?info_string block_line in
144151
let meta = loc_to_meta location in
145152
Block.Code_block (code_block, meta)
146153
| Odoc_parser.Loc.{ value = `Math_block code; location } ->
147-
let block_line = Block_line.list_of_string code in
154+
let block_line = block_lines_of_string code in
148155
let code_block = Block.Code_block.make block_line in
149156
let meta = loc_to_meta location in
150157
Block.Ext_math_block (code_block, meta)

ocaml-lsp-server/test/e2e/__tests__/textDocument-signatureHelp.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,15 +381,13 @@ describe_opt("textDocument/completion", () => {
381381
\`\`\`
382382
let square x = x * x
383383
let result = square 3
384-
let result = square 3
385384
\`\`\`
386385
387386
### Verbatim
388387
389388
\`\`\`verb
390389
This text will be displayed verbatim.
391390
No formatting will be applied.
392-
No formatting will be applied.
393391
\`\`\`
394392
395393
### Module List

0 commit comments

Comments
 (0)