Last active
December 13, 2016 22:52
-
-
Save docsteveharris/e8f56833a532c04860df to your computer and use it in GitHub Desktop.
This file contains 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
#! /usr/bin/python | |
# author: Steve Harris | |
# Convert short nvAlt image links to full path for previewing in Marked | |
# Todo | |
# ==== | |
# - move the pathto line to a variable | |
# - post this script as a gist | |
# Log | |
# === | |
# 140712 | |
# - adapted from https://github.com/potsky/SublimeBuildForMarked/blob/master/Py%20Preprocessor%20for%20Marked/preprocessor.py | |
import sys | |
import re | |
insert_full_image_path = re.compile(r"!\[(.*?)\]\((.*?\.png|jpg|gif|svg|tif|pdf|eps)\)") | |
try: | |
for line in sys.stdin: | |
print re.sub(insert_full_image_path, r"![\1](/users/steve/pictures/nvalt-img/\2)", line) | |
except KeyboardInterrupt: | |
sys.stdout.flush() | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Full explanation here