Last active
July 15, 2019 09:24
-
-
Save rhoboro/2fbbe82ad4cb7687204937095088dca3 to your computer and use it in GitHub Desktop.
Markdownのアウトラインの抽出を行う
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import unicodedata | |
MAX_LENGTH = 60 | |
CHECK_ONLY_OUTPUT = False | |
def check_line(line): | |
if line.startswith('#'): | |
print(line, end='') | |
def check_file(filename): | |
is_in_code_block = False | |
is_output_line = False | |
for i, line in enumerate(open(filename).readlines()): | |
if "```" in line: | |
is_in_code_block = not is_in_code_block | |
if not is_in_code_block: | |
is_output_line = False | |
if is_in_code_block: | |
continue | |
check_line(line) | |
def main(): | |
filenames = sys.argv[1:] | |
for filename in filenames: | |
check_file(filename) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment