<?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 Terpstramarsedit - Brett Terpstra</title>
	<atom:link href="http://brettterpstra.com/tag/marsedit/feed/" rel="self" type="application/rss+xml" />
	<link>http://brettterpstra.com</link>
	<description>Elegant solutions to complex problems.</description>
	<lastBuildDate>Thu, 09 Feb 2012 15:01:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Fun with MarsEdit, part I</title>
		<link>http://brettterpstra.com/fun-with-marsedit-part-i/</link>
		<comments>http://brettterpstra.com/fun-with-marsedit-part-i/#comments</comments>
		<pubDate>Sun, 06 Jun 2010 21:02:26 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[applescript]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[marsedit]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=533</guid>
		<description><![CDATA[<p>I’ll be the first to admit that I get a little obsessed with projects that aren’t really going to improve my life all that much. Those projects can be fun to blog about, though, so I present you my brief obsession for this Sunday afternoon. You may have noticed on this blog that some posts have header images, and some&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/fun-with-marsedit-part-i/">Fun with MarsEdit, part I</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' display:none'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/06/funwithmarseditheader.jpg?9d7bd4" alt="funwithmarseditheader.jpg" border="0" width="650" height="187" class="headerimg" /></p>

<p>I’ll be the first to admit that I get a little obsessed with projects that aren’t really going to improve my life all that much. Those projects can be fun to blog about, though, so I present you my brief obsession for this Sunday afternoon.</p>

<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/06/funwithmarseditbeforeafter.jpg?9d7bd4" alt="Template header before and after" border="0" width="298" height="202" class="alignright" />You may have noticed on this blog that some posts have header images, and some don’t, and that they get styled differently based on whether there’s an image or not. It pulls the header images from one of two places: the post thumbnail (which I can’t edit from MarsEdit) or the first image in the post content with a class of “headerimg”. As long as I’m blogging in <a href="http://​www​.red​-sweater​.com/​m​a​r​s​e​d​it/">MarsEdit</a> (or TextMate for that matter), I’m stuck with the latter option. Because the whole header image deal is handled through PHP in my functions.php file, I can’t really preview how it’s going to look; rather, I get a header image stuck somewhere before, in or after my content. In TextMate, I have a little more “scriptability” at my disposal, and the previews I’ve created there are quite accurate. As far as I can tell, I can’t pre-process content before the template is generated, so I had to try something else…
<span id="more-533"></span>My solution, for now, is jQuery in the preview template. I load the jQuery library up top (inside the header) using Google’s Ajax API:</p>

<div markdown=0>
<pre><code>
&lt;script src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
&lt;script&gt;google.load(&quot;jquery&quot;, &quot;1.4&quot;);&lt;/script&gt;
</code></pre>
</div>

<p>Then, at the bottom, I just start polling for an image with the right class to show up. I know it’s brute force, but this isn’t exactly public-facing, and it doesn’t seem to cause any hiccups in my writing. I have this right before my closing body tag:</p>

<div markdown=0>
<pre><code>
&lt;script&gt;
function fixHeader() {
    if ($(&#x27;img.headerimg&#x27;).attr(&#x27;src&#x27;) != undefined) {
        headerImg = $(&#x27;img.headerimg&#x27;).removeClass(&#x27;headerimg&#x27;).remove();
        postThumb = $(&#x27;.postthumb:first&#x27;);
        headerImg.prependTo(postThumb);
        postThumb.addClass(&#x27;hasimage&#x27;).removeClass(&#x27;noimage&#x27;);
    }
}
setInterval(fixHeader,2000);
&lt;/script&gt;
</code></pre>
</div>

<p>I’m sharing this just to toss the idea out there, not because I think there’s anyone else with the exact same template setup as mine.</p>

<p>In addition to having Javascript at my disposal, MarsEdit is also AppleScript-able. I haven’t looked very far into that yet, but I did whip up a quick script for adding the “headerimg” class to my images (because I always forget which class I assigned for this):</p>

<div markdown=0>
<pre><code>
tell application &quot;MarsEdit&quot;
    set selectionContents to selected text of document 1
    set {astid, AppleScript&#x27;s text item delimiters} to {AppleScript&#x27;s text item delimiters, &quot;/&gt;&quot;}
    if selectionContents is not &quot;&quot; then
        set textToInsert to (text item 1 of selectionContents) &amp; &quot;class=\&quot;headerimg\&quot; /&gt;&quot;
    end if
    set AppleScript&#x27;s text item delimiters to astid
    set selected text of document 1 to textToInsert
end tell
</code></pre>
</div>

<p>That lets me just select an image (or pending upload tag) and run the script to add the necessary class.</p>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/multimarkdown-in-marsedit/' rel='bookmark' title='MultiMarkdown in MarsEdit'>MultiMarkdown in MarsEdit</a></li>
<li><a href='http://brettterpstra.com/instapaper-beyond-for-safari/' rel='bookmark' title='Instapaper Beyond for Safari'>Instapaper Beyond for Safari</a></li>
<li><a href='http://brettterpstra.com/marked-scripts-nvalt-evernote-marsedit-scrivener/' rel='bookmark' title='Marked scripts: nvALT, Evernote, MarsEdit, Scrivener'>Marked scripts: nvALT, Evernote, MarsEdit, Scrivener</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/fun-with-marsedit-part-i/">Fun with MarsEdit, part I</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/fun-with-marsedit-part-i/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MultiMarkdown in MarsEdit</title>
		<link>http://brettterpstra.com/multimarkdown-in-marsedit/</link>
		<comments>http://brettterpstra.com/multimarkdown-in-marsedit/#comments</comments>
		<pubDate>Sun, 06 Jun 2010 13:21:56 +0000</pubDate>
		<dc:creator>Brett</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[markdown]]></category>
		<category><![CDATA[marsedit]]></category>
		<category><![CDATA[multimarkdown]]></category>
		<category><![CDATA[os x]]></category>

		<guid isPermaLink="false">http://brettterpstra.com/?p=522</guid>
		<description><![CDATA[<p>I’ve just started using MarsEdit1 again (in combination with my TextMate2 blogging bundles), but I’ve run into a couple of issues. First, I can’t assign thumbnails to my posts directly. This is the result of poor API support in WordPress for handling attachments on a specific post, and not Daniel’s fault at all. Fortunately, I’ve set my blog up to&#8230;</p><p>Originally posted on <a href="http://brettterpstra.com" title="BrettTerpstra.com">BrettTerpstra.com</a> at <a href="http://brettterpstra.com/multimarkdown-in-marsedit/">MultiMarkdown in MarsEdit</a></p>]]></description>
			<content:encoded><![CDATA[<p><img style=' display:none'  src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/06/marseditmultimarkdownheader.jpg?9d7bd4" alt="marseditmultimarkdownheader.jpg" border="0" width="650" height="187" class="headerimg" /></p>

<p><img src="http://cdn2.brettterpstra.com/wp-content/uploads/2010/06/MarsEditIcon225.jpg?9d7bd4" alt="Mars Edit Icon" border="0" width="225" height="225" style="float:right;" />I’ve just started using MarsEdit<sup id="fnref:MarsEdit"><a href="#fn:MarsEdit" rel="footnote">1</a></sup> again (in combination with my TextMate<sup id="fnref:TextMate"><a href="#fn:TextMate" rel="footnote">2</a></sup> blogging bundles), but I’ve run into a couple of issues. First, I can’t assign thumbnails to my posts directly. This is the result of poor API support in WordPress for handling attachments on a specific post, and not Daniel’s fault at all. Fortunately, I’ve set my blog up to search for an image with a specific class, remove it from the post and use it as the post header if a thumbnail isn’t assigned. That works.</p>

<p>Second, my blog uses PHP Markdown Extra<sup id="fnref:markdownextra"><a href="#fn:markdownextra" rel="footnote">3</a></sup>, and a lot of the “extra” functionality was messing up my carefully-crafted preview in MarsEdit. Fortunately, a little searching on the Red Sweater forums yielded exactly what I needed<sup id="fnref:forumpost"><a href="#fn:forumpost" rel="footnote">4</a></sup>: you can add your own text filters with a little editing and some luck.</p>

<p>Markdown Extra shares most of the functionality I need with MultiMarkdown<sup id="fnref:MultiMarkdown"><a href="#fn:MultiMarkdown" rel="footnote">5</a></sup>, such as footnotes and quick, semantic tables. By copying the <code>bin</code> folder from <code>~/Application Support/MultiMarkdown/</code> to <code>~/Application Support/MarsEdit/TextFilters/</code> and renaming it from <code>bin</code> to <code>MultiMarkdown</code> (the exact same name as the executable), I was able to add the text filter without breaking a sweat.</p>

<p>Now, between MarsEdit and Edit in TextMate, I can do all of my blogging in Markdown Extra, offline, with full previews. I can manage categories and tags, excerpts and add media. Spectacular.</p>

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

<li id="fn:MarsEdit">
<p>MarsEdit: <a href="http://www.red-sweater.com/marsedit/">http://www.red-sweater.com/marsedit/</a> <a href="#fnref:MarsEdit" rev="footnote">↩</a></p>
</li>

<li id="fn:TextMate">
<p>TextMate: <a href="http://macromates.com/">http://macromates.com/</a> <a href="#fnref:TextMate" rev="footnote">↩</a></p>
</li>

<li id="fn:markdownextra">
<p>PHP Markdown Extra: <a href="http://michelf.com/projects/php-markdown/extra/">http://michelf.com/projects/php-markdown/extra/</a> <a href="#fnref:markdownextra" rev="footnote">↩</a></p>
</li>

<li id="fn:forumpost">
<p>Red Sweater Forum Post: <a href="http://www.red-sweater.com/forums/viewtopic.php?id=1211">http://www.red-sweater.com/forums/viewtopic.php?id=1211</a> <a href="#fnref:forumpost" rev="footnote">↩</a></p>
</li>

<li id="fn:MultiMarkdown">
<p>MultiMarkdown: <a href="http://fletcherpenney.net/multimarkdown/">http://fletcherpenney.net/multimarkdown/</a> <a href="#fnref:MultiMarkdown" rev="footnote">↩</a></p>
</li>

</ol>
</div>
<p>Related posts:<ol>
<li><a href='http://brettterpstra.com/fun-with-marsedit-part-i/' rel='bookmark' title='Fun with MarsEdit, part I'>Fun with MarsEdit, part I</a></li>
<li><a href='http://brettterpstra.com/marked-scripts-nvalt-evernote-marsedit-scrivener/' rel='bookmark' title='Marked scripts: nvALT, Evernote, MarsEdit, Scrivener'>Marked scripts: nvALT, Evernote, MarsEdit, Scrivener</a></li>
<li><a href='http://brettterpstra.com/the-second-marked-giveaway/' rel='bookmark' title='The second Marked giveaway!'>The second Marked giveaway!</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/multimarkdown-in-marsedit/">MultiMarkdown in MarsEdit</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettterpstra.com/multimarkdown-in-marsedit/feed/</wfw:commentRss>
		<slash:comments>11</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 8/41 queries in 0.106 seconds using xcache
Object Caching 1097/1141 objects using xcache
Content Delivery Network via cdn2.brettterpstra.com

Served from: brettterpstra.com @ 2012-02-09 17:38:00 -->
