File tree 4 files changed +23
-5
lines changed
test/integration/markdown.t
4 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -316,7 +316,7 @@ and item (l : Item.t list) args nesting_level =
316
316
let code, _, content = source_take_until_punctuation code in
317
317
let content =
318
318
if source_contains_text content then
319
- paragraph (source_code content args)
319
+ quote_block ( paragraph (source_code content args) )
320
320
else noop
321
321
in
322
322
render_declaration ~anchor ~doc code content
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ and blocks =
20
20
| List of list_type * blocks list
21
21
| Raw_markup of string
22
22
| Block_separator
23
+ | Prefixed_block of string * blocks (* * Prefix every lines of blocks. *)
23
24
24
25
and list_type = Ordered | Unordered
25
26
@@ -64,11 +65,20 @@ let paragraph i = Block i
64
65
65
66
let code_block s = CodeBlock s
66
67
68
+ let quote_block b = Prefixed_block (" > " , b)
69
+
67
70
let heading level i =
68
71
let make_hashes n = String. make n '#' in
69
72
let hashes = make_hashes level in
70
73
Block (String hashes ++ i)
71
74
75
+ (* * Every lines that [f] formats are prefixed and written in [sink].
76
+ Inefficient. *)
77
+ let with_prefixed_formatter prefix sink f =
78
+ let s = Format. asprintf " %t" f in
79
+ String. split_on_char '\n' s
80
+ |> List. iter (fun l -> Format. fprintf sink " %s%s@\n " prefix l)
81
+
72
82
let pp_list_item fmt list_type (b : blocks ) n pp_blocks =
73
83
match list_type with
74
84
| Unordered -> Format. fprintf fmt " - @[%a@]" pp_blocks b
@@ -109,3 +119,5 @@ let rec pp_blocks fmt b =
109
119
in
110
120
pp_list 0 l
111
121
| Raw_markup s -> Format. fprintf fmt " %s" s
122
+ | Prefixed_block (p , b ) ->
123
+ with_prefixed_formatter p fmt (fun fmt -> pp_blocks fmt b)
Original file line number Diff line number Diff line change @@ -55,6 +55,8 @@ val paragraph : inlines -> blocks
55
55
56
56
val code_block : string -> blocks
57
57
58
+ val quote_block : blocks -> blocks
59
+
58
60
val heading : int -> inlines -> blocks
59
61
60
62
val pp_blocks : Format .formatter -> blocks -> unit
Original file line number Diff line number Diff line change 34
34
35
35
# ##### val x :
36
36
37
- [t](# type-t)
37
+ > [t](# type-t)
38
+
38
39
39
40
Doc for `val x `
40
41
41
42
<a id="type-a" ></a >
42
43
43
44
# ##### type a =
44
45
45
- [t](# type-t)
46
+ > [t](# type-t)
47
+
46
48
47
49
Type alias
48
50
88
90
89
91
# ##### val y :
90
92
91
- [ `One | `Two ]
93
+ > [ `One | `Two ]
94
+
92
95
93
96
Polymorphic variant.
94
97
98
101
99
102
# ##### val z :
100
103
101
- [t](# type-t) -> ( [t](#type-t) -> [t](#type-t) ) -> foo : [t](#type-t) -> ? bar : [t](#type-t) -> [ `One of [t](#type-t) ] -> [t](#type-t) * [t](#type-t)
104
+ > [t](# type-t) -> ( [t](#type-t) -> [t](#type-t) ) -> foo : [t](#type-t) -> ? bar : [t](#type-t) -> [ `One of [t](#type-t) ] -> [t](#type-t) * [t](#type-t)
105
+
102
106
103
107
Type complicated enough to be rendered differently.
104
108
You can’t perform that action at this time.
0 commit comments