Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/turbohtml/clean/__init__.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

8 statements  

1""" 

2turbohtml.clean: scrub and tidy HTML -- sanitize against an allowlist, auto-link plain URLs, and minify. 

3 

4The sanitizer replaces `bleach <https://github.com/mozilla/bleach>`__/``nh3``/``html-sanitizer``, the linkifier 

5replaces ``bleach.linkify``/``linkify-it-py``, ``minify`` replaces ``minify-html``/``htmlmin``, the CSS minifier 

6(:func:`minify_css`) replaces ``rcssmin``/``csscompressor``/``cssmin``, and the JavaScript minifier (:func:`minify_js`) 

7replaces ``jsmin``/``rjsmin``. The three minifiers sit together here: ``minify`` for a whole HTML document, 

8:func:`minify_css` for a stylesheet, and :func:`minify_js` for a script. Every configurable entry point takes a frozen, 

9thread-safe config object (:class:`Policy`, :class:`Linkify`, :class:`Minify`, :class:`CSSMinify`, :class:`JSMinify`). 

10""" 

11 

12from __future__ import annotations 

13 

14from turbohtml._html import Minify, collapse_whitespace_node, strip_comments_node, transform_node 

15from turbohtml._internal._cssmin import CSSMinify, minify_css, minify_css_inline 

16from turbohtml._internal._minify import JSMinify, minify, minify_js 

17 

18from ._linkify import ( 

19 DEFAULT_CALLBACKS, 

20 DEFAULT_PHONE_LABELS, 

21 Callback, 

22 LinkCandidate, 

23 LinkDetector, 

24 Linker, 

25 Linkify, 

26 LinkSpan, 

27 PhoneFormat, 

28 PhoneGrouping, 

29 PhoneNumber, 

30 PhoneNumbers, 

31 PhoneType, 

32 linkify, 

33 linkify_node, 

34 nofollow, 

35 target_blank, 

36) 

37from ._sanitizer import ( 

38 DEFAULT_ATTRIBUTES, 

39 DEFAULT_CSS_PROPERTIES, 

40 DEFAULT_SCHEMES, 

41 DEFAULT_TAGS, 

42 OnDisallowed, 

43 Policy, 

44 Removed, 

45 Sanitizer, 

46 Transform, 

47 sanitize, 

48 sanitize_node, 

49 sanitize_report, 

50 sanitize_report_node, 

51) 

52 

53__all__ = [ 

54 "DEFAULT_ATTRIBUTES", 

55 "DEFAULT_CALLBACKS", 

56 "DEFAULT_CSS_PROPERTIES", 

57 "DEFAULT_PHONE_LABELS", 

58 "DEFAULT_SCHEMES", 

59 "DEFAULT_TAGS", 

60 "CSSMinify", 

61 "Callback", 

62 "JSMinify", 

63 "LinkCandidate", 

64 "LinkDetector", 

65 "LinkSpan", 

66 "Linker", 

67 "Linkify", 

68 "Minify", 

69 "OnDisallowed", 

70 "PhoneFormat", 

71 "PhoneGrouping", 

72 "PhoneNumber", 

73 "PhoneNumbers", 

74 "PhoneType", 

75 "Policy", 

76 "Removed", 

77 "Sanitizer", 

78 "Transform", 

79 "collapse_whitespace_node", 

80 "linkify", 

81 "linkify_node", 

82 "minify", 

83 "minify_css", 

84 "minify_css_inline", 

85 "minify_js", 

86 "nofollow", 

87 "sanitize", 

88 "sanitize_node", 

89 "sanitize_report", 

90 "sanitize_report_node", 

91 "strip_comments_node", 

92 "target_blank", 

93 "transform_node", 

94]