__init__.py 970 B

12345678910111213141516171819202122232425262728
  1. __all__ = ("commonmark", "default", "gfm_like", "js_default", "zero")
  2. from ..utils import PresetType
  3. from . import commonmark, default, zero
  4. js_default = default
  5. class gfm_like: # noqa: N801
  6. """GitHub Flavoured Markdown (GFM) like.
  7. This adds the linkify, table and strikethrough components to CommmonMark.
  8. Note, it lacks task-list items and raw HTML filtering,
  9. to meet the the full GFM specification
  10. (see https://github.github.com/gfm/#autolinks-extension-).
  11. """
  12. @staticmethod
  13. def make() -> PresetType:
  14. config = commonmark.make()
  15. config["components"]["core"]["rules"].append("linkify")
  16. config["components"]["block"]["rules"].append("table")
  17. config["components"]["inline"]["rules"].extend(["strikethrough", "linkify"])
  18. config["components"]["inline"]["rules2"].append("strikethrough")
  19. config["options"]["linkify"] = True
  20. config["options"]["html"] = True
  21. return config