(md: str, path: str)
| 23 | return r.text |
| 24 | |
| 25 | def __handle_md__(md: str, path: str): |
| 26 | in_code = False |
| 27 | code = '' |
| 28 | content = '' |
| 29 | |
| 30 | md_lines = md.splitlines() |
| 31 | |
| 32 | for line in md_lines: |
| 33 | if in_code: |
| 34 | if re.search("^```[a-zA-Z].*", line): |
| 35 | continue |
| 36 | |
| 37 | if re.search("^```$", line): |
| 38 | in_code = False |
| 39 | continue |
| 40 | |
| 41 | code += line + '\n' |
| 42 | continue |
| 43 | |
| 44 | if line.startswith("<!--"): |
| 45 | in_code = True |
| 46 | (uri, start, end) = __split_url_and_range__(line.split(' ')[1]) |
| 47 | content = "\n".join(__fetch_raw__(uri).splitlines()[start-1:end]).rstrip() |
| 48 | continue |
| 49 | |
| 50 | if code != '': |
| 51 | if code.rstrip() != content: |
| 52 | print("Error in", path) |
| 53 | print("Code in book:") |
| 54 | print(code) |
| 55 | print("Code from github:") |
| 56 | print(content) |
| 57 | sys.exit(1) |
| 58 | |
| 59 | code = '' |
| 60 | content = '' |
| 61 | continue |
| 62 | |
| 63 | def __main__(): |
| 64 | path = '' |
no test coverage detected