@@ -1973,6 +1973,206 @@ let%expect_test _ =
1973
1973
end in
1974
1974
()
1975
1975
1976
+ let%expect_test _ =
1977
+ let module Medias = struct
1978
+ let basic_simple =
1979
+ test
1980
+ "{image!foo}\n\n\
1981
+ {audio!foo}\n\n\
1982
+ {video!foo}\n\n\
1983
+ {image:foo}\n\n\
1984
+ {audio:foo}\n\n\
1985
+ {video:foo}";
1986
+ [%expect
1987
+ {|
1988
+ ((output
1989
+ (((f.ml (1 0) (1 11))
1990
+ (simple ((f.ml (1 7) (1 10)) (Reference foo)) "" image))
1991
+ ((f.ml (3 0) (3 11))
1992
+ (simple ((f.ml (3 7) (3 10)) (Reference foo)) "" audio))
1993
+ ((f.ml (5 0) (5 11))
1994
+ (simple ((f.ml (5 7) (5 10)) (Reference foo)) "" video))
1995
+ ((f.ml (7 0) (7 11)) (simple ((f.ml (7 7) (7 10)) (Link foo)) "" image))
1996
+ ((f.ml (9 0) (9 11)) (simple ((f.ml (9 7) (9 10)) (Link foo)) "" audio))
1997
+ ((f.ml (11 0) (11 11))
1998
+ (simple ((f.ml (11 7) (11 10)) (Link foo)) "" video))))
1999
+ (warnings ())) |}]
2000
+
2001
+ let basic =
2002
+ test
2003
+ "{{image!foo}bar}\n\n\
2004
+ {{audio!foo}bar}\n\n\
2005
+ {{video!foo}bar}\n\n\
2006
+ {{image:foo}bar}\n\n\
2007
+ {{audio:foo}bar}\n\n\
2008
+ {{video:foo}bar}";
2009
+ [%expect
2010
+ {|
2011
+ ((output
2012
+ (((f.ml (1 0) (1 16))
2013
+ (simple ((f.ml (1 8) (1 12)) (Reference foo)) bar image))
2014
+ ((f.ml (3 0) (3 16))
2015
+ (simple ((f.ml (3 8) (3 12)) (Reference foo)) bar audio))
2016
+ ((f.ml (5 0) (5 16))
2017
+ (simple ((f.ml (5 8) (5 12)) (Reference foo)) bar video))
2018
+ ((f.ml (7 0) (7 16)) (simple ((f.ml (7 8) (7 12)) (Link foo)) bar image))
2019
+ ((f.ml (9 0) (9 16)) (simple ((f.ml (9 8) (9 12)) (Link foo)) bar audio))
2020
+ ((f.ml (11 0) (11 16))
2021
+ (simple ((f.ml (11 8) (11 12)) (Link foo)) bar video))))
2022
+ (warnings ())) |}]
2023
+
2024
+ let empty =
2025
+ test "{{image!foo}}";
2026
+ [%expect
2027
+ {|
2028
+ ((output
2029
+ (((f.ml (1 0) (1 13))
2030
+ (simple ((f.ml (1 8) (1 12)) (Reference foo)) "" image))))
2031
+ (warnings
2032
+ ( "File \"f.ml\", line 1, characters 11-12:\
2033
+ \n'{{image!...} ...}' (image-reference) should not be empty."))) |}]
2034
+
2035
+ let whitespace =
2036
+ test "{{image!foo} }";
2037
+ [%expect
2038
+ {|
2039
+ ((output
2040
+ (((f.ml (1 0) (1 16))
2041
+ (simple ((f.ml (1 8) (1 12)) (Reference foo)) "" image))))
2042
+ (warnings
2043
+ ( "File \"f.ml\", line 1, characters 11-15:\
2044
+ \n'{{image!...} ...}' (image-reference) should not be empty."))) |}]
2045
+
2046
+ let trimming =
2047
+ test "{{image!foo} hello }";
2048
+ [%expect
2049
+ {|
2050
+ ((output
2051
+ (((f.ml (1 0) (1 27))
2052
+ (simple ((f.ml (1 8) (1 12)) (Reference foo)) hello image))))
2053
+ (warnings ())) |}]
2054
+
2055
+ let nested_markup_is_uninterpreted =
2056
+ test "{{image!foo}{b bar}}";
2057
+ [%expect
2058
+ {|
2059
+ ((output
2060
+ (((f.ml (1 0) (1 20))
2061
+ (simple ((f.ml (1 8) (1 12)) (Reference foo)) "{b bar}" image))))
2062
+ (warnings ())) |}]
2063
+
2064
+ let in_markup =
2065
+ test "{ul {li {{image!foo}bar}}}";
2066
+ [%expect
2067
+ {|
2068
+ ((output
2069
+ (((f.ml (1 0) (1 26))
2070
+ (unordered heavy
2071
+ ((((f.ml (1 8) (1 24))
2072
+ (simple ((f.ml (1 16) (1 20)) (Reference foo)) bar image))))))))
2073
+ (warnings ())) |}]
2074
+
2075
+ let unterminated_image =
2076
+ test "{{image!foo";
2077
+ [%expect
2078
+ {|
2079
+ ((output
2080
+ (((f.ml (1 0) (1 11))
2081
+ (simple ((f.ml (1 8) (1 10)) (Reference foo)) "" image))))
2082
+ (warnings
2083
+ ( "File \"f.ml\", line 1, characters 0-11:\
2084
+ \nOpen bracket '{{image!' is never closed."
2085
+ "File \"f.ml\", line 1, characters 11-11:\
2086
+ \nEnd of text is not allowed in '{{image!...} ...}' (image-reference)."
2087
+ "File \"f.ml\", line 1, characters 11-10:\
2088
+ \n'{{image!...} ...}' (image-reference) should not be empty."))) |}]
2089
+
2090
+ let unterminated_image_simple =
2091
+ test "{image!foo";
2092
+ [%expect
2093
+ {|
2094
+ ((output
2095
+ (((f.ml (1 0) (1 10))
2096
+ (simple ((f.ml (1 7) (1 9)) (Reference foo)) "" image))))
2097
+ (warnings
2098
+ ( "File \"f.ml\", line 1, characters 0-10:\
2099
+ \nOpen bracket '{image!' is never closed."))) |}]
2100
+
2101
+ let unterminated_video =
2102
+ test "{{video!foo";
2103
+ [%expect
2104
+ {|
2105
+ ((output
2106
+ (((f.ml (1 0) (1 11))
2107
+ (simple ((f.ml (1 8) (1 10)) (Reference foo)) "" video))))
2108
+ (warnings
2109
+ ( "File \"f.ml\", line 1, characters 0-11:\
2110
+ \nOpen bracket '{{video!' is never closed."
2111
+ "File \"f.ml\", line 1, characters 11-11:\
2112
+ \nEnd of text is not allowed in '{{video!...} ...}' (video-reference)."
2113
+ "File \"f.ml\", line 1, characters 11-10:\
2114
+ \n'{{video!...} ...}' (video-reference) should not be empty."))) |}]
2115
+
2116
+ let unterminated_video_simple =
2117
+ test "{video!foo";
2118
+ [%expect
2119
+ {|
2120
+ ((output
2121
+ (((f.ml (1 0) (1 10))
2122
+ (simple ((f.ml (1 7) (1 9)) (Reference foo)) "" video))))
2123
+ (warnings
2124
+ ( "File \"f.ml\", line 1, characters 0-10:\
2125
+ \nOpen bracket '{video!' is never closed."))) |}]
2126
+
2127
+ let unterminated_audio =
2128
+ test "{{audio!foo";
2129
+ [%expect
2130
+ {|
2131
+ ((output
2132
+ (((f.ml (1 0) (1 11))
2133
+ (simple ((f.ml (1 8) (1 10)) (Reference foo)) "" audio))))
2134
+ (warnings
2135
+ ( "File \"f.ml\", line 1, characters 0-11:\
2136
+ \nOpen bracket '{{audio!' is never closed."
2137
+ "File \"f.ml\", line 1, characters 11-11:\
2138
+ \nEnd of text is not allowed in '{{audio!...} ...}' (audio-reference)."
2139
+ "File \"f.ml\", line 1, characters 11-10:\
2140
+ \n'{{audio!...} ...}' (audio-reference) should not be empty."))) |}]
2141
+
2142
+ let unterminated_audio_simple =
2143
+ test "{audio!foo";
2144
+ [%expect
2145
+ {|
2146
+ ((output
2147
+ (((f.ml (1 0) (1 10))
2148
+ (simple ((f.ml (1 7) (1 9)) (Reference foo)) "" audio))))
2149
+ (warnings
2150
+ ( "File \"f.ml\", line 1, characters 0-10:\
2151
+ \nOpen bracket '{audio!' is never closed."))) |}]
2152
+
2153
+ let unterminated_content =
2154
+ test "{{image!foo} bar";
2155
+ [%expect
2156
+ {|
2157
+ ((output
2158
+ (((f.ml (1 0) (1 16))
2159
+ (simple ((f.ml (1 8) (1 11)) (Reference foo)) bar image))))
2160
+ (warnings
2161
+ ( "File \"f.ml\", line 1, characters 16-16:\
2162
+ \nEnd of text is not allowed in '{{image!...} ...}' (image-reference)."))) |}]
2163
+
2164
+ let newline_in_content =
2165
+ test "{{image!foo} bar \n baz}";
2166
+ [%expect
2167
+ {|
2168
+ ((output
2169
+ (((f.ml (1 0) (2 5))
2170
+ (simple ((f.ml (1 8) (2 -6)) (Reference foo)) "bar \
2171
+ \n baz" image))))
2172
+ (warnings ())) |}]
2173
+ end in
2174
+ ()
2175
+
1976
2176
let%expect_test _ =
1977
2177
let module Link = struct
1978
2178
let basic =
0 commit comments