commonmark.py 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. """Commonmark default options.
  2. This differs to presets.default,
  3. primarily in that it allows HTML and does not enable components:
  4. - block: table
  5. - inline: strikethrough
  6. """
  7. from ..utils import PresetType
  8. def make() -> PresetType:
  9. return {
  10. "options": {
  11. "maxNesting": 20, # Internal protection, recursion limit
  12. "html": True, # Enable HTML tags in source,
  13. # this is just a shorthand for .enable(["html_inline", "html_block"])
  14. # used by the linkify rule:
  15. "linkify": False, # autoconvert URL-like texts to links
  16. # used by the replacements and smartquotes rules
  17. # Enable some language-neutral replacements + quotes beautification
  18. "typographer": False,
  19. # used by the smartquotes rule:
  20. # Double + single quotes replacement pairs, when typographer enabled,
  21. # and smartquotes on. Could be either a String or an Array.
  22. #
  23. # For example, you can use '«»„“' for Russian, '„“‚‘' for German,
  24. # and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
  25. "quotes": "\u201c\u201d\u2018\u2019", # /* “”‘’ */
  26. # Renderer specific; these options are used directly in the HTML renderer
  27. "xhtmlOut": True, # Use '/' to close single tags (<br />)
  28. "breaks": False, # Convert '\n' in paragraphs into <br>
  29. "langPrefix": "language-", # CSS language prefix for fenced blocks
  30. # Highlighter function. Should return escaped HTML,
  31. # or '' if the source string is not changed and should be escaped externally.
  32. # If result starts with <pre... internal wrapper is skipped.
  33. #
  34. # function (/*str, lang, attrs*/) { return ''; }
  35. #
  36. "highlight": None,
  37. },
  38. "components": {
  39. "core": {"rules": ["normalize", "block", "inline", "text_join"]},
  40. "block": {
  41. "rules": [
  42. "blockquote",
  43. "code",
  44. "fence",
  45. "heading",
  46. "hr",
  47. "html_block",
  48. "lheading",
  49. "list",
  50. "reference",
  51. "paragraph",
  52. ]
  53. },
  54. "inline": {
  55. "rules": [
  56. "autolink",
  57. "backticks",
  58. "emphasis",
  59. "entity",
  60. "escape",
  61. "html_inline",
  62. "image",
  63. "link",
  64. "newline",
  65. "text",
  66. ],
  67. "rules2": ["balance_pairs", "emphasis", "fragments_join"],
  68. },
  69. },
  70. }