Skip to content

Instantly share code, notes, and snippets.

@btbytes
Created December 17, 2011 20:09
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 btbytes/1491227 to your computer and use it in GitHub Desktop.
Save btbytes/1491227 to your computer and use it in GitHub Desktop.
-- extracturls.hs
import Text.Pandoc
extractURL :: Inline -> [String]
extractURL (Link _ (u,_)) = [u]
extractURL (Image _ (u,_)) = [u]
extractURL _ = []
extractURLs :: Pandoc -> [String]
extractURLs = queryWith extractURL
readDoc :: String -> Pandoc
readDoc = readMarkdown defaultParserState
main :: IO ()
main = interact (unlines . extractURLs . readDoc)
cat foo.txt| runhaskell ./extracturls.hs | xargs -0 python -c "import sys,os; fnames=sys.argv[1].split(); foo=[fn for fn in fnames if not os.path.exists(fn)]; print 'missing files: \n%s' % ('\n'.join(foo),)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment