Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate opam file, dune.3, omd.2.0.0~alpha3, emit tables! #15

Merged
merged 2 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
_build
*.install
.merlin
_opam
19 changes: 18 additions & 1 deletion dune-project
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
(lang dune 2.0)
(lang dune 3.6)
(name md2mld)

(generate_opam_files true)
(formatting (enabled_for dune))

(license "ISC")
(source (github mseri/md2mld))
(documentation "https://mseri.github.io/md2mld/")
(authors "Marcello Seri <marcello.seri@gmail.com>")
(maintainers "Marcello Seri <marcello.seri@gmail.com>")

(package
(name md2mld)
(synopsis "Little cli tool to convert md files into mld files")
(depends
(ocaml (>= "4.08"))
base-bytes
(omd (>= "2.0.0~alpha3"))))
23 changes: 17 additions & 6 deletions md2mld.opam
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
name: "md2mld"
synopsis: "Little cli tool to convert md files into mld files"
maintainer: "Marcello Seri <marcello.seri@gmail.com>"
authors: "Marcello Seri <marcello.seri@gmail.com>"
maintainer: ["Marcello Seri <marcello.seri@gmail.com>"]
authors: ["Marcello Seri <marcello.seri@gmail.com>"]
license: "ISC"
homepage: "https://github.com/mseri/md2mld"
doc: "https://mseri.github.io/md2mld/"
bug-reports: "https://github.com/mseri/md2mld/issues"
depends: [
"dune" {>= "3.6"}
"ocaml" {>= "4.08"}
"dune" {>= "2.0"}
"base-bytes"
"omd" {>= "2.0.0~alpha2"}
"omd" {>= "2.0.0~alpha3"}
"odoc" {with-doc}
]
build: [
["dune" "subst"] {dev}
["dune" "build" "-p" name "-j" jobs "@install" "@runtest" {with-test}]
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://github.com/mseri/md2mld.git"
12 changes: 12 additions & 0 deletions src/backend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,18 @@ let rec block ctx (bl : 'attr Omd.block) =
, inline text
, "}" )
| Definition_list _ -> Null
| Table (_attr, header, rows) ->
(* Heavy syntax, no alignment defined yet *)
let header =
let rows = concat_map (fun (cell, _align) -> Surround ("{th ", inline cell, "}")) header in
Surround ("{tr ", rows, "}") in
let rows =
concat_map (fun row ->
let row = concat_map (fun cell -> Surround ("{td ", inline cell, "}")) row in
Surround ("{tr ", row, "}"))
rows
in
Surround ("{table ", concat header rows, "}")


let of_doc ?(min_head_lvl = 0) doc =
Expand Down
1 change: 1 addition & 0 deletions tests/test.expected
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ another code block?
{!module:Module} <-- An explicit cross reference

{!Module} <-- An inferred cross reference
{table {tr {th foo}{th bar}{th tut}}{tr {td {e baz}}{td bim}{td [who]}}{tr {td per}{td {b lol}}{td dit}}}
Copy link
Owner

@mseri mseri Feb 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we enforce that the table is isolated from the surrounding content by empty lines?

8 changes: 7 additions & 1 deletion tests/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,10 @@ And this is a link [Hello](https://ocaml.org).

<module:Module> <-- An explicit cross reference

<ref:Module> <-- An inferred cross reference
<ref:Module> <-- An inferred cross reference


| foo | bar | tut |
|:----- | ------- | -----:|
| _baz_ | bim | `who` |
| per | **lol** | dit |