<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Brett Terpstraevernote page  - Brett Terpstra</title>
	<atom:link href="http://brettterpstra.com/tag/evernote/feed/" rel="self" type="application/rss+xml" />
	<link>http://brettterpstra.com</link>
	<description>Elegant solutions to complex problems.</description>
	<lastBuildDate>Tue, 22 May 2012 02:49:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Why a plain-text nerd uses Evernote</title>
		<link>http://brettterpstra.com/why-a-plain-text-nerd-uses-evernote/</link>
		<comments>http://brettterpstra.com/why-a-plain-text-nerd-uses-evernote/#comments</comments>
		<pubDate>Sat, 10 Sep 2011 14:03:24 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[evernote]]></category>
		<category><![CDATA[notes]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/why-a-plain-text-nerd-uses-evernote/</guid>
		<description><![CDATA[<p>People always seem surprised to find out I use Evernote, despite all of the plain-text tools at my fingertips. I thought I’d offer some explanation as to why and how I use Evernote. The biggest knock against Evernote–from myself and others–is that the data isn’t easily portable. Let’s be clear, though, you can export individual notes as HTML files and&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/why-a-plain-text-nerd-uses-evernote/">Why a plain-text nerd uses Evernote</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2011/09/evernote_icon_150x_150.png?9d7bd4" alt="Evernote Icon 150x 150" height="150" width="150" class="alignright">People always seem surprised to find out I use <a href="http://www.evernote.com/">Evernote</a>, despite all of the plain-text tools at my fingertips. I thought I’d offer some explanation as to why and <em>how</em> I use Evernote.</p>

<p>The biggest knock against Evernote–from myself and others–is that the data isn’t easily portable. Let’s be clear, though, you can export individual notes as HTML files and you can mass export notes in a standard XML format that’s not too difficult to work with. You can drag a PDF or other file right out of Evernote. The fact is that Evernote is made for rich text and images; portability gets more difficult when you’re no longer just dealing with text. The <a href="http://reinventedsoftware.com/blog/2010/02/17/evernote-importer-for-together/">Evernote-&gt;Together importer</a> is a great example of making use of these features. <ins datetime="2011-09-10T16:07:49+00:00"><strong>Update:</strong> I almost forgot to mention the <a href="http://enml-editor.ping13.net/">ENML Editor</a> project, a web interface for editing Evernote’s XML output.</ins></p>

<p>Given the above, I don’t use Evernote for “notes” anymore. If I’m typing a note, it’s in a text editor on my phone or <a href="http://brettterpstra.com/project/nvalt/">nvALT</a> on the desktop. I use Evernote for “temporary” items that make full use of Evernote’s searching, sorting and image recognition capabilities.</p>

<p><span id="more-2737"></span></p>

<p>I use Evernote the most when I travel. It’s the fastest, easiest way to keep tickets, itineraries, reservations and expenses all neatly organized and at synced between all of my devices. When I park my car, I snap a picture of the nearest parking ramp column (with the color and row number) and stick it in the notebook for the trip. I believe in using the right software for the job, and–while <a href="https://www.dropbox.com/">Dropbox</a><sup id="fnref:dropbox"><a href="#fn:dropbox" rel="footnote">1</a></sup> can cover a lot of bases–Evernote excels in this area. I don’t need this data to be portable later; when the trip is over, so is the lifespan of the notes.</p>

<p>I also use Evernote for grabbing images of receipts, both on the road and at home. Being able to snap pictures of paper receipts and print web receipts directly to the same bucket is important, and having automatic OCR on those images is priceless. I generally don’t need to reference my receipts after a year, so this data is temporary as well. If a receipt is for a large purchase or needs a longer lifespan, it’s probably going into my home inventory software or elsewhere anyway.</p>

<p>I know some of the guys at Evernote, and our history <a href="http://www.tuaw.com/2008/03/20/evernote-universal-human-memory-extension/">goes back a ways</a>. I know that they’re passionate about their users, and the safety of their data. I trust Evernote to be there when I’m boarding the plane and–should the need arise–when I’m being audited. I don’t need it for simple notes, Notational Velocity, nvALT and plain text in general are faster, more portable and work across my devices. PDFs and images just make more sense in Evernote, so that’s what I use.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:dropbox">
<p>Dropbox is great for making files available on your iPhone, but the OpenMeta tagging system I use on my desktop and laptop doesn’t sync to my mobile devices. I don’t like depending entirely on folders when I need to find something quickly. <a href="#fnref:dropbox" rev="footnote">↩</a></p>
</li>

</ol>
</div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/taking-the-markdown-to-evernote-service-further/' rel='bookmark' title='Taking the Markdown to Evernote service further'>Taking the Markdown to Evernote service further</a></li>
<li><a href='http://brettterpstra.com/antique-safari-reader-hack-update-with-evernote-goodness/' rel='bookmark' title='Antique Safari Reader hack update with Evernote goodness'>Antique Safari Reader hack update with Evernote goodness</a></li>
<li><a href='http://brettterpstra.com/evernote-site-memory-tagger-for-wordpress/' rel='bookmark' title='Evernote Site Memory tagger for WordPress'>Evernote Site Memory tagger for WordPress</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/why-a-plain-text-nerd-uses-evernote/">Why a plain-text nerd uses Evernote</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/why-a-plain-text-nerd-uses-evernote/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Taking the Markdown to Evernote service further</title>
		<link>http://brettterpstra.com/taking-the-markdown-to-evernote-service-further/</link>
		<comments>http://brettterpstra.com/taking-the-markdown-to-evernote-service-further/#comments</comments>
		<pubDate>Sun, 05 Jun 2011 22:19:30 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[bookmarks]]></category>
		<category><![CDATA[evernote]]></category>
		<category><![CDATA[markdown]]></category>
		<category><![CDATA[multimarkdown]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=2373</guid>
		<description><![CDATA[<p>Martin Kopischke has taken my little Markdown to Evernote Service and made it whole. I dropped the project pretty quickly as I stopped using Evernote as my primary storage for text notes, and I left it in pretty poor shape. Martin has fixed that. The new Service adds way better tag handling, MultiMarkdown-style metadata hooks for Notebook, tags and more,&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/taking-the-markdown-to-evernote-service-further/">Taking the Markdown to Evernote service further</a></p>]]></description>
			<content:encoded><![CDATA[<p>Martin Kopischke has taken my little <a href="http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/">Markdown to Evernote Service</a> and made it whole. I dropped the project pretty quickly as I stopped using Evernote as my primary storage for text notes, and I left it in pretty poor shape. <a href="http://nsuserview.kopischke.net/">Martin has fixed that</a>.</p>

<p>The new Service adds way better tag handling, MultiMarkdown-style metadata hooks for Notebook, tags and more, and generally amped up the parser and error handling, as well as the Evernote side of things. <a href="http://nsuserview.kopischke.net/">Check it out at NSUserView</a>. Thanks Martin, nice work!</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/' rel='bookmark' title='A better System Service for Evernote clipping — with MultiMarkdown'>A better System Service for Evernote clipping — with MultiMarkdown</a></li>
<li><a href='http://brettterpstra.com/antique-safari-reader-hack-update-with-evernote-goodness/' rel='bookmark' title='Antique Safari Reader hack update with Evernote goodness'>Antique Safari Reader hack update with Evernote goodness</a></li>
<li><a href='http://brettterpstra.com/clippable-to-evernote-snow-leopard-service/' rel='bookmark' title='Clippable to Evernote Snow Leopard Service'>Clippable to Evernote Snow Leopard Service</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/taking-the-markdown-to-evernote-service-further/">Taking the Markdown to Evernote service further</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/taking-the-markdown-to-evernote-service-further/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Evernote Site Memory tagger for WordPress</title>
		<link>http://brettterpstra.com/evernote-site-memory-tagger-for-wordpress/</link>
		<comments>http://brettterpstra.com/evernote-site-memory-tagger-for-wordpress/#comments</comments>
		<pubDate>Fri, 10 Sep 2010 10:06:52 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[evernote]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=947</guid>
		<description><![CDATA[<p>Evernote introduced Site Memory today, providing an easy way to help people clip to Evernote from your site while maintaining control over how your content appears and is attributed. While some instructions are provided for WordPress, some of us will obviously want to customize things a little further. Brett Kelly posted a quick PHP script on the Evernote WordPress docs&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/evernote-site-memory-tagger-for-wordpress/">Evernote Site Memory tagger for WordPress</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' display:none'  class="headerimg" src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/09/evernotesitememoryheaderimage.jpg?9d7bd4" alt="Header image" /></p>

<p><a href="https://www.evernote.com/">Evernote</a> introduced <a href="http://www.evernote.com/about/developer/sitememory/">Site Memory</a> today, providing an easy way to help people clip to Evernote from your site while maintaining control over how your content appears and is attributed. While some instructions are <a href="http://www.evernote.com/about/developer/sitememory/wordpress.php">provided for WordPress</a>, some of us will obviously want to customize things a little further.</p>

<p><a href="http://brettkelly.org/">Brett Kelly</a> posted a quick PHP script on the Evernote WordPress docs to include the first three tags from your post as suggested tags in the clipper. I wanted to weight these, though, so here’s my version…</p>

<p><span id="more-947"></span></p>

<div markdown=0>
<pre><code>
&lt;a href=&quot;javascript:void()&quot; title=&quot;Clip to Evernote&quot; class=&quot;evernoteclip&quot; 
  onclick=&quot;Evernote.doClip({ title: &#x27;&lt;?php the_title_attribute(); ?&gt;&#x27;,
    providerName: &#x27;Brett Terpstra&#x27;,
    url: &#x27;&lt;?php the_permalink(); ?&gt;&#x27;,
    contentId: &#x27;post-&lt;?php the_ID(); ?&gt;-clip&#x27;,
    suggestTags: &#x27;&lt;?php
    if (get_post_meta($post-&gt;ID, &#x27;evernoteTags&#x27;, true)) {
      echo get_post_meta($post-&gt;ID, &#x27;evernoteTags&#x27;, true);
    } else {
      $posttags = get_the_tags();
      $out = array();
      if ($posttags) {
        foreach($posttags as $tag) {
          $out[trim($tag-&gt;name)] = intval($tag-&gt;count); 
        }
        ksort($out,SORT_NUMERIC);
        echo implode(array_keys(array_slice($out, 0, 3)),&#x27;,&#x27;);
      }
    }?&gt;&#x27;});return false;&quot;&gt;
&lt;img src=&quot;&lt;?php bloginfo(&#x27;template_url&#x27;); ?&gt;/images/evernoteclipper.png&quot; alt=&quot;Evernote Clipper Icon&quot;/&gt;
&lt;/a&gt;
</code></pre>
</div>

<p>It first checks for a custom field called “evernoteTags,” so you can override the whole thing by specifying up to three tags in a custom field in the post editor. The tags should be separated by commas, spaces aren’t important: “tag1,tag2,tag3”, no quotes. Moving on…</p>

<p>The rest of the code grabs all of the tags for the post and their use counts on your site, sorts by the use count and outputs the tag names. Pretty simple.</p>

<p>I should also note that the JavaScript library for the clipper weighs in at 33k compressed, so it’s not a lightweight addition to your blog. I grabbed the online source, minified it and am serving it from a CDN, so the hit was minimized, but still there. I’m also loading the clipper image from my CDN, just to avoid the extra offsite hit. I may eventually attempt to lazy load the script only when the link is clicked, but this works for now.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/antique-safari-reader-hack-update-with-evernote-goodness/' rel='bookmark' title='Antique Safari Reader hack update with Evernote goodness'>Antique Safari Reader hack update with Evernote goodness</a></li>
<li><a href='http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/' rel='bookmark' title='A better System Service for Evernote clipping — with MultiMarkdown'>A better System Service for Evernote clipping — with MultiMarkdown</a></li>
<li><a href='http://brettterpstra.com/taking-the-markdown-to-evernote-service-further/' rel='bookmark' title='Taking the Markdown to Evernote service further'>Taking the Markdown to Evernote service further</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/evernote-site-memory-tagger-for-wordpress/">Evernote Site Memory tagger for WordPress</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/evernote-site-memory-tagger-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EverSave revisited, now with session restore!</title>
		<link>http://brettterpstra.com/eversave-revisited-now-with-session-restore/</link>
		<comments>http://brettterpstra.com/eversave-revisited-now-with-session-restore/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 01:50:46 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[evernote]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[snow leopard]]></category>
		<category><![CDATA[System Service]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=744</guid>
		<description><![CDATA[<p>Safari 5 has brought several solutions for managing lists of open tabs, from the simple (like my TabLinks extension) to full session-management capabilities (see the beautiful Sessions extension). However, I’ve found I still like using my EverSave script in many situations, primarily because it allows me to annotate, tag and sync my important sessions for later retrieval. One thing’s been&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/eversave-revisited-now-with-session-restore/">EverSave revisited, now with session restore!</a></p>]]></description>
			<content:encoded><![CDATA[<p>Safari 5 has brought several solutions for managing lists of open tabs, from the simple (like my <a href="http://brettterpstra.com/2010/06/18/tablinks-safari-extension/">TabLinks extension</a>) to full session-management capabilities (see the beautiful <a href="http://dl.dropbox.com/u/8247646/sessions/index.html">Sessions extension</a>). However, I’ve found I still like using my <a href="http://brettterpstra.com/2010/03/06/saving-safari-browsing-sessions-to-evernote/">EverSave script</a> in many situations, primarily because it allows me to annotate, tag and sync my important sessions for later retrieval. One thing’s been bugging me, though, and that’s the inability to do a mass restore on a tab list (i.e. open them all at once).</p>

<p>When I decided to fix this, the first issue was that when EverSave creates the Evernote note, it lets Evernote convert the list from HTML to Rich Text. Once it’s stored in Rich Text Format (RTF), manipulating it via any shell language, including AppleScript, becomes quite difficult. It’s not impossible, but I quickly decided it wasn’t a route I wanted to wander down. Here’s what I <strong>did</strong> do…
<span id="more-744"></span></p>

<h3>Saving tabs to Evernote</h3>

<p>What I ended up doing was modifying what EverSave stored, and including the actual URL in the visible text of the note. It’s not the prettiest solution, but it’s the only way that this particular system will work. I did my best to minimize the visual presence of the URL using the rudimentary markup that Evernote actually pays attention to. The final product looks like this:</p>

<p><img src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/07/EverSaveRevisedBookmarks1.jpg?9d7bd4" alt="EverSaveRevisedBookmarks.jpg" border="0" width="650" height="93" /></p>

<p>The actual layout is still fully controlled by the _template property in the first line, which is the only line that’s changed from the original script. I’m posting the whole thing again, with this minor revision, for convenience. With a little bit of HTML (remember to escape your double quotes), you can modify the template to look however you like. Just keep in mind that Evernote strips 90% of markup out when it creates the note from your HTML, so stick with basic tags. See the <a href="http://brettterpstra.com/2010/03/06/saving-safari-browsing-sessions-to-evernote/">original EverSave post</a> for a breakdown of the script.</p>

<p>Be sure to continue reading after the script to see how we handle the “restore” functionality.</p>


<div class="wp_syntax"><div class="code"><pre class="applescript"><span class="kw3">property</span> _template : <span class="st0">&quot;&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;</span><span class="re0">%url</span><span class="st0">&quot;&gt;&amp;uArr;&lt;/a&gt; %name&lt;/strong&gt; &lt; &lt;small&gt;%url&lt;/small&gt; &gt;&quot;</span>
&nbsp;
<span class="co1">--search and replace function for template</span>
<span class="kw3">on</span> snr<span class="br0">&#40;</span>tofind, toreplace, TheString<span class="br0">&#41;</span>
	<span class="kw3">set</span> ditd <span class="kw3">to</span> <span class="kw1">text</span> <span class="kw1">item</span> <span class="kw1">delimiters</span>
	<span class="kw3">set</span> <span class="kw1">text</span> <span class="kw1">item</span> <span class="kw1">delimiters</span> <span class="kw3">to</span> tofind
	<span class="kw3">set</span> textItems <span class="kw3">to</span> <span class="kw1">text</span> <span class="kw1">items</span> <span class="kw3">of</span> TheString
	<span class="kw3">set</span> <span class="kw1">text</span> <span class="kw1">item</span> <span class="kw1">delimiters</span> <span class="kw3">to</span> toreplace
	<span class="kw3">if</span> <span class="br0">&#40;</span>class <span class="kw3">of</span> TheString <span class="kw3">is</span> <span class="kw1">string</span><span class="br0">&#41;</span> <span class="kw3">then</span>
		<span class="kw3">set</span> res <span class="kw3">to</span> textItems <span class="kw2">as</span> <span class="kw1">string</span>
	<span class="kw3">else</span> <span class="co1">-- if (class of TheString is Unicode text) then</span>
		<span class="kw3">set</span> res <span class="kw3">to</span> textItems <span class="kw2">as</span> Unicode <span class="kw1">text</span>
	<span class="kw3">end</span> <span class="kw3">if</span>
	<span class="kw3">set</span> <span class="kw1">text</span> <span class="kw1">item</span> <span class="kw1">delimiters</span> <span class="kw3">to</span> ditd
	<span class="kw3">return</span> res
<span class="kw3">end</span> snr
&nbsp;
<span class="kw3">set</span> prettyDate <span class="kw3">to</span> <span class="kw1">do shell script</span> <span class="st0">&quot;date '+%A, %B %d, %Y at %l:%M %p'&quot;</span>
<span class="kw3">set</span> theTitle <span class="kw3">to</span> <span class="st0">&quot;Bookmarks &quot;</span> <span class="sy0">&amp;</span> prettyDate
<span class="kw3">set</span> urlList <span class="kw3">to</span> <span class="st0">&quot;&lt;ul&gt;&quot;</span>
&nbsp;
<span class="kw3">tell</span> <span class="kw1">application</span> <span class="st0">&quot;Safari&quot;</span>
	<span class="kw3">set</span> tabList <span class="kw3">to</span> <span class="kw2">every</span> <span class="kw1">tab</span> <span class="kw3">of</span> <span class="kw2">front</span> <span class="kw1">window</span>
	<span class="kw3">repeat</span> <span class="kw3">with</span> aTab <span class="kw3">in</span> tabList
		<span class="kw3">set</span> aLink <span class="kw3">to</span> _template
		<span class="kw3">set</span> aLink <span class="kw3">to</span> <span class="kw3">my</span> snr<span class="br0">&#40;</span><span class="st0">&quot;%name&quot;</span>, <span class="kw1">name</span> <span class="kw3">of</span> aTab, aLink<span class="br0">&#41;</span>
		<span class="kw3">set</span> aLink <span class="kw3">to</span> <span class="kw3">my</span> snr<span class="br0">&#40;</span><span class="st0">&quot;%url&quot;</span>, URL <span class="kw3">of</span> aTab, aLink<span class="br0">&#41;</span>
		<span class="kw3">set</span> urlList <span class="kw3">to</span> urlList <span class="sy0">&amp;</span> aLink <span class="sy0">&amp;</span> <span class="kw3">return</span>
	<span class="kw3">end</span> <span class="kw3">repeat</span>
<span class="kw3">end</span> <span class="kw3">tell</span>
<span class="kw3">set</span> urlList <span class="kw3">to</span> urlList <span class="sy0">&amp;</span> <span class="st0">&quot;&lt;/ul&gt;&quot;</span>
&nbsp;
<span class="kw3">tell</span> <span class="kw1">application</span> <span class="st0">&quot;Evernote&quot;</span>
	<span class="kw3">set</span> theNote <span class="kw3">to</span> create note <span class="kw3">with</span> html urlList title theTitle notebook <span class="st0">&quot;Bookmarks&quot;</span>
<span class="kw3">end</span> <span class="kw3">tell</span></pre></div></div>


<p>I have this script saved as “EverSave.scpt” in my <code>~/Library/Scripts/Applications/Safari</code> folder (create it if you don’t have it), and launch it using <a href="http://www.red-sweater.com/fastscripts/">FastScripts</a> with a Command-Shift-S shortcut. Safari doesn’t have anything bound to that key-combo, and it’s easy to remember (Save As in most programs).</p>

<h3>Restoring tabs</h3>

<p>This solution makes a few assumptions, but the script is easily customized to handle any differences in your setup. I went with a System Service (Snow Leopard) for the restore function, primarily because it allows me to act directly on selected text in Evernote. It’s a very simple Ruby script that parses the selected text for urls, and then opens any that it finds in sequential order using your default browser. There’s a commented out line if you want to always target Safari directly when opening them, which may be useful in some situations. I use <a href="http://www.choosyosx.com/">Choosy</a>, and have a rule that just directs all of these to Safari. If you have Safari set as your default browser, and that’s where you want to open your links, this will just work as is.</p>

<p>To set up the service:</p>

<ol>
<li>Open Automator and select “Service” as the new file type.</li>
<li>On the right hand side, tell it that “Service receives selected” <strong><em>text</em></strong> in <strong><em>Evernote.app</em></strong> (choose Other… and select Evernote).</li>
<li>Find “Run Shell Script” in the list on the left and drag it into the area on the right.</li>
<li>Set the Shell dropdown to /usr/bin/ruby</li>
<li>Insert the following code, and feel free to modify</li>
<li>Save the result as “EverRestore”</li>
<li>Assign a shortcut key, if desired, in System Preferences &gt; Keyboard &gt; Keyboard Shortcuts &gt; Services</li>
</ol>

<p>Here’s the code for the service:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby">ARGF.<span class="me1">each</span> <span class="kw1">do</span> <span class="sy0">|</span>f<span class="sy0">|</span>
    links = f.<span class="me1">scan</span> <span class="sy0">/&lt;</span> <span class="br0">&#40;</span>https?:<span class="sy0">//</span>.<span class="sy0">*</span>?<span class="br0">&#41;</span> <span class="sy0">&gt;/</span>mi
    <span class="co1"># The above scans specifically for the angle brackets in my template. </span>
    <span class="co1"># If you remove those from the output of EverSave, be sure to update</span>
    <span class="co1"># the regular expression accordingly.</span>
    <span class="kw1">if</span> links.<span class="me1">empty</span>? <span class="kw1">then</span>
        <span class="kw3">exit</span>
    <span class="kw1">else</span>
        links.<span class="me1">each</span> <span class="br0">&#123;</span><span class="sy0">|</span>link<span class="sy0">|</span> <span class="sy0">%</span>x<span class="br0">&#123;</span>osascript <span class="sy0">-</span>e <span class="sy0">&amp;</span><span class="co1">#x27;open location &quot;#{link[0]}&quot;&amp;#x27;}}</span>
        <span class="co1"># links.each {|link| %x{osascript -e &amp;#x27;tell application &quot;Safari&quot; to open location &quot;#{link[0]}&quot;&amp;#x27;} }</span>
    <span class="kw1">end</span>
<span class="kw1">end</span></pre></div></div>


<p>The simple regular expression in line 2 does scan specifically for the angle brackets I used in the new EverSave template. That just relieves some complexity. If you want a regular expression that doesn’t require the angle brackets, try replacing line 2 with this:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby">links = f.<span class="me1">scan</span> <span class="sy0">/</span><span class="br0">&#40;</span>https?:<span class="sy0">//</span><span class="br0">&#40;</span><span class="br0">&#91;</span>^s<span class="st0">&quot;,;]+)..{2,4}(/[^s&quot;</span>,;!<span class="br0">&#93;</span><span class="sy0">+</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">/</span>mi</pre></div></div>


<p>Once it’s saved in Automator, it should be available when you select text in Evernote. If there are visible URLs in the selected text, running this Service will open them in tabs in Safari (or your default browser). You can selectively open certain urls by only selecting the lines that contain the ones you want to open. Non-contiguous selections will require a little text editing, of course.</p>

<h3>Not as hard as it looks… really.</h3>

<p>The explanation got a little long, and probably seems unnecessarily complex. The fact is, I can save a Safari browsing session with one key combo, edit, annotate and tag it (if I want to), then restore it later by highlighting and typing a new command combination. It’s actually quite convenient, and fairly bulletproof. I’d love to hear how you use it, or what you’re doing instead!</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/antique-safari-reader-hack-update-with-evernote-goodness/' rel='bookmark' title='Antique Safari Reader hack update with Evernote goodness'>Antique Safari Reader hack update with Evernote goodness</a></li>
<li><a href='http://brettterpstra.com/clippable-to-evernote-snow-leopard-service/' rel='bookmark' title='Clippable to Evernote Snow Leopard Service'>Clippable to Evernote Snow Leopard Service</a></li>
<li><a href='http://brettterpstra.com/save-safari-tabs-to-instapaper/' rel='bookmark' title='Save Safari tabs to Instapaper'>Save Safari tabs to Instapaper</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/eversave-revisited-now-with-session-restore/">EverSave revisited, now with session restore!</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/eversave-revisited-now-with-session-restore/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Antique Safari Reader hack update with Evernote goodness</title>
		<link>http://brettterpstra.com/antique-safari-reader-hack-update-with-evernote-goodness/</link>
		<comments>http://brettterpstra.com/antique-safari-reader-hack-update-with-evernote-goodness/#comments</comments>
		<pubDate>Sat, 12 Jun 2010 11:45:27 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[evernote]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[reader]]></category>
		<category><![CDATA[safari]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=585</guid>
		<description><![CDATA[<p>I updated the links and information on the main post, but I thought I’d put a little ping out there for RSS readers who might want to upgrade: Evernote web clipper functionality is now complete in the style, and the button in the HUD will open the floating frame, let you add tags and extra text, then clip just the&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/antique-safari-reader-hack-update-with-evernote-goodness/">Antique Safari Reader hack update with Evernote goodness</a></p>]]></description>
			<content:encoded><![CDATA[<p>I updated the links and information on the <a href="http://brettterpstra.com/2010/06/12/safari-reader-antique-hack/">main post</a>, but I thought I’d put a little ping out there for RSS readers who might want to upgrade:</p>

<p>Evernote web clipper functionality is now complete in the style, and the button in the HUD will open the floating frame, let you add tags and extra text, then clip just the visible text in Reader to your main Evernote notebook without ever opening a new page. Exactly what I wanted. Now I just have to add the same thing to Instapaper Beyond!</p>

<p>The style is also now available with and without background images, just <a href="http://brettterpstra.com/2010/06/12/safari-reader-antique-hack/">check the main post</a> for updates.</p>

<div class="download_desc"><p class="download-icon"><a href="http://brettterpstra.com/downloads/AntiqueWBackground.zip?9d7bd4" title="Download Antique Safari Reader style (2573)"><img src="http://cdn2.brettterpstra.com/wp-content/uploads/downloads/thumbnails/2010/11/safariiconantiqued.png?9d7bd4" alt="download image for Antique Safari Reader style" width="64" /></a><br /><a href="http://brettterpstra.com/downloads/AntiqueWBackground.zip?9d7bd4" title="Download Antique Safari Reader style (2573)" class="download-button">Download</a></p><p class="desc"><a href="http://brettterpstra.com/downloads/AntiqueWBackground.zip?9d7bd4" title="Download Antique Safari Reader style (2573)">Antique Safari Reader style</a> — Custom style (hack) for Safari 5\‘s Reader feature. Antique styling/colors with a few nifty features. Now with a fully-functional Evernote clipper. If you don’t want a background image, see the other available download. <a href="http://brettterpstra.com/2010/06/12/safari-reader-antique-hack/">More Info</a></p></div>

<div class="download_desc"><p class="download-icon"><a href="http://brettterpstra.com/downloads/AntiqueNoBG.zip?9d7bd4" title="Download Antique Safari Reader Style (no background image) (1328)"><img src="http://cdn2.brettterpstra.com/wp-content/uploads/downloads/thumbnails/2010/11/safariiconantiqued.png?9d7bd4" alt="download image for Antique Safari Reader Style (no background image)" width="64" /></a><br /><a href="http://brettterpstra.com/downloads/AntiqueNoBG.zip?9d7bd4" title="Download Antique Safari Reader Style (no background image) (1328)" class="download-button">Download</a></p><p class="desc"><a href="http://brettterpstra.com/downloads/AntiqueNoBG.zip?9d7bd4" title="Download Antique Safari Reader Style (no background image) (1328)">Antique Safari Reader Style (no background image)</a> — Same as the Safari Reader Antique hack, but without the slightly-over-the-top background image. Now with a fully-functional Evernote clipper. <a href="http://brettterpstra.com/2010/06/12/safari-reader-antique-hack/">More Info</a></p></div>

<hr />
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/safari-reader-antique-hack/' rel='bookmark' title='Safari Reader Antique hack'>Safari Reader Antique hack</a></li>
<li><a href='http://brettterpstra.com/antique-1-5-for-safari-reader/' rel='bookmark' title='Antique 1.5 for Safari Reader'>Antique 1.5 for Safari Reader</a></li>
<li><a href='http://brettterpstra.com/taking-the-markdown-to-evernote-service-further/' rel='bookmark' title='Taking the Markdown to Evernote service further'>Taking the Markdown to Evernote service further</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/antique-safari-reader-hack-update-with-evernote-goodness/">Antique Safari Reader hack update with Evernote goodness</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/antique-safari-reader-hack-update-with-evernote-goodness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A better System Service for Evernote clipping — with MultiMarkdown</title>
		<link>http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/</link>
		<comments>http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 00:02:09 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[evernote]]></category>
		<category><![CDATA[markdown]]></category>
		<category><![CDATA[multimarkdown]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[snow leopard]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=302</guid>
		<description><![CDATA[<p>Update: If you’re looking for a Markdown -&#62; Evernote, check this out. Another post, quickly and with less explanation… The fact that Evernote processes HTML so much better than it does plain or rich text got me thinking and tinkering. I use Markdown (actually, MultiMarkdown) constantly, and it does a great job of turning plain text into valid markup. With&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/">A better System Service for Evernote clipping — with MultiMarkdown</a></p>]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> If you’re looking for a Markdown -&gt; Evernote, <a href="http://brettterpstra.com/taking-the-markdown-to-evernote-service-further/">check this out</a>.</p>

<p>Another post, quickly and with less explanation…</p>

<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/03/EvernoteIcon-300x300.png?9d7bd4" alt="Evernote Icon" title="EvernoteIcon" width="300" height="300" class="alignright size-medium wp-image-305" />The fact that Evernote processes HTML so much better than it does plain or rich text got me thinking and tinkering. I use <a href="http://daringfireball.net/projects/markdown/">Markdown</a> (actually, <a href="http://fletcherpenney.net/multimarkdown/">MultiMarkdown</a>) constantly, and it does a great job of turning plain text into valid markup. With (Multi)Markdown, even plain text becomes HTML that–when imported into Evernote–retains most of its formatting. To answer your question, no, I’m not obsessed with Evernote, I’m obsessed with problems I think I could solve. It’s unhealthy.</p>

<p><strong><em>Please note</em></strong>, this requires that you have <a href="http://fletcherpenney.net/">Fletcher Penney’s</a> MultiMarkdown installed in <code>~/Library/Application Support/MultiMarkdown</code>, and that the Perl files (MultiMarkdown.pl and SmartyPants.pl) are located in a ‘bin’ subdirectory (which is the default install). If you don’t have MultiMarkdown, you should get it anyway (all the cool kids have it), so head over to the <a href="http://fletcher.github.com/MultiMarkdown/">download page</a> and grab a copy. Now, on with the show.</p>

<p>I set this up originally as a <a href="http://macromates.com/">TextMate</a> command, intending just to be able to clip code snippets and free-form text to Evernote without thinking too much about it. That worked well, so I modified it to work as a System Service. Specifically, a Snow Leopard service, but I’m providing the Ruby script here and it can be modified for any Mac setup you want.</p>

<p>While it will work just fine on plain text with no markup, it does have a couple of “special” features. If you start a line with a <code>#</code> and a space (e.g.: # This is my header), which is a <a href="http://daringfireball.net/projects/markdown/syntax#header">Markdown convention</a> for a first-level heading, it will use that as the title for the note and strip it out of the text in processing. It only uses the first one it finds, but it will strip out any first-level headers in the selection. I’ll probably modify that later, or just have it leave them in. Also, a line that begins with “tags:” followed by a space and a comma-separated list of words will be split up and used to tag the new note. This is also stripped before processing. It handles spaces in multi-word tags, and odd marks at the beginning or end of a tag, <em>but only one punctuation character, and only at the beginning or end of a tag</em>. The code follows…</p>

<p><span id="more-302"></span></p>

<p>Here’s the Ruby code, messy as it may be:</p>

<div markdown=0>
<pre><code>
    #!/usr/bin/env ruby -rjcode -Ku
    # requires that MultiMarkdown be installed in ~/Library/Application Support/MultiMarkdown
    # That, or edit the script to point to yours :)

    ARGF.each do |f|
    input = f
    contents = &#x27;&#x27;
    tags = &#x27;&#x27;
    title = nil

    def e_as(str)
        str.to_s.gsub(/(?=[&quot;\\])/, &#x27;\\&#x27;)
    end
    input.each_line { |line| 
      if line =~ /^# (.*?)/
        title = line[2..-1]
        break
      end
    }
    title = %x{date &#x27;+Clipped note: %A, %B %d, %Y at %l:%M %p&#x27;|tr -s &quot; &quot;} if title.nil?

    input.each_line { |line| 
      if line =~ /^[Tt]ags: /
        tags = line[5..-1].split(&#x27;,&#x27;).map {|tag| tag = tag.strip.gsub(/^(.)?\b|\b(.)?$/,&quot;\\2\&quot;\\1&quot;) }
        break
      end
    }

    IO.popen(&#x27;&quot;$HOME/Library/Application Support/MultiMarkdown/bin/MultiMarkdown.pl&quot;|&quot;$HOME/Library/Application Support/MultiMarkdown/bin/SmartyPants.pl&quot;&#x27;, &quot;r+&quot;) do |io|
     input.each_line { |line| 
        io &lt;&lt; line unless line =~ /^# |[Tt]ags\: /
     }; io.close_write
     io.each_line do |line|
       contents &lt;&lt; line
     end
    end
    tags = &quot; tags {#{tags.join(&quot;,&quot;)}}&quot; unless tags.empty?
    %x{osascript -e &#x27;tell application &quot;Evernote&quot; to create note with html &quot;#{e_as contents}&quot; title &quot;#{title}&quot; notebook &quot;Unfiled&quot;#{tags}&#x27;}
    end
</code></pre>
</div>

<p>You can create a System Service in Automator with it, set up a command in TextMate, or do whatever else you can think of. If you just want to download the service and try it out, I’ve made it <a href="http://brettterpstra.com/downloads/MarkdownToEvernote.zip?9d7bd4">available here</a>. Unzip and copy it to ~/Library/Services (in your home folder). If you set it up as a System Service, assign a shortcut key in the Keyboard pane of System Preferences.</p>

<p>It does choke once in a while, apparently on Markdown-generated code snippets, but I haven’t quite narrowed down why, yet. I’ll update the code if I figure that one out. Overall, though, it makes pretty clippings and allows you to use some Markdown syntax to spice up your text without having to touch the (regrettably abominable) Evernote editor.</p>

<hr />

<div class="download_desc"><p class="download-icon"><a href="http://brettterpstra.com/downloads/MarkdownToEvernote.zip?9d7bd4" title="Download Markdown To Evernote Service (474)"><img src="http://brettterpstra.com/wp-content/images/serviceicon.jpg?9d7bd4" alt="download image for Markdown To Evernote Service" width="64" /></a><br /><a href="http://brettterpstra.com/downloads/MarkdownToEvernote.zip?9d7bd4" title="Download Markdown To Evernote Service (474)" class="download-button">Download</a></p><p class="desc"><a href="http://brettterpstra.com/downloads/MarkdownToEvernote.zip?9d7bd4" title="Download Markdown To Evernote Service (474)">Markdown To Evernote Service</a> — A Snow Leopard System Service that grabs selected text, processes it with MultiMarkdown and clips the resulting HTML to Evernote, creating a nicely formatted note. Uses the first (and hopefully only) Markdown first-level heading (# My headline) as the title for the note, and will look for a line starting with “tags: ” followed by a comma-separated list of tags as well.

Requires that MultiMarkdown be installed in ~/Library/Application Support/MultiMarkdown. <a href="http://brettterpstra.com/2010/03/06/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/">More Info</a></p></div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/taking-the-markdown-to-evernote-service-further/' rel='bookmark' title='Taking the Markdown to Evernote service further'>Taking the Markdown to Evernote service further</a></li>
<li><a href='http://brettterpstra.com/evernote-site-memory-tagger-for-wordpress/' rel='bookmark' title='Evernote Site Memory tagger for WordPress'>Evernote Site Memory tagger for WordPress</a></li>
<li><a href='http://brettterpstra.com/a-service-for-writing-multimarkdown-footnotes-inline/' rel='bookmark' title='A Service for writing MultiMarkdown footnotes inline'>A Service for writing MultiMarkdown footnotes inline</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/">A better System Service for Evernote clipping — with MultiMarkdown</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Saving Safari browsing sessions to Evernote</title>
		<link>http://brettterpstra.com/saving-safari-browsing-sessions-to-evernote/</link>
		<comments>http://brettterpstra.com/saving-safari-browsing-sessions-to-evernote/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 15:45:30 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[evernote]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[websurfing]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=290</guid>
		<description><![CDATA[<p>I primarily use Safari for web browsing, mostly because it’s smoother and faster than Firefox, and the Web Inspector is just as useful as Firebug. As time passes, I end up with a lot of web pages open, and I like to clear out my browser tabs on a regular basis. Safari doesn’t really have a long-term session-saving option, so&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/saving-safari-browsing-sessions-to-evernote/">Saving Safari browsing sessions to Evernote</a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://cdn2.brettterpstra.com/wp-content/uploads/2010/03/EvernoteBookmarksScreenshot-1.jpg?9d7bd4" rel="lightbox"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/03/EvernoteBookmarksScreenshot-1-300x157.jpg?9d7bd4" alt="" title="Evernote Bookmarks" width="300" height="157" class="alignright size-medium wp-image-291" /></a>I primarily use Safari for web browsing, mostly because it’s smoother and faster than Firefox, and the Web Inspector is just as useful as Firebug. As time passes, I end up with a lot of web pages open, and I like to clear out my browser tabs on a regular basis. Safari doesn’t really have a long-term session-saving option, so I save lists of open tabs to various applications. I used to use <a href="http://hetima.com/safari/stand-e.html">SafariStand</a> to do this, but it got too buggy and slow for me. I use <a href="http://flyingmeat.com/voodoopad/">VoodooPad</a> for it, but I like the sorting and searching option in <a href="http://www.evernote.com/">Evernote</a>, both on my desktop, and synced online and to my iPhone.</p>

<p>As much as I love Evernote, its editor is, well, a hassle. Importing text clippings can strip line breaks and leave you with quite a mess, and cleaning it up is less than pleasant. I’ve found that using AppleScript, HTML and Evernote together allows me to create pretty well-formatted notes from web and text clippings, aside from using Evernote’s PDF features. In most cases—like website clippings—I don’t need or want a full PDF, replete with ads and comments (<a href="http://brettterpstra.com/tag/clippable/">Clippable</a> was designed with that in mind). The trick when creating a note in Evernote via AppleScript is to use a little HTML to get the basic formatting. Evernote’s AppleScript library provides a command tailored to this purpose.</p>

<p>To demonstrate, I’ll show you how to save your browsing session in Safari as a nicely formatted list in Evernote. For this I set up a new Notebook called “Bookmarks,” and am keeping the markup very simple. Evernote strips most styling from imported HTML, but accepts structural items like headlines, lists, tables, etc., applying its own default formatting to the elements.</p>

<p><span id="more-290"></span>
To begin, open AppleScript Editor (or Script Editor in Leopard) and create a new document. Save it as “EverSurfSaver.scpt” (or your own, better name) in <code>~/Library/Scripts/Applications/Safari</code>, creating the folders if you need to. This makes the script show up at the top of the list when you’re in Safari, and not clutter your script menu in other applications. Speaking of the Script Menu, if yours isn’t showing up in your menubar, and you want it to, look in the General tab of AppleScript Editor (Snow Leopard) or open the AppleScript Utility (Leopard). I launch most of my scripts with <a href="http://obdev.at/products/launchbar/index.html">LaunchBar</a>, but I keep the AS menu around.</p>

<p>In my script, the first thing I did was set up a template for the link formatting, and a search-and-replace function to implement it. It’s not terribly advanced, it just gives you %name and %url as placeholders, and you can set up the string however you like. I prefer this method to building long <code>this &amp; that &amp; return &amp; etc.</code> strings in AppleScript (although that still happens pretty often). My template for the links is set up as an unordered list, so it looks like this:</p>

<div markdown=0>
<pre><code>
property _template : &quot;&lt;li&gt;&lt;a href=\&quot;%url\&quot;&gt;%name&lt;/a&gt;&lt;/li&gt;&quot;
</code></pre>
</div>

<p>This is, fairly obviously, taking a name and a url and creating a hyperlink, wrapped in a list item. Note that any double quotes in the template string need to be escaped with a blackslash. The search-and-replace function is one that I use often, and I can’t remember who to attribute for the original code, for which I apologize…</p>

<div markdown=0>
<pre><code>
--search and replace function for template
on snr(tofind, toreplace, TheString)
    set atid to text item delimiters
    set text item delimiters to tofind
    set textItems to text items of TheString
    set text item delimiters to toreplace
    if (class of TheString is string) then
        set res to textItems as string
    else -- (assume Unicode)
        set res to textItems as Unicode text
    end if
    set text item delimiters to atid
    return res
end snr
</code></pre>
</div>

<p>Now we can update our template with shorter calls to the <code>snr</code> function. We’ll get around to using the template in a moment.</p>

<p>Next, we want to set up some basic variables to format the title of our note and create our list variable (open an unordered list) so that they’re all available outside of other functions and tell statements. I’m using a shell call (<code>do shell script</code>) to create the date strings, just because it’s <strong><em>so</em></strong> much faster than formatting a date in AppleScript.</p>

<div markdown=0>
<pre><code>
set prettyDate to do shell script &quot;date &#x27;+%A, %B %d, %Y at %l:%M %p&#x27;&quot;
set theTitle to &quot;Bookmarks &quot; &amp; prettyDate
set urlList to &quot;&lt;ul&gt;&quot;
</code></pre>
</div>

<p>The command <code>date '+%A, %B %d, %Y at %l:%M %p'</code> will create a date string that looks like <strong>Saturday, March 06, 2010 at  9:04 AM</strong>. Note the extra space before the “9:04.” That’s because it’s a single-digit hour and gets padded where the zero would be with other formatting. You can remove this with a little *NIX string handling, but I’m just going to live with it for the purposes of this post.</p>

<p>Next, we gather all of the tabs open in the front window of Safari. It’s entirely possible to cycle through all open windows and get all tabs, but I always surf in “one window” mode, so I’ll leave it up to you to look that one up if you need it. We’ll be appending the information from each tab to the urlList variable we set up at the beginning.</p>

<div markdown=0>
<pre><code>
tell application &quot;Safari&quot;
    set tabList to every tab of front window
    repeat with aTab in tabList
        set aLink to _template
        set aLink to my snr(&quot;%name&quot;, name of aTab, aLink)
        set aLink to my snr(&quot;%url&quot;, URL of aTab, aLink)
        set urlList to urlList &amp; aLink &amp; return
    end repeat
end tell
set urlList to urlList &amp; &quot;&lt;/ul&gt;&quot;
</code></pre>
</div>

<p>The block ends by appending the closing tag to our urlList. So we have a simple HTML fragment containing an unordered list of all of our links, the titles hyperlinked to their associated url. All that’s left to do now is create our Evernote note from this fragment:</p>

<div markdown=0>
<pre><code>
tell application "Evernote"
    set theNote to create note with html urlList title theTitle notebook "Bookmarks"
end tell
</code></pre>
</div>

<p>That’s it. Now there’s a note in Evernote, in a notebook called “Bookmarks,” titled something like “Bookmarks Saturday, March 06, 2010 at  9:04 AM.” Here’s the code in its entirety:</p>

<div markdown=0>
<pre><code>
property _template : &quot;&lt;li&gt;&lt;a href=\&quot;%url\&quot;&gt;%name&lt;/a&gt;&lt;/li&gt;&quot;

--search and replace function for template
on snr(tofind, toreplace, TheString)
    set ditd to text item delimiters
    set text item delimiters to tofind
    set textItems to text items of TheString
    set text item delimiters to toreplace
    if (class of TheString is string) then
        set res to textItems as string
    else -- if (class of TheString is Unicode text) then
        set res to textItems as Unicode text
    end if
    set text item delimiters to ditd
    return res
end snr

set prettyDate to do shell script &quot;date &#x27;+%A, %B %d, %Y at %l:%M %p&#x27;&quot;
set theTitle to &quot;Bookmarks &quot; &amp; prettyDate
set urlList to &quot;&lt;ul&gt;&quot;

tell application &quot;Safari&quot;
    set tabList to every tab of front window
    repeat with aTab in tabList
        set aLink to _template
        set aLink to my snr(&quot;%name&quot;, name of aTab, aLink)
        set aLink to my snr(&quot;%url&quot;, URL of aTab, aLink)
        set urlList to urlList &amp; aLink &amp; return
    end repeat
end tell
set urlList to urlList &amp; &quot;&lt;/ul&gt;&quot;

tell application &quot;Evernote&quot;
    set theNote to create note with html urlList title theTitle notebook &quot;Bookmarks&quot;
end tell
</code></pre>
</div>

<p><a href="applescript://com.apple.scripteditor?action=new&#038;script=property%20_template%20:%20%22%3Cli%3E%3Ca%20href=%5C%22%25url%5C%22%3E%25name%3C/a%3E%3C/li%3E%22%0A%0A--search%20and%20replace%20function%20for%20template%0Aon%20snr(tofind,%20toreplace,%20TheString)%0A%09set%20ditd%20to%20text%20item%20delimiters%0A%09set%20text%20item%20delimiters%20to%20tofind%0A%09set%20textItems%20to%20text%20items%20of%20TheString%0A%09set%20text%20item%20delimiters%20to%20toreplace%0A%09if%20(class%20of%20TheString%20is%20string)%20then%0A%09%09set%20res%20to%20textItems%20as%20string%0A%09else%20--%20if%20(class%20of%20TheString%20is%20Unicode%20text)%20then%0A%09%09set%20res%20to%20textItems%20as%20Unicode%20text%0A%09end%20if%0A%09set%20text%20item%20delimiters%20to%20ditd%0A%09return%20res%0Aend%20snr%0A%0Aset%20prettyDate%20to%20do%20shell%20script%20%22date%20'+%25A,%20%25B%20%25d,%20%25Y%20at%20%25l:%25M%20%25p'%22%0Aset%20theTitle%20to%20%22Bookmarks%20%22%20&#038;%20prettyDate%0Aset%20urlList%20to%20%22%3Cul%3E%22%0A%0Atell%20application%20%22Safari%22%0A%09set%20tabList%20to%20every%20tab%20of%20front%20window%0A%09repeat%20with%20aTab%20in%20tabList%0A%09%09set%20aLink%20to%20_template%0A%09%09set%20aLink%20to%20my%20snr(%22%25name%22,%20name%20of%20aTab,%20aLink)%0A%09%09set%20aLink%20to%20my%20snr(%22%25url%22,%20URL%20of%20aTab,%20aLink)%0A%09%09set%20urlList%20to%20urlList%20&#038;%20aLink%20&#038;%20return%0A%09end%20repeat%0Aend%20tell%0Aset%20urlList%20to%20urlList%20&#038;%20%22%3C/ul%3E%22%0A%0Atell%20application%20%22Evernote%22%0A%09set%20theNote%20to%20create%20note%20with%20html%20urlList%20title%20theTitle%20notebook%20%22Bookmarks%22%0Aend%20tell">Click here</a> to open this script in your default script editor.</p>

<h3>Addendum</h3>

<p>One of the great things about using Evernote for this purpose is that you can add todo checkboxes next to important or “read later” links for reference. If there’s a theme to the batch of links (I just saved the results of a long search for decent WordPress e-commerce plugins), you can also add meaningful tags to the note itself. Further, you can add any notes and keywords you want next to or below the link in an indented list item (you never have to deal with markup again after the import, at that point it’s just a rich text list).</p>

<p>Because this script only deals with the frontmost window, you can also drag off a specific group of tabs to a new window, and only bookmark those in the Evernote note. With a little “show dialog” or CocoaDialog action, you could easily have the script request tags or notes in the process and append them to the note. If I ever implement that, I’ll post it, but I like the simplicity and immediacy it has right now.</p>

<p>Also, I forgot to look and see who else was doing something similar (I’m in my own little world a lot). Justin over at <a href="http://veritrope.com/">Veritrope</a> has a <a href="http://veritrope.com/tips/safari-tabs-to-evernote">similar script</a> (minus the HTML), amongst a large collection of really useful scripts and services. You should check that out, too!</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/duplicating-safari-browsing-sessions-between-macs/' rel='bookmark' title='Duplicating Safari browsing sessions between Macs'>Duplicating Safari browsing sessions between Macs</a></li>
<li><a href='http://brettterpstra.com/eversave-revisited-now-with-session-restore/' rel='bookmark' title='EverSave revisited, now with session restore!'>EverSave revisited, now with session restore!</a></li>
<li><a href='http://brettterpstra.com/antique-safari-reader-hack-update-with-evernote-goodness/' rel='bookmark' title='Antique Safari Reader hack update with Evernote goodness'>Antique Safari Reader hack update with Evernote goodness</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/saving-safari-browsing-sessions-to-evernote/">Saving Safari browsing sessions to Evernote</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/saving-safari-browsing-sessions-to-evernote/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Clippable updated to remove source code line numbers</title>
		<link>http://brettterpstra.com/clippable-updated-to-remove-source-code-line-numbers/</link>
		<comments>http://brettterpstra.com/clippable-updated-to-remove-source-code-line-numbers/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 11:55:31 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[clippable]]></category>
		<category><![CDATA[evernote]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[readability2]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=212</guid>
		<description><![CDATA[<p>I made a couple of minor changes to the Clippable bookmarklet, mostly in the way it handles SyntaxHighlighter code blocks. The SyntaxHighlighter plugin is used (too) often to format and color code source snippets in websites. The result when clipping a page is that the code you get still has line numbers, but no option to view the raw source&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/clippable-updated-to-remove-source-code-line-numbers/">Clippable updated to remove source code line numbers</a></p>]]></description>
			<content:encoded><![CDATA[<p>I made a couple of minor changes to the <a href="http://brettterpstra.com/share/readability2.html">Clippable bookmarklet</a>, mostly in the way it handles SyntaxHighlighter code blocks. The SyntaxHighlighter plugin is used (too) often to format and color code source snippets in websites. The result when clipping a page is that the code you get still has line numbers, but no option to view the raw source without going back to the web page. Then you end up manually editing out the line numbers if you want to copy and paste the code, which can be a pain in most cases.</p>

<p>Since the point of Clippable was to deal better with things <em>like</em> code blocks (especially for saving snippets to Evernote), it now removes the toolbar and line numbers from SyntaxHighlighter blocks. It also looks for another common technique: converting lines in code to an ordered list inside of a pre block. This is just blotted out with CSS now. Those are the only two highlighting methods it targets at the moment, but I’ll tackle more as I run into them.</p>

<p>If you already have the bookmarklet installed, you’re already benefitting from these changes (the bookmarklet calls the source scripts on my server, so it is, in essence, automatically updated). If not, just cruise over to the <a href="http://brettterpstra.com/share/readability2.html">Clippable page</a> and grab it!</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/clippable-updated-goes-mobile/' rel='bookmark' title='Clippable updated, goes mobile'>Clippable updated, goes mobile</a></li>
<li><a href='http://brettterpstra.com/clippable/' rel='bookmark' title='Clippable'>Clippable</a></li>
<li><a href='http://brettterpstra.com/clippable-to-evernote-snow-leopard-service/' rel='bookmark' title='Clippable to Evernote Snow Leopard Service'>Clippable to Evernote Snow Leopard Service</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/clippable-updated-to-remove-source-code-line-numbers/">Clippable updated to remove source code line numbers</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/clippable-updated-to-remove-source-code-line-numbers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clippable to Evernote Snow Leopard Service</title>
		<link>http://brettterpstra.com/clippable-to-evernote-snow-leopard-service/</link>
		<comments>http://brettterpstra.com/clippable-to-evernote-snow-leopard-service/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 05:55:06 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[clippable]]></category>
		<category><![CDATA[evernote]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[snow leopard]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=109</guid>
		<description><![CDATA[<p>Clippable to Evernote will allow you to trigger the Clippable bookmarklet in Safari and copy the result directly to your "Unfiled" notebook in Evernote. This service is Snow Leopard-only.</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/clippable-to-evernote-snow-leopard-service/">Clippable to Evernote Snow Leopard Service</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' display:none'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2009/11/clippabletoevernote110309.jpg?9d7bd4" alt="clippabletoevernote110309" title="clippabletoevernote110309" width="440" height="187" class="alignnone size-full wp-image-121 headerimg" />
Clippable to Evernote will allow you to trigger the <a href="http://brettterpstra.com/2009/11/03/clippable/">Clippable bookmarklet</a> in Safari and copy the result directly to your “Unfiled” notebook in Evernote. This service is Snow Leopard-only. If you need it modified for Leopard and aren’t sure how, let me know. If there’s some interest, I’ll just work one up and post it.</p>

<p>To install in Snow Leopard, just unzip (double-click the zip file) the file and move the resulting .workflow file to [your home directory]/Library/Services. It should now appear in your Safari-&gt;Services menu, in Safari only. To add a keyboard shortcut to the Service, go to the Keyboard pane in System Preferences, choose the Keyboard Shortcuts tab, select Services on the left and find the Clippable… service on the right. Double click on the right side of the listing to enter a hotkey. I currently have mine bound to control-command-E, which works well for me in Safari.</p>

<p>Download <a href="http://brettterpstra.com/share/clippable-to-evernote.zip?9d7bd4">here</a>.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/updated-songza-lucky-link-service/' rel='bookmark' title='Updated: Songza Lucky Link Service'>Updated: Songza Lucky Link Service</a></li>
<li><a href='http://brettterpstra.com/equation-evaluation-service-for-snow-leopard/' rel='bookmark' title='A (fairly) simple equation evaluation service for Snow Leopard'>A (fairly) simple equation evaluation service for Snow Leopard</a></li>
<li><a href='http://brettterpstra.com/clippable-updated-goes-mobile/' rel='bookmark' title='Clippable updated, goes mobile'>Clippable updated, goes mobile</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/clippable-to-evernote-snow-leopard-service/">Clippable to Evernote Snow Leopard Service</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/clippable-to-evernote-snow-leopard-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Readability2 leaks out</title>
		<link>http://brettterpstra.com/readability2-leaks-out/</link>
		<comments>http://brettterpstra.com/readability2-leaks-out/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 09:30:52 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[evernote]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[readability2]]></category>
		<category><![CDATA[service]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=52</guid>
		<description><![CDATA[<p>So my modification of the Readability bookmarklet kind of snuck out before it was ready, but it’s my own fault. Now I’m scrambling a little to make it more presentable and less of a straight-up hack of the excellent original. I wanted to make a few things clear about my goals and purpose on this one. First the entire project&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/readability2-leaks-out/">Readability2 leaks out</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' display:none'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2009/11/readability2110220091.jpg?9d7bd4" alt="readability211022009" title="readability211022009" width="440" height="187" class="alignnone size-full wp-image-126 headerimg" /></p>

<p>So <a href="http://brettterpstra.com/share/readability2.html">my modification of the Readability bookmarklet</a> kind of snuck out before it was ready, but it’s my own fault. Now I’m scrambling a little to make it more presentable and less of a straight-up hack of the <a href="http://lab.arc90.com/experiments/readability/">excellent original</a>. I wanted to make a few things clear about my goals and purpose on this one.</p>

<p>First the entire project was really a subset of my attempt at a better Evernote clipper for Snow Leopard. One which allowed me to preserve code formatting and automatically remove comments and ads from the post, in a smarter fashion than the current Safari clipper does. I built it as a System Service and run it with a hotkey. You can <a href="http://cdn2.brettterpstra.com/wp-content/uploads/2009/11/clippable-to-evernote1111111.zip?9d7bd4">download it</a> and try it out, if you like. I’ll make a more accessible version with instructions shortly.</p>

<p>This is why I removed the formatting options from the bookmarklet… Evernote was going to strip all of that out anyway. Originally, I was just using the code to strip out ads and find the meat. The modifications to preserve code blocks, movies, etc. were simply working toward the “perfect” Evernote clip.</p>

<p>It works for what it is, but wasn’t really intended to be used without the Evernote Service. If I get enough feedback, and no cease and desist orders from the original creators, I’ll continue to modify it. One thing you can certainly do to help is provide me with URL’s to pages it fails on; the more scenarios I can study, the smarter I can make it.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/taking-the-markdown-to-evernote-service-further/' rel='bookmark' title='Taking the Markdown to Evernote service further'>Taking the Markdown to Evernote service further</a></li>
<li><a href='http://brettterpstra.com/why-a-plain-text-nerd-uses-evernote/' rel='bookmark' title='Why a plain-text nerd uses Evernote'>Why a plain-text nerd uses Evernote</a></li>
<li><a href='http://brettterpstra.com/evernote-site-memory-tagger-for-wordpress/' rel='bookmark' title='Evernote Site Memory tagger for WordPress'>Evernote Site Memory tagger for WordPress</a></li>
</ol></p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/readability2-leaks-out/">Readability2 leaks out</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/readability2-leaks-out/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (Feed is rejected)
Page Caching using disk: enhanced
Database Caching 29/129 queries in 0.239 seconds using xcache
Object Caching 3071/3206 objects using xcache
Content Delivery Network via cdn2.brettterpstra.com

Served from: brettterpstra.com @ 2012-05-23 02:54:12 -->
