MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / is_markup

Function is_markup

src/textcode/markup.py:56–76  ·  view source on GitHub ↗

Return True is the file at `location` is some kind of markup, such as HTML, XML, PHP, etc.

(location)

Source from the content-addressed store, hash-verified

54
55
56def is_markup(location):
57 """
58 Return True is the file at `location` is some kind of markup, such as HTML,
59 XML, PHP, etc.
60 """
61 T = get_type(location)
62
63 # do not care for small files
64 if T.size < 64:
65 return False
66
67 if not T.is_text:
68 return False
69
70 if location.endswith(extensions):
71 return True
72
73 with open(location, "rb") as f:
74 start = as_unicode(f.read(1024))
75
76 return is_markup_text(start)
77
78
79def is_markup_text(text):

Callers

nothing calls this directly

Calls 4

as_unicodeFunction · 0.90
get_typeFunction · 0.85
is_markup_textFunction · 0.85
readMethod · 0.45

Tested by

no test coverage detected