tweak_manpage 584 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/perl -i -p
  2. use strict;
  3. use warnings;
  4. # We only need to use "\&'" or "\&." at the start of a line.
  5. s/(?<=.)\\\&(['.])/$1/g;
  6. # Some quotes turn into open/close quotes.
  7. s/'(.)'/\\(oq$1\\(cq/g;
  8. s/(^|[ (])"(?!( |$))/$1\\(lq/gm;
  9. s/(?<! )"([.,:;! )]|$)/\\(rq$1/gm;
  10. s/(\\\(lq[^(]*) "( |$)/$1 \\(rq$2/gm;
  11. s/(^| )" ([^(]*\\\(rq)/$1\\(lq $2/gm;
  12. # And some don't.
  13. s/^([. ])(.*)/ $1 . realquotes($2) /egm;
  14. s/(\\f(B|\(CW).*?\\fP)/ realquotes($1) /egs;
  15. s/^\\\&(\\\(oq)/$1/gm;
  16. sub realquotes
  17. {
  18. my($txt) = @_;
  19. $txt =~ s/\\\([lr]q/"/g;
  20. $txt =~ s/\\\([oc]q/'/g;
  21. $txt;
  22. }