tweak_manpage 892 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/perl -i -p
  2. # Make some hyphens unbreakable.
  3. s{(--\w[-\w]+)}{ $x = $1; $x =~ s/-/\\-/g; $x }eg;
  4. s/(?<!\\)-(['"\d*])/\\-$1/g;
  5. s#(['"(= /,])-(?!-)#$1\\-#g;
  6. s/(\\fB)-/$1\\-/g;
  7. s/(\[\w)-(\w\])/$1\\-$2/g;
  8. s{(\\f\(CW.*?\\fP)}{ $x = $1; $x =~ s/(?<!\\)-/\\-/g; $x }eg;
  9. s/(\.\w+)-/$1\\-/g;
  10. # We only need to use "\&'" or "\&." at the start of a line.
  11. s/(?<=.)\\\&(['.])/$1$2/g;
  12. # Use an em-dash where appropriate.
  13. s/ \\?-{1,2} / \\(em /g;
  14. # Some quotes turn into open/close quotes.
  15. s/'(.)'/\\(oq$1\\(cq/g;
  16. s/(^|[ (])"(?!( |$))/$1\\(lq/gm;
  17. s/(?<! )"([.,:;! )]|$)/\\(rq$1/gm;
  18. s/(\\\(lq[^(]*) "( |$)/$1 \\(rq$2/gm;
  19. s/(^| )" ([^(]*\\\(rq)/$1\\(lq $2/gm;
  20. # And some don't.
  21. s/^([. ])(.*)/ $1 . realquotes($2) /egm;
  22. s/(\\f(B|\(CW).*?\\fP)/ realquotes($1) /egs;
  23. s/^\\\&(\\\(oq)/$1/gm;
  24. sub realquotes
  25. {
  26. my($txt) = @_;
  27. $txt =~ s/\\\([lr]q/"/g;
  28. $txt =~ s/\\\([oc]q/'/g;
  29. $txt;
  30. }