From 8e0201452c5dfe18b9e8140dea7dbce96e578d8e Mon Sep 17 00:00:00 2001 From: Nathan Rebours Date: Thu, 21 Jul 2022 11:41:40 +0200 Subject: [PATCH 1/4] Introduce new syntax for explicit block type This introduce a new, more explicit labels `block-type=...` which is meant to replace the four separate labels `cram`, `ocaml`, `toplevel` and `include` in the future. It is added for a transition period at the end of which the four labels of the apocalypse should be removed in favor of this new one. Signed-off-by: Nathan Rebours --- CHANGES.md | 3 + lib/block.ml | 2 +- lib/label.ml | 82 ++++++++++++------- lib/label.mli | 4 +- .../mdx-test/expect/block-type/test-case.md | 21 +++++ .../expect/block-type/test-case.md.expected | 23 ++++++ test/bin/mdx-test/expect/dune.inc | 12 +++ .../failure/block-type-value/test-case.md | 12 +++ .../block-type-value/test-case.md.expected | 2 + test/bin/mdx-test/failure/dune.inc | 26 ++++++ .../include-without-file-label/test-case.md | 5 ++ .../test-case.md.expected | 1 + test/lib/test_block.ml | 4 +- 13 files changed, 163 insertions(+), 34 deletions(-) create mode 100644 test/bin/mdx-test/expect/block-type/test-case.md create mode 100644 test/bin/mdx-test/expect/block-type/test-case.md.expected create mode 100644 test/bin/mdx-test/failure/block-type-value/test-case.md create mode 100644 test/bin/mdx-test/failure/block-type-value/test-case.md.expected create mode 100644 test/bin/mdx-test/failure/include-without-file-label/test-case.md create mode 100644 test/bin/mdx-test/failure/include-without-file-label/test-case.md.expected diff --git a/CHANGES.md b/CHANGES.md index a10ab881c..1731c5a89 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,9 @@ #### Added - Report all parsing errors in Markdown files (#389, @NathanReb) +- Add alternative syntax for explicitly setting the block-type. + The new label `block-type=...` can be set to `ocaml`, `toplevel`, `cram` or + `include`. (#, @NathanReb) #### Changed diff --git a/lib/block.ml b/lib/block.ml index 4a53ce329..9ebe0270f 100644 --- a/lib/block.ml +++ b/lib/block.ml @@ -414,7 +414,7 @@ let infer_block ~loc ~config ~header ~contents ~errors = let mk ~loc ~section ~labels ~legacy_labels ~header ~contents ~errors = let block_kind = - get_label (function Block_kind x -> Some x | _ -> None) labels + get_label (function Block_type x -> Some x | _ -> None) labels in let config = get_block_config labels in (match block_kind with diff --git a/lib/label.ml b/lib/label.ml index f9f93d73d..f128c74c3 100644 --- a/lib/label.ml +++ b/lib/label.ml @@ -71,7 +71,13 @@ type non_det = Nd_output | Nd_command let default_non_det = Nd_output -type block_kind = OCaml | Cram | Toplevel | Include +type block_type = OCaml | Cram | Toplevel | Include + +let pp_block_type ppf = function + | OCaml -> Fmt.string ppf "ocaml" + | Cram -> Fmt.string ppf "cram" + | Toplevel -> Fmt.string ppf "toplevel" + | Include -> Fmt.string ppf "include" type t = | Dir of string @@ -84,13 +90,7 @@ type t = | Version of Relation.t * Ocaml_version.t | Set of string * string | Unset of string - | Block_kind of block_kind - -let pp_block_kind ppf = function - | OCaml -> Fmt.string ppf "ocaml" - | Cram -> Fmt.string ppf "cram" - | Toplevel -> Fmt.string ppf "toplevel" - | Include -> Fmt.string ppf "include" + | Block_type of block_type let pp ppf = function | Dir d -> Fmt.pf ppf "dir=%s" d @@ -106,7 +106,7 @@ let pp ppf = function Fmt.pf ppf "version%a%a" Relation.pp op Ocaml_version.pp v | Set (v, x) -> Fmt.pf ppf "set-%s=%s" v x | Unset x -> Fmt.pf ppf "unset-%s" x - | Block_kind bk -> pp_block_kind ppf bk + | Block_type bt -> Fmt.pf ppf "block-type=%a" pp_block_type bt let is_prefix ~prefix s = let len_prefix = String.length prefix in @@ -140,41 +140,65 @@ let requires_value ~label ~value f = let requires_eq_value ~label ~value f = requires_value ~label ~value (fun op value -> - match op with Relation.Eq -> Ok (f value) | _ -> non_eq_op ~label) + match op with Relation.Eq -> f value | _ -> non_eq_op ~label) + +let version_of_string s = + match Ocaml_version.of_string s with + | Ok v -> Ok v + | Error (`Msg e) -> Util.Result.errorf "Invalid version: %s." e + +let parse_non_det_value ~label s = + match s with + | "output" -> Ok Nd_output + | "command" -> Ok Nd_command + | s -> + let allowed_values = [ ""; {|"command"|}; {|"output"|} ] in + invalid_value ~label ~allowed_values s + +let parse_block_type_value ~label s = + match s with + | "ocaml" -> Ok OCaml + | "cram" -> Ok Cram + | "toplevel" -> Ok Toplevel + | "include" -> Ok Include + | s -> + let allowed_values = + [ {|"ocaml"|}; {|"cram"|}; {|"toplevel"|}; {|"include"|} ] + in + invalid_value ~label ~allowed_values s let interpret label value = + let open Util.Result.Infix in match label with | "skip" -> doesnt_accept_value ~label ~value Skip - | "ocaml" -> doesnt_accept_value ~label ~value (Block_kind OCaml) - | "cram" -> doesnt_accept_value ~label ~value (Block_kind Cram) - | "toplevel" -> doesnt_accept_value ~label ~value (Block_kind Toplevel) - | "include" -> doesnt_accept_value ~label ~value (Block_kind Include) + | "ocaml" -> doesnt_accept_value ~label ~value (Block_type OCaml) + | "cram" -> doesnt_accept_value ~label ~value (Block_type Cram) + | "toplevel" -> doesnt_accept_value ~label ~value (Block_type Toplevel) + | "include" -> doesnt_accept_value ~label ~value (Block_type Include) | v when is_prefix ~prefix:"unset-" v -> doesnt_accept_value ~label ~value (Unset (split_prefix ~prefix:"unset-" v)) | "version" -> requires_value ~label ~value (fun op v -> - match Ocaml_version.of_string v with - | Ok v -> Ok (Version (op, v)) - | Error (`Msg e) -> - Util.Result.errorf "Invalid `version` label value: %s." e) + version_of_string v >>= fun v -> Ok (Version (op, v))) | "non-deterministic" -> ( match value with | None -> Ok (Non_det None) - | Some (Relation.Eq, "output") -> Ok (Non_det (Some Nd_output)) - | Some (Relation.Eq, "command") -> Ok (Non_det (Some Nd_command)) - | Some (Relation.Eq, v) -> - let allowed_values = [ ""; {|"command"|}; {|"output"|} ] in - invalid_value ~label ~allowed_values v + | Some (Relation.Eq, s) -> + parse_non_det_value ~label s >>= fun nd -> Ok (Non_det (Some nd)) | Some _ -> non_eq_op ~label) - | "dir" -> requires_eq_value ~label ~value (fun x -> Dir x) - | "source-tree" -> requires_eq_value ~label ~value (fun x -> Source_tree x) - | "file" -> requires_eq_value ~label ~value (fun x -> File x) - | "part" -> requires_eq_value ~label ~value (fun x -> Part x) - | "env" -> requires_eq_value ~label ~value (fun x -> Env x) + | "dir" -> requires_eq_value ~label ~value (fun x -> Ok (Dir x)) + | "source-tree" -> + requires_eq_value ~label ~value (fun x -> Ok (Source_tree x)) + | "file" -> requires_eq_value ~label ~value (fun x -> Ok (File x)) + | "part" -> requires_eq_value ~label ~value (fun x -> Ok (Part x)) + | "env" -> requires_eq_value ~label ~value (fun x -> Ok (Env x)) + | "block-type" -> + requires_eq_value ~label ~value (fun x -> + parse_block_type_value ~label x >>= fun bt -> Ok (Block_type bt)) | l when is_prefix ~prefix:"set-" l -> requires_eq_value ~label ~value (fun x -> - Set (split_prefix ~prefix:"set-" l, x)) + Ok (Set (split_prefix ~prefix:"set-" l, x))) | l -> Error (`Msg (Format.sprintf "`%s` is not a valid label." l)) let of_string s = diff --git a/lib/label.mli b/lib/label.mli index fdba0a603..5ae377bfc 100644 --- a/lib/label.mli +++ b/lib/label.mli @@ -29,7 +29,7 @@ type non_det = Nd_output | Nd_command val default_non_det : non_det -type block_kind = OCaml | Cram | Toplevel | Include +type block_type = OCaml | Cram | Toplevel | Include type t = | Dir of string @@ -42,7 +42,7 @@ type t = | Version of Relation.t * Ocaml_version.t | Set of string * string | Unset of string - | Block_kind of block_kind + | Block_type of block_type val pp : Format.formatter -> t -> unit diff --git a/test/bin/mdx-test/expect/block-type/test-case.md b/test/bin/mdx-test/expect/block-type/test-case.md new file mode 100644 index 000000000..fc7370cb1 --- /dev/null +++ b/test/bin/mdx-test/expect/block-type/test-case.md @@ -0,0 +1,21 @@ +It is possible to explicitly state the type of a block using the +`block-type` label, working around language header and content based +inference which can sometime lead to troublesome error messages. + +The following blocks use a volontarily misleading language header that would +normally lead to errors if we let MDX infer the type of block based on them. + +```sh block-type=toplevel +# 1 + 1;; +``` + +```sh block-type=ocaml +let x = 2 +``` + +```ocaml block-type=cram +$ echo "boom" +``` + +The include block type is somewhat redundant with the `file=...` label as +so it is not tested here. diff --git a/test/bin/mdx-test/expect/block-type/test-case.md.expected b/test/bin/mdx-test/expect/block-type/test-case.md.expected new file mode 100644 index 000000000..2060729ea --- /dev/null +++ b/test/bin/mdx-test/expect/block-type/test-case.md.expected @@ -0,0 +1,23 @@ +It is possible to explicitly state the type of a block using the +`block-type` label, working around language header and content based +inference which can sometime lead to troublesome error messages. + +The following blocks use a volontarily misleading language header that would +normally lead to errors if we let MDX infer the type of block based on them. + +```ocaml block-type=toplevel +# 1 + 1;; +- : int = 2 +``` + +```ocaml block-type=ocaml +let x = 2 +``` + +```sh block-type=cram +$ echo "boom" +boom +``` + +The include block type is somewhat redundant with the `file=...` label as +so it is not tested here. diff --git a/test/bin/mdx-test/expect/dune.inc b/test/bin/mdx-test/expect/dune.inc index 54b10eeba..c66e114c3 100644 --- a/test/bin/mdx-test/expect/dune.inc +++ b/test/bin/mdx-test/expect/dune.inc @@ -11,6 +11,18 @@ (alias runtest) (action (diff bash-fence/test-case.md.expected bash-fence.actual))) +(rule + (target block-type.actual) + (deps (package mdx) (source_tree block-type)) + (action + (with-stdout-to %{target} + (chdir block-type + (run ocaml-mdx test --output - test-case.md))))) + +(rule + (alias runtest) + (action (diff block-type/test-case.md.expected block-type.actual))) + (rule (target casual-file-inc.actual) (deps (package mdx) (source_tree casual-file-inc)) diff --git a/test/bin/mdx-test/failure/block-type-value/test-case.md b/test/bin/mdx-test/failure/block-type-value/test-case.md new file mode 100644 index 000000000..b0c586cba --- /dev/null +++ b/test/bin/mdx-test/failure/block-type-value/test-case.md @@ -0,0 +1,12 @@ +This tests that erros are properly reported when the `block-type` label +is misused. + +It requires a value + +```ocaml block-type +``` + +It only accept a fixed set of values + +```ocaml block-type=invalid +``` diff --git a/test/bin/mdx-test/failure/block-type-value/test-case.md.expected b/test/bin/mdx-test/failure/block-type-value/test-case.md.expected new file mode 100644 index 000000000..a94e21377 --- /dev/null +++ b/test/bin/mdx-test/failure/block-type-value/test-case.md.expected @@ -0,0 +1,2 @@ +[mdx] Fatal error: File "test-case.md", lines 6-7: invalid code block: Label `block-type` requires a value. +[mdx] Fatal error: File "test-case.md", lines 11-12: invalid code block: "invalid" is not a valid value for label `block-type`. Valid values are "ocaml", "cram", "toplevel" and "include". diff --git a/test/bin/mdx-test/failure/dune.inc b/test/bin/mdx-test/failure/dune.inc index 9bf381ab6..87739745f 100644 --- a/test/bin/mdx-test/failure/dune.inc +++ b/test/bin/mdx-test/failure/dune.inc @@ -12,6 +12,19 @@ (alias runtest) (action (diff block-locations/test-case.md.expected block-locations.actual))) +(rule + (target block-type-value.actual) + (deps (package mdx) (source_tree block-type-value)) + (action + (with-accepted-exit-codes 1 + (with-outputs-to %{target} + (chdir block-type-value + (run %{bin:ocaml-mdx} test test-case.md)))))) + +(rule + (alias runtest) + (action (diff block-type-value/test-case.md.expected block-type-value.actual))) + (rule (target both-prelude.actual) (deps (package mdx) (source_tree both-prelude)) @@ -65,6 +78,19 @@ (enabled_if (<> %{os_type} Win32)) (action (diff in-toplevel/test-case.md.expected in-toplevel.actual))) +(rule + (target include-without-file-label.actual) + (deps (package mdx) (source_tree include-without-file-label)) + (action + (with-accepted-exit-codes 1 + (with-outputs-to %{target} + (chdir include-without-file-label + (run %{bin:ocaml-mdx} test test-case.md)))))) + +(rule + (alias runtest) + (action (diff include-without-file-label/test-case.md.expected include-without-file-label.actual))) + (rule (target invalid-label.actual) (deps (package mdx) (source_tree invalid-label)) diff --git a/test/bin/mdx-test/failure/include-without-file-label/test-case.md b/test/bin/mdx-test/failure/include-without-file-label/test-case.md new file mode 100644 index 000000000..1d7279202 --- /dev/null +++ b/test/bin/mdx-test/failure/include-without-file-label/test-case.md @@ -0,0 +1,5 @@ +Explicitly setting the block-type to include has little benefits except +for warning you that the `file=...` label is mandatory. + +```ocaml block-type=include +``` diff --git a/test/bin/mdx-test/failure/include-without-file-label/test-case.md.expected b/test/bin/mdx-test/failure/include-without-file-label/test-case.md.expected new file mode 100644 index 000000000..5f6e485ae --- /dev/null +++ b/test/bin/mdx-test/failure/include-without-file-label/test-case.md.expected @@ -0,0 +1 @@ +[mdx] Fatal error: File "test-case.md", lines 4-5: invalid code block: `file` label is required for include blocks. diff --git a/test/lib/test_block.ml b/test/lib/test_block.ml index 86312d883..f9d687bf0 100644 --- a/test/lib/test_block.ml +++ b/test/lib/test_block.ml @@ -38,10 +38,10 @@ let test_mk = (test_name, `Quick, test_fun) in [ - make_test ~name:"invalid ocaml" ~labels:[ Block_kind OCaml ] + make_test ~name:"invalid ocaml" ~labels:[ Block_type OCaml ] ~header:(Some OCaml) ~contents:[ "# let x = 2;;" ] ~expected:(Error (`Msg "toplevel syntax is not allowed in OCaml blocks.")); - make_test ~name:"invalid toplevel" ~labels:[ Block_kind Toplevel ] + make_test ~name:"invalid toplevel" ~labels:[ Block_type Toplevel ] ~header:(Some OCaml) ~contents:[ "let x = 2;;" ] ~expected:(Error (`Msg "invalid toplevel syntax in toplevel blocks.")); ] From 53bfb95954bd048955f1082a77b7d031a5ea6cac Mon Sep 17 00:00:00 2001 From: Nathan Rebours Date: Fri, 22 Jul 2022 12:02:00 +0200 Subject: [PATCH 2/4] Rename block-type label to type Signed-off-by: Nathan Rebours --- lib/label.ml | 4 ++-- test/bin/mdx-test/expect/block-type/test-case.md | 9 ++++++--- .../bin/mdx-test/expect/block-type/test-case.md.expected | 9 ++++++--- test/bin/mdx-test/failure/block-type-value/test-case.md | 6 ++++-- .../failure/block-type-value/test-case.md.expected | 4 ++-- .../failure/include-without-file-label/test-case.md | 3 ++- .../include-without-file-label/test-case.md.expected | 2 +- 7 files changed, 23 insertions(+), 14 deletions(-) diff --git a/lib/label.ml b/lib/label.ml index f128c74c3..3c31ceded 100644 --- a/lib/label.ml +++ b/lib/label.ml @@ -106,7 +106,7 @@ let pp ppf = function Fmt.pf ppf "version%a%a" Relation.pp op Ocaml_version.pp v | Set (v, x) -> Fmt.pf ppf "set-%s=%s" v x | Unset x -> Fmt.pf ppf "unset-%s" x - | Block_type bt -> Fmt.pf ppf "block-type=%a" pp_block_type bt + | Block_type bt -> Fmt.pf ppf "type=%a" pp_block_type bt let is_prefix ~prefix s = let len_prefix = String.length prefix in @@ -193,7 +193,7 @@ let interpret label value = | "file" -> requires_eq_value ~label ~value (fun x -> Ok (File x)) | "part" -> requires_eq_value ~label ~value (fun x -> Ok (Part x)) | "env" -> requires_eq_value ~label ~value (fun x -> Ok (Env x)) - | "block-type" -> + | "type" -> requires_eq_value ~label ~value (fun x -> parse_block_type_value ~label x >>= fun bt -> Ok (Block_type bt)) | l when is_prefix ~prefix:"set-" l -> diff --git a/test/bin/mdx-test/expect/block-type/test-case.md b/test/bin/mdx-test/expect/block-type/test-case.md index fc7370cb1..98b4bd329 100644 --- a/test/bin/mdx-test/expect/block-type/test-case.md +++ b/test/bin/mdx-test/expect/block-type/test-case.md @@ -5,15 +5,18 @@ inference which can sometime lead to troublesome error messages. The following blocks use a volontarily misleading language header that would normally lead to errors if we let MDX infer the type of block based on them. -```sh block-type=toplevel + +```sh # 1 + 1;; ``` -```sh block-type=ocaml + +```sh let x = 2 ``` -```ocaml block-type=cram + +```ocaml $ echo "boom" ``` diff --git a/test/bin/mdx-test/expect/block-type/test-case.md.expected b/test/bin/mdx-test/expect/block-type/test-case.md.expected index 2060729ea..d152dcb8e 100644 --- a/test/bin/mdx-test/expect/block-type/test-case.md.expected +++ b/test/bin/mdx-test/expect/block-type/test-case.md.expected @@ -5,16 +5,19 @@ inference which can sometime lead to troublesome error messages. The following blocks use a volontarily misleading language header that would normally lead to errors if we let MDX infer the type of block based on them. -```ocaml block-type=toplevel + +```ocaml # 1 + 1;; - : int = 2 ``` -```ocaml block-type=ocaml + +```ocaml let x = 2 ``` -```sh block-type=cram + +```sh $ echo "boom" boom ``` diff --git a/test/bin/mdx-test/failure/block-type-value/test-case.md b/test/bin/mdx-test/failure/block-type-value/test-case.md index b0c586cba..71e020bda 100644 --- a/test/bin/mdx-test/failure/block-type-value/test-case.md +++ b/test/bin/mdx-test/failure/block-type-value/test-case.md @@ -3,10 +3,12 @@ is misused. It requires a value -```ocaml block-type + +```ocaml ``` It only accept a fixed set of values -```ocaml block-type=invalid + +```ocaml ``` diff --git a/test/bin/mdx-test/failure/block-type-value/test-case.md.expected b/test/bin/mdx-test/failure/block-type-value/test-case.md.expected index a94e21377..8931f1eff 100644 --- a/test/bin/mdx-test/failure/block-type-value/test-case.md.expected +++ b/test/bin/mdx-test/failure/block-type-value/test-case.md.expected @@ -1,2 +1,2 @@ -[mdx] Fatal error: File "test-case.md", lines 6-7: invalid code block: Label `block-type` requires a value. -[mdx] Fatal error: File "test-case.md", lines 11-12: invalid code block: "invalid" is not a valid value for label `block-type`. Valid values are "ocaml", "cram", "toplevel" and "include". +[mdx] Fatal error: File "test-case.md", lines 6-8: invalid code block: Label `type` requires a value. +[mdx] Fatal error: File "test-case.md", lines 12-14: invalid code block: "invalid" is not a valid value for label `type`. Valid values are "ocaml", "cram", "toplevel" and "include". diff --git a/test/bin/mdx-test/failure/include-without-file-label/test-case.md b/test/bin/mdx-test/failure/include-without-file-label/test-case.md index 1d7279202..45cd9e5b8 100644 --- a/test/bin/mdx-test/failure/include-without-file-label/test-case.md +++ b/test/bin/mdx-test/failure/include-without-file-label/test-case.md @@ -1,5 +1,6 @@ Explicitly setting the block-type to include has little benefits except for warning you that the `file=...` label is mandatory. -```ocaml block-type=include + +```ocaml ``` diff --git a/test/bin/mdx-test/failure/include-without-file-label/test-case.md.expected b/test/bin/mdx-test/failure/include-without-file-label/test-case.md.expected index 5f6e485ae..2deddf767 100644 --- a/test/bin/mdx-test/failure/include-without-file-label/test-case.md.expected +++ b/test/bin/mdx-test/failure/include-without-file-label/test-case.md.expected @@ -1 +1 @@ -[mdx] Fatal error: File "test-case.md", lines 4-5: invalid code block: `file` label is required for include blocks. +[mdx] Fatal error: File "test-case.md", lines 4-6: invalid code block: `file` label is required for include blocks. From 64cd7968a5b83158389249d6cd495bc3725199b0 Mon Sep 17 00:00:00 2001 From: Nathan Rebours Date: Fri, 22 Jul 2022 12:03:15 +0200 Subject: [PATCH 3/4] Update CHANGES.md Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 1731c5a89..d0d536da1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,7 +5,7 @@ - Report all parsing errors in Markdown files (#389, @NathanReb) - Add alternative syntax for explicitly setting the block-type. The new label `block-type=...` can be set to `ocaml`, `toplevel`, `cram` or - `include`. (#, @NathanReb) + `include`. (#385, @NathanReb) #### Changed From 57a0ef152dbc93451335ae1708614241205ea6c5 Mon Sep 17 00:00:00 2001 From: Nathan Rebours Date: Tue, 6 Sep 2022 11:00:44 +0200 Subject: [PATCH 4/4] Fix remaining `block-type` Signed-off-by: Nathan Rebours --- CHANGES.md | 2 +- test/bin/mdx-test/expect/block-type/test-case.md | 4 ++-- test/bin/mdx-test/expect/block-type/test-case.md.expected | 4 ++-- test/bin/mdx-test/failure/block-type-value/test-case.md | 4 ++-- .../mdx-test/failure/include-without-file-label/test-case.md | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d0d536da1..23f9b7eca 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,7 +4,7 @@ - Report all parsing errors in Markdown files (#389, @NathanReb) - Add alternative syntax for explicitly setting the block-type. - The new label `block-type=...` can be set to `ocaml`, `toplevel`, `cram` or + The new label `type=...` can be set to `ocaml`, `toplevel`, `cram` or `include`. (#385, @NathanReb) #### Changed diff --git a/test/bin/mdx-test/expect/block-type/test-case.md b/test/bin/mdx-test/expect/block-type/test-case.md index 98b4bd329..674ac57aa 100644 --- a/test/bin/mdx-test/expect/block-type/test-case.md +++ b/test/bin/mdx-test/expect/block-type/test-case.md @@ -1,6 +1,6 @@ It is possible to explicitly state the type of a block using the -`block-type` label, working around language header and content based -inference which can sometime lead to troublesome error messages. +`type` label to bypass the language header + content based inference, +providing better, more focused error messages. The following blocks use a volontarily misleading language header that would normally lead to errors if we let MDX infer the type of block based on them. diff --git a/test/bin/mdx-test/expect/block-type/test-case.md.expected b/test/bin/mdx-test/expect/block-type/test-case.md.expected index d152dcb8e..00fe5ff35 100644 --- a/test/bin/mdx-test/expect/block-type/test-case.md.expected +++ b/test/bin/mdx-test/expect/block-type/test-case.md.expected @@ -1,6 +1,6 @@ It is possible to explicitly state the type of a block using the -`block-type` label, working around language header and content based -inference which can sometime lead to troublesome error messages. +`type` label to bypass the language header + content based inference, +providing better, more focused error messages. The following blocks use a volontarily misleading language header that would normally lead to errors if we let MDX infer the type of block based on them. diff --git a/test/bin/mdx-test/failure/block-type-value/test-case.md b/test/bin/mdx-test/failure/block-type-value/test-case.md index 71e020bda..a46b38255 100644 --- a/test/bin/mdx-test/failure/block-type-value/test-case.md +++ b/test/bin/mdx-test/failure/block-type-value/test-case.md @@ -1,4 +1,4 @@ -This tests that erros are properly reported when the `block-type` label +This tests that erros are properly reported when the `type` label is misused. It requires a value @@ -7,7 +7,7 @@ It requires a value ```ocaml ``` -It only accept a fixed set of values +It only accepts a fixed set of values ```ocaml diff --git a/test/bin/mdx-test/failure/include-without-file-label/test-case.md b/test/bin/mdx-test/failure/include-without-file-label/test-case.md index 45cd9e5b8..298d518f2 100644 --- a/test/bin/mdx-test/failure/include-without-file-label/test-case.md +++ b/test/bin/mdx-test/failure/include-without-file-label/test-case.md @@ -1,4 +1,4 @@ -Explicitly setting the block-type to include has little benefits except +Explicitly setting the `type` to `include` has little benefits except for warning you that the `file=...` label is mandatory.