mirror of
https://github.com/token2/snapd.git
synced 2026-03-13 11:15:47 -07:00
38 lines
996 B
Python
Executable File
38 lines
996 B
Python
Executable File
#!/usr/bin/python3
|
|
#
|
|
# see http://daringfireball.net/projects/markdown/syntax
|
|
# for the "canonical" reference
|
|
#
|
|
# We support django-markdown which uses python-markdown, see:
|
|
# http://pythonhosted.org/Markdown/
|
|
|
|
import sys
|
|
import codecs
|
|
|
|
|
|
def lint_li(fname, text):
|
|
"""Ensure that the list-items are multiplies of 2"""
|
|
is_clean = True
|
|
for i, line in enumerate(text.splitlines()):
|
|
if line.lstrip().startswith("*") and line.index("*") % 2 != 0:
|
|
print("%s: line %i list has non-2 spaces indent" % (fname, i))
|
|
is_clean = False
|
|
return is_clean
|
|
|
|
|
|
def lint(md_files):
|
|
"""lint all md files"""
|
|
all_clean = True
|
|
for md in md_files:
|
|
with codecs.open(md, "r", "utf-8") as f:
|
|
buf = f.read()
|
|
for fname, func in globals().items():
|
|
if fname.startswith("lint_"):
|
|
all_clean &= func(md, buf)
|
|
return all_clean
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if not lint(sys.argv):
|
|
sys.exit(1)
|