INNER CODE UNIT · Python
strip_code
awesome-android-root/awesome-android-root · scripts/check_links.py:51
def strip_code(text):
"""Blank out fenced code blocks & inline code so links there are skipped."""
text = re.sub(r'```.*?```', ' ' * 100000, text, flags=re.S)
text = re.sub(r'`[^`]*`', ' ', text)
return text
def find_target(path, dirn):
"""Resolve an in-doc link target to a file path."""
if path.startswith('/'):
if path.endswith('/'):
return os.path.join(DOCS, path.lstrip('/'), 'index.md')
p = path.lstrip('/')
cand = os.path.join(DOCS, p)
if os.path.isfile(cand):
return cand
for ext in ('', '.md', '/index.md'):
c = cand + ext