|
87 | 87 |
|
88 | 88 | let to_html_rec ~config (b: B.t) = |
89 | 89 | let open Config in |
90 | | - let text_to_html ~l ~style = |
| 90 | + let text_to_html ?(border=false) ~l ~style () = |
91 | 91 | let a, bold = attrs_of_style style in |
92 | 92 | let l = List.map H.txt l in |
93 | 93 | let l = if bold then List.map (fun x->H.b [x]) l else l in |
94 | | - H.span ~a:(H.a_class config.cls_text :: (a @ config.a_text)) l in |
| 94 | + let a_border = if border then [H.a_style "border:thin solid"] else [] in |
| 95 | + H.span ~a:(H.a_class config.cls_text :: a_border @ (a @ config.a_text)) l in |
95 | 96 | let loop : |
96 | 97 | 'tags. (B.t -> ([< Html_types.flow5 > `Pre `Span `Div `Ul `Table `P] as 'tags) html) -> B.t -> 'tags html = |
97 | 98 | fun fix b -> |
98 | 99 | match B.view b with |
99 | 100 | | B.Empty -> (H.div [] :> [< Html_types.flow5 > `Pre `Span `Div `P `Table `Ul ] html) |
100 | | - | B.Text {l; style} when style.B.Style.preformatted -> H.pre [text_to_html ~l ~style] |
101 | | - | B.Text {l; style} -> text_to_html ~l ~style |
102 | | - | B.Pad (_, b) |
103 | | - | B.Frame b -> fix b |
| 101 | + | B.Text {l; style} when style.B.Style.preformatted -> H.pre [text_to_html ~l ~style ()] |
| 102 | + | B.Text {l; style} -> text_to_html ~l ~style () |
| 103 | + | B.Pad (_, b) -> fix b |
| 104 | + | B.Frame b -> |
| 105 | + H.div ~a:[H.a_style "border:thin solid"] [ fix b ] |
104 | 106 | | B.Align {h=`Right;inner=b;v=_} -> |
105 | 107 | H.div ~a:[H.a_class ["align-right"]] [ fix b ] |
106 | 108 | | B.Align {h=`Center;inner=b;v=_} -> |
@@ -135,13 +137,23 @@ let to_html_rec ~config (b: B.t) = |
135 | 137 | let l = Array.to_list l in |
136 | 138 | (match B.view b with |
137 | 139 | | B.Text {l=tl; style} -> |
138 | | - H.details (H.summary [text_to_html ~l:tl ~style]) |
| 140 | + H.details (H.summary [text_to_html ~l:tl ~style ()]) |
139 | 141 | [ H.ul (List.map (fun x -> H.li [to_html_rec x]) l) ] |
140 | | - | _ -> |
| 142 | + | B.Frame b -> |
| 143 | + (match B.view b with |
| 144 | + | (B.Text {l=tl; style}) -> |
| 145 | + H.details (H.summary [text_to_html ~border:true ~l:tl ~style ()]) |
| 146 | + [ H.ul (List.map (fun x -> H.li [to_html_rec x]) l) ] |
| 147 | + | _ -> |
141 | 148 | H.div |
142 | | - [ to_html_rec b |
143 | | - ; H.ul (List.map (fun x -> H.li [to_html_rec x]) l) |
144 | | - ]) |
| 149 | + [ to_html_rec b |
| 150 | + ; H.ul (List.map (fun x -> H.li [to_html_rec x]) l) |
| 151 | + ]) |
| 152 | + | _ -> |
| 153 | + H.div |
| 154 | + [ to_html_rec b |
| 155 | + ; H.ul (List.map (fun x -> H.li [to_html_rec x]) l) |
| 156 | + ]) |
145 | 157 | | B.Link {uri; inner} -> |
146 | 158 | H.div [H.a ~a:[H.a_href uri] [to_html_nondet_rec inner]] |
147 | 159 | | _ -> loop to_html_rec b |
|
0 commit comments