public
Last active

  • Download Gist
extracturls.hs
Haskell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
-- 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)
print_missing_images.sh
Shell
1
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),)"

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.