fieldlist.pl 1022 B

123456789101112131415161718192021222324252627282930313233
  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/Field_List_Extension
  12. use strict;
  13. use v5.10;
  14. AddModuleDescription('fieldlist.pl', 'Field List Extension');
  15. our ($bol, @MyRules);
  16. push(@MyRules, \&FieldListRules);
  17. sub FieldListRules {
  18. # :fieldname: fieldbody
  19. if ($bol && m/\G\s*\:(?=(((\S.*\S)|\S)\:))/cg
  20. or InElement('dd') && m/\G\s*\n(\s)*\:(?=(((\S.*\S)|\S)\:))/cg) {
  21. return CloseHtmlEnvironmentUntil('dd') . OpenHtmlEnvironment('dl', 1, 'fieldlist')
  22. . AddHtmlEnvironment('dt'); # `:' needs special treatment, later
  23. } elsif (InElement('dt') and m/\G\:[ \t]*(?=((\S)+))/cg) {
  24. return CloseHtmlEnvironment() . AddHtmlEnvironment('dd');
  25. }
  26. return;
  27. }