Skip to content

Instantly share code, notes, and snippets.

@docsteveharris
Last active December 13, 2016 22:52
Show Gist options
  • Save docsteveharris/e8f56833a532c04860df to your computer and use it in GitHub Desktop.
Save docsteveharris/e8f56833a532c04860df to your computer and use it in GitHub Desktop.
#! /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
@docsteveharris
Copy link
Author

Full explanation here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment