[OCaml] Mobile-friendly clone of cgit.
fix parse #+begin_example blocks as code blocks
Example blocks were rendered as raw text with the directives visible. Now they are parsed and rendered identically to source blocks but without syntax highlighting (no language specified).
lib/prose/prose_org.ml
@@ -166,6 +166,14 @@
166
166
String.trim line |> String.lowercase_ascii
167
167
|> String.starts_with ~prefix:"#+end_src"
168
168
169
Added:
let is_example_begin line =
170
Added:
String.trim line |> String.lowercase_ascii
171
Added:
|> String.starts_with ~prefix:"#+begin_example"
172
Added:
173
Added:
let is_example_end line =
174
Added:
String.trim line |> String.lowercase_ascii
175
Added:
|> String.starts_with ~prefix:"#+end_example"
176
Added:
169
177
(* {1 Block parsing} *)
170
178
171
179
let is_boundary_common line =
@@ -179,6 +187,7 @@
179
187
is_boundary_common line
180
188
|| Option.is_some (heading line)
181
189
|| Option.is_some (src_begin line)
190
Added:
|| is_example_begin line
182
191
in
183
192
let rec take_paragraph collected = function
184
193
| line :: _ as rest when is_boundary line -> (List.rev collected, rest)
@@ -228,6 +237,13 @@
228
237
let lines, rest = Prose_format.take_until is_src_end [] rest in
229
238
loop
230
239
(Code_block (language, String.concat "\n" lines) :: blocks)
240
Added:
rest
241
Added:
| None when is_example_begin line ->
242
Added:
let lines, rest =
243
Added:
Prose_format.take_until is_example_end [] rest
244
Added:
in
245
Added:
loop
246
Added:
(Code_block (None, String.concat "\n" lines) :: blocks)
231
247
rest
232
248
| None -> (
233
249
match definition_item line with