""" ========================= IMAGE LINKS ================================= Turns paragraphs like <~~~~~~~~~~~~~~~~~~~~~~~~ dir/subdir dir/subdir dir/subdir ~~~~~~~~~~~~~~ dir/subdir dir/subdir dir/subdir ~~~~~~~~~~~~~~~~~~~> Into mini-photo galleries. """ import re, markdown import url_manager IMAGE_LINK = """""" SLIDESHOW_LINK = """[slideshow]""" ALBUM_LINK = """ [%s]""" class ImageLinksExtension (markdown.Extension): def extendMarkdown(self, md, md_globals) : md.preprocessors.add("imagelink", ImageLinkPreprocessor(self), "_begin") class ImageLinkPreprocessor (markdown.Preprocessor): def run(self, lines) : url = url_manager.BlogEntryUrl(url_manager.BlogUrl("all"), "2006/08/29/the_rest_of_our") all_images = [] blocks = [] in_image_block = False new_lines = [] for line in lines : if line.startswith("<~~~~~~~") : albums = [] rows = [] in_image_block = True if not in_image_block : new_lines.append(line) else : line = line.strip() if line.endswith("~~~~~~>") or not line : in_image_block = False new_block = "