protect_character_in_texinfo.t 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. use strict;
  2. BEGIN {
  3. require Texinfo::ModulePath;
  4. Texinfo::ModulePath::init(undef, undef, 'updirs' => 2);
  5. }
  6. use Test::More;
  7. BEGIN { plan tests => 4; }
  8. use Texinfo::Parser qw(parse_texi_text);
  9. use Texinfo::Common qw(protect_comma_in_tree protect_colon_in_tree
  10. protect_node_after_label_in_tree);
  11. use Texinfo::Convert::Texinfo;
  12. ok(1);
  13. sub run_test($$$$)
  14. {
  15. my $do = shift;
  16. my $in = shift;
  17. my $out = shift;
  18. my $name = shift;
  19. my $tree = parse_texi_text(undef, $in);
  20. if ($do->{'protect_comma'}) {
  21. $tree = protect_comma_in_tree($tree);
  22. }
  23. if ($do->{'protect_colon'}) {
  24. $tree = protect_colon_in_tree($tree);
  25. }
  26. if ($do->{'protect_node_after_label'}) {
  27. $tree = protect_node_after_label_in_tree($tree);
  28. }
  29. my $texi_result = Texinfo::Convert::Texinfo::convert($tree);
  30. if (!defined($out)) {
  31. print STDERR " --> $name:\n$texi_result";
  32. } else {
  33. is ($texi_result, $out, $name);
  34. }
  35. }
  36. run_test({'protect_comma' => 1},
  37. 'Some, text,,,@code{,} @asis{, text} @verb{:v,:} @,c',
  38. 'Some@comma{} text@comma{}@comma{}@comma{}@code{@comma{}} @asis{@comma{} text} @verb{:v,:} @,c',
  39. 'protect comma');
  40. run_test({'protect_colon' => 1},
  41. 'Some :: colons: @code{:} @verb{: in verb::} @:.:',
  42. 'Some @asis{::} colons@asis{:} @code{@asis{:}} @verb{: in verb::} @:.@asis{:}',
  43. 'protect colon');
  44. run_test({'protect_node_after_label' => 1},
  45. "\t\t".'., text @code{,.t.} @verb{:, .:} .'."\t t",
  46. '@asis{ }@asis{.,} text @code{@asis{,.}t@asis{.}} @verb{:, .:} @asis{. } t',
  47. 'protect node after label characters');