Skip to content

Instantly share code, notes, and snippets.

@rhoboro
Last active July 15, 2019 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhoboro/2fbbe82ad4cb7687204937095088dca3 to your computer and use it in GitHub Desktop.
Save rhoboro/2fbbe82ad4cb7687204937095088dca3 to your computer and use it in GitHub Desktop.
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