Skip to content

Commit

Permalink
Fix style issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvain Le Gall committed Oct 27, 2013
1 parent 223a864 commit d58b4dc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
11 changes: 7 additions & 4 deletions src/Markdown.ml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ and skip_blank_line e = match BatEnum.peek e with
and read_nonempty indent e s = match s.[0] with
'!' -> read_heading s
| '*' | '+' | '-' as c when snd_is_space s ->
push_remainder indent s e;
push_remainder indent s e;
read_ul indent c e
| '#' when snd_is_space s -> push_remainder indent s e; read_ol indent e
| '{' when snd_is s '{' -> read_pre (BatString.slice s ~first:2) e
Expand Down Expand Up @@ -206,13 +206,15 @@ and scan s st n =
delimited (fun ~first ~last -> Bold (unescape_slice s ~first ~last)) "*"
s st n
| '_' ->
delimited (fun ~first ~last -> Emph (unescape_slice s ~first ~last)) "__"
delimited
(fun ~first ~last -> Emph (unescape_slice s ~first ~last)) "__"
s st n
| '=' ->
delimited
(fun ~first ~last ->
Struck (scan s
{ max = last; fragments = []; current = new_fragment (); }
{ max = last; fragments = [];
current = new_fragment (); }
first))
"==" s st n
| '!' when matches_at s ~max n "![" ->
Expand Down Expand Up @@ -265,7 +267,8 @@ and scan_past ~delim s ~max n =
let rec loop m ~max =
if m >= max then None else
match (try Some (Str.search_forward re s m) with Not_found -> None) with
| Some m when m < max && s.[m-1] <> '\\' -> Some (m + String.length delim)
| Some m when m < max && s.[m-1] <> '\\' ->
Some (m + String.length delim)
| Some m when m < max -> loop (m + 1) ~max
| _ -> None (* no match or >= max *)
in loop n ~max
Expand Down
30 changes: 18 additions & 12 deletions test/TestMarkdown.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ let test_read_list test_ctxt =
[Ulist ([Normal [Text "foo bar baz"]], [[Normal [Text "baz"]]])]
"* foo\nbar \n baz\n* baz";
check
[Ulist ([Normal [Text "foo"]; Normal [Text "bar"]], [[Normal [Text "baz"]]])]
[Ulist ([Normal [Text "foo"];
Normal [Text "bar"]], [[Normal [Text "baz"]]])]
"* foo\n\n bar\n* baz";
check
[Ulist ([Normal [Text "foo"]], [])]
Expand Down Expand Up @@ -84,7 +85,8 @@ let test_read_normal test_ctxt =
Text "."]]
"foo *bar* *baz* __foobar__ _foobar_[desc](target)![alt](image).";
check
[Normal [Bold "foo"; Text " "; Struck [Bold "foo"; Emph "bar"; Text "_baz_"]]]
[Normal [Bold "foo"; Text " ";
Struck [Bold "foo"; Emph "bar"; Text "_baz_"]]]
"*foo* ==*foo*__bar___baz_==";
check
[Normal
Expand All @@ -102,7 +104,8 @@ let test_read_normal_unmatched test_ctxt =
check [Normal [Text "foo _ bar"]] "foo _ bar";
check [Normal [Text "foo __ bar"]] "foo __ bar";
check [Normal [Text "foo == bar"]] "foo == bar";
check [Normal [Text "foo == bar"]; Normal [Text "baz =="]] "foo == bar\n\nbaz =="
check [Normal [Text "foo == bar"]; Normal [Text "baz =="]]
"foo == bar\n\nbaz =="

let test_read_pre test_ctxt =
check
Expand Down Expand Up @@ -136,7 +139,8 @@ let test_read_pre test_ctxt =
let test_heading test_ctxt =
for i = 1 to 6 do
check
[Heading (i, [Text "foo "; Link { href_target = "dst"; href_desc = "foo" }])]
[Heading (i, [Text "foo ";
Link { href_target = "dst"; href_desc = "foo" }])]
(String.make i '!' ^ "foo [foo](dst)")
done

Expand All @@ -146,7 +150,9 @@ let test_quote test_ctxt =
check [Normal [Text "foo says:"];
Quote [Normal [Text "xxx:"];
Ulist ([Normal [Text "xxx yyy"]],
[[Normal [Emph "2"]]; [Normal [Text "_2_"]]; [Normal [Bold "3"]]]);
[[Normal [Emph "2"]];
[Normal [Text "_2_"]];
[Normal [Bold "3"]]]);
Quote [Normal [Text "yyy"]; Quote [Normal [Text "zzz"]];
Normal [Text "aaa"]]]]
"foo says:\n\
Expand All @@ -170,15 +176,15 @@ let test_quote test_ctxt =
> * two\n\
\n"

let test_oasis test_ctxt =
check
[Normal
let test_oasis test_ctxt =
check
[Normal
[Text "OASIS generates a full configure, build and install system \
for your application. It starts with a simple ";
Code "_oasis";
Text " file at the toplevel of your project and creates everything \
required."];
Normal
Normal
[Text "It uses external tools like OCamlbuild and it can be considered \
as the glue between various subsystems that do the job. It \
should support the following tools:"];
Expand All @@ -205,18 +211,18 @@ project and creates everything required.
It uses external tools like OCamlbuild and it can be considered as the glue
between various subsystems that do the job. It should support the following
tools:
tools:
- OCamlbuild
- OMake (todo)
- OCamlMakefile (todo)
- ocaml-autoconf (todo)
It also features a do-it-yourself command line invocation and an internal
It also features a do-it-yourself command line invocation and an internal
configure/install scheme. Libraries are managed through findlib. It has been
tested on GNU Linux and Windows.
It also allows to have standard entry points and description. It helps to
It also allows to have standard entry points and description. It helps to
integrates your libraries and software with third parties tools like GODI."

let tests =
Expand Down
2 changes: 1 addition & 1 deletion test/test.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(* Copyright (C) 2009 Mauricio Fernandez <mfp@acm.org> *)
open OUnit2

let tests =
let tests =
"Markdown" >:::
[
TestMarkdown.tests;
Expand Down

0 comments on commit d58b4dc

Please sign in to comment.