[TxMt] By the way...

Allan Odgaard throw-away-1 at macromates.com
Sun Nov 5 12:17:54 UTC 2006


On 5. Nov 2006, at 12:07, Brett Terpstra wrote:

[ abstracting link creation ]
> How do you mean?

Well, something like we make a function:

     module LinkFactory
       module_function

       def create(url, link_text = url, title = "")
         case ENV['TM_SCOPE']
         when /\btext.html.markdown\b/:
           "[#{link_text}](#{url})"
         when /\btext.html\b/:
           "<a href=\"#{url}\"#{" title=\"#{title}\"" unless  
title.empty?}>#{link_text}</a>"
         when …
           …
         end
       end
     end

Then all the commands which generate links (wrap selection, lucky,  
wikipedia, link to blog post, etc.) use LinkFactory.create(…) and we  
just need one version which works nicely with both HTML, Markdown,  
Textile, and possibly other formats.





More information about the textmate mailing list