本站源代码
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.

33 line
1.7KB

  1. // Package blackfriday is a Markdown processor.
  2. //
  3. // It translates plain text with simple formatting rules into HTML or LaTeX.
  4. //
  5. // Sanitized Anchor Names
  6. //
  7. // Blackfriday includes an algorithm for creating sanitized anchor names
  8. // corresponding to a given input text. This algorithm is used to create
  9. // anchors for headings when EXTENSION_AUTO_HEADER_IDS is enabled. The
  10. // algorithm is specified below, so that other packages can create
  11. // compatible anchor names and links to those anchors.
  12. //
  13. // The algorithm iterates over the input text, interpreted as UTF-8,
  14. // one Unicode code point (rune) at a time. All runes that are letters (category L)
  15. // or numbers (category N) are considered valid characters. They are mapped to
  16. // lower case, and included in the output. All other runes are considered
  17. // invalid characters. Invalid characters that preceed the first valid character,
  18. // as well as invalid character that follow the last valid character
  19. // are dropped completely. All other sequences of invalid characters
  20. // between two valid characters are replaced with a single dash character '-'.
  21. //
  22. // SanitizedAnchorName exposes this functionality, and can be used to
  23. // create compatible links to the anchor names generated by blackfriday.
  24. // This algorithm is also implemented in a small standalone package at
  25. // github.com/shurcooL/sanitized_anchor_name. It can be useful for clients
  26. // that want a small package and don't need full functionality of blackfriday.
  27. package blackfriday
  28. // NOTE: Keep Sanitized Anchor Name algorithm in sync with package
  29. // github.com/shurcooL/sanitized_anchor_name.
  30. // Otherwise, users of sanitized_anchor_name will get anchor names
  31. // that are incompatible with those generated by blackfriday.
上海开阖软件有限公司 沪ICP备12045867号-1