Skip to content

Instantly share code, notes, and snippets.

@rhoboro
Last active Jul 15, 2019
Embed
What would you like to do?
Markdownのアウトラインの抽出を行う
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