Skip to content

Commit

Permalink
Fix lists generation
Browse files Browse the repository at this point in the history
Signed-off-by: Marcello Seri <[email protected]>
  • Loading branch information
mseri committed Jun 25, 2021
1 parent 9a6d3a3 commit 9b9ecd8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## 0.5.0 (2021-06-25)
- improve generation of (un)ordered lists
- port to omd 2.0.0~alpha2

## 0.4.0 (2021-06-25)
Expand Down
13 changes: 9 additions & 4 deletions src/backend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ let rec block ctx (bl : 'attr Omd.block) =
| List (_attr, ty, sp, bl) ->
let sign =
match ty with
| Ordered _ -> "+ "
| Bullet _ -> "- "
| Ordered _ -> "{+ "
| Bullet _ -> "{- "
in
let li t =
let block' (t : 'attr Omd.block) =
Expand All @@ -177,9 +177,14 @@ let rec block ctx (bl : 'attr Omd.block) =
| _ -> block ctx t
in
let nl = if sp = Tight then Null else nl in
Surround (sign, concat nl (concat_map block' t), "")
Surround (sign, concat nl (concat_map block' t), "}")
in
concat nl (concat_map li bl)
let list_type =
match ty with
| Ordered _ -> "{ol "
| Bullet _ -> "{ul "
in
concat (Surround (list_type, concat_map li bl, "}")) nl
| Code_block (_attr, _label, code) -> BlockSurround ("{[\n", text code, "]}")
| Thematic_break _attr -> GeneralBlock (text "***")
| Html_block (_attr, body) -> raw body
Expand Down
6 changes: 3 additions & 3 deletions tests/readme-min-header-3.expected
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ In [dune] you can use it to generate an mld file with
You can see the documentation generated from the latest tagged version of this README at {{: http://mseri.github.io/md2mld/md2mld/index.html} mseri.github.io/md2mld/md2mld/index.html}.

{4 Known issues}

-
{ul {-

Until the new odoc {{: https://github.com/ocaml/odoc/issues/141} fixing #141} is released, the minimal header allowed in the [md] file will be the level 3 one [###].
You can work around this by using the [-min-header 3] flag during the invocation of [md2mld].
-
}{-

If you see an error like ['{0': heading level should be lower than top heading level '0'], this is because in [ocamldoc] the first header must have a level higher than all other headings in the page.
You can safely ignore it or increase the level of the subsequent headings to get rid of it.
}}
6 changes: 3 additions & 3 deletions tests/readme.expected
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ In [dune] you can use it to generate an mld file with
You can see the documentation generated from the latest tagged version of this README at {{: http://mseri.github.io/md2mld/md2mld/index.html} mseri.github.io/md2mld/md2mld/index.html}.

{1 Known issues}

-
{ul {-

Until the new odoc {{: https://github.com/ocaml/odoc/issues/141} fixing #141} is released, the minimal header allowed in the [md] file will be the level 3 one [###].
You can work around this by using the [-min-header 3] flag during the invocation of [md2mld].
-
}{-

If you see an error like ['{0': heading level should be lower than top heading level '0'], this is because in [ocamldoc] the first header must have a level higher than all other headings in the page.
You can safely ignore it or increase the level of the subsequent headings to get rid of it.
}}
16 changes: 8 additions & 8 deletions tests/test.expected
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ let x = "bla"
]}

Hello this is a ordered list

+ One
+ Two
+ Three
{ol {+ One
}{+ Two
}{+ Three
}}

And this is a unordered list

- One
- Two
- Three
{ul {- One
}{- Two
}{- Three
}}

{1 Another header}

Expand Down

0 comments on commit 9b9ecd8

Please sign in to comment.