8 use lib $Bin, "$Bin/t";
15 name => 'text basic tests',
16 filter_elements => 'Org::Element::Text',
18 * just some heading, not bold*
21 /3) this *is* italic./
22 _5) this is underline._
23 +7) this is strike-through.+
25 ~11) this is verbatim.~
27 unparsed: *ends with spaces *, / start with space/, =no ending. no starting.~
30 test_after_parse => sub {
32 my $doc = $args{result};
33 my $elems = $args{elements};
34 #diag(explain [map {$_->as_string} @$elems]);
35 ok(!$elems->[ 0]->style, "elem 0 normal");
36 is( $elems->[ 1]->style, "B", "elem 2 bold");
37 is( $elems->[ 3]->style, "I", "elem 2 italic");
38 is( $elems->[ 5]->style, "U", "elem 2 underline");
39 is( $elems->[ 7]->style, "S", "elem 2 strike-through");
40 is( $elems->[ 9]->style, "C", "elem 2 code");
41 is( $elems->[11]->style, "V", "elem 2 verbatim");
42 ok(!$elems->[12]->style, "elem 13 normal");
44 is( $elems->[ 0]->as_string, "0) this is normal.\n",
46 is( $elems->[ 1]->as_string, "*1) this /is/ bold.*",
48 is( $elems->[ 3]->as_string, "/3) this *is* italic./",
50 is( $elems->[ 5]->as_string, "_5) this is underline._",
51 "underline as_string");
52 is( $elems->[ 7]->as_string, "+7) this is strike-through.+",
53 "strike-through as_string");
54 is( $elems->[ 9]->as_string, "=9) this is code.=",
56 is( $elems->[11]->as_string, "~11) this is verbatim.~",
57 "verbatim as_string");
61 # emacs only allows a single newline in markup
63 name => 'max newlines',
64 filter_elements => 'Org::Element::Text',
74 test_after_parse => sub {
76 my $doc = $args{result};
77 my $elems = $args{elements};
78 #diag(explain [map {$_->as_string} @$elems]);
79 is( $elems->[0]->style, "C", "elem 0 code");
80 ok(!$elems->[1]->style, "elem 1 normal");
82 is( $elems->[0]->as_string, "=this is\nstill code=",
84 is( $elems->[1]->as_string, "\n\n=this is\nno longer\ncode=\n",
89 # markup can contain links, even *[[link][description with * in it]]*. also
92 name => 'link inside markup',
93 filter_elements => 'Org::Element::Text',
97 test_after_parse => sub {
99 my $doc = $args{result};
100 my $elems = $args{elements};
101 is($elems->[0]->style, "B", "elem 0 bold");
102 is($elems->[0]->children->[0]->as_string, "bolded ",
104 is(ref($elems->[0]->children->[1]), "Org::Element::Link",
105 "link inside bolded");