A fork of hyde, the static site generation. Some patches will be pushed upstream.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

48 lines
1.1 KiB

  1. # -*- coding: utf-8 -*-
  2. """
  3. Markings plugin
  4. """
  5. from hyde.ext.plugins.texty import TextyPlugin
  6. class MarkingsPlugin(TextyPlugin):
  7. """
  8. The plugin class for mark text replacement.
  9. """
  10. def __init__(self, site):
  11. super(MarkingsPlugin, self).__init__(site)
  12. @property
  13. def tag_name(self):
  14. """
  15. The mark tag.
  16. """
  17. return 'mark'
  18. @property
  19. def default_open_pattern(self):
  20. """
  21. The default pattern for mark open text.
  22. """
  23. return u'^§§+\s*([A-Za-z0-9_\-]+)\s*$'
  24. @property
  25. def default_close_pattern(self):
  26. """
  27. The default pattern for mark close text.
  28. """
  29. return u'^§§+\s*([A-Za-z0-9_\-]*)\s*\.\s*$'
  30. def text_to_tag(self, match, start=True):
  31. """
  32. Replace open pattern (default:§§ CSS)
  33. with
  34. {% mark CSS %} or equivalent and
  35. Replace close pattern (default: §§ CSS.)
  36. with
  37. {% endmark %} or equivalent
  38. """
  39. text = super(MarkingsPlugin, self).text_to_tag(match, start)
  40. print text
  41. return text