htmlcomment.pl 915 B

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright (C) 2008 Weakish Jiang <weakish@gmail.com>
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License version 2 as
  5. # published by the Free Software Foundation.
  6. #
  7. # You can get a copy of GPL version 2 at
  8. # http://www.gnu.org/licenses/gpl-2.0.html
  9. #
  10. # For user doc, see:
  11. # http://www.oddmuse.org/cgi-bin/oddmuse/Html_Comment_Extension
  12. use strict;
  13. use v5.10;
  14. AddModuleDescription('htmlcomment.pl', 'Html Comment Extension');
  15. our ($bol, @MyRules);
  16. push(@MyRules, \&HtmlCommentRules);
  17. sub HtmlCommentRules {
  18. # /*
  19. # This is a comment.
  20. # */
  21. # This RegExp is borrowed from creole.pl shamelessly.
  22. if ($bol && m/\G\/\*[ \t]*\n(.*?\n)\*\/[ \t]*(\n|\z)/cgs) {
  23. my $str = $1;
  24. $str =~ s/\n \*\//\n\*\//g;
  25. return CloseHtmlEnvironments() . '<!--' . $str . '-->'
  26. . AddHtmlEnvironment('p');
  27. }
  28. return;
  29. }