[MlMt] Replacing the Markdown processor

Kee Hinckley kee+freron at hinckley.com
Mon Dec 2 17:26:12 EST 2013


On 2 Dec 2013, at 16:31, Thomas Wölk wrote:

> On 2 Dec 2013, at 13:53, Kee Hinckley wrote:
>
>> From the docs, it seemed as though creating
>>
>> 	{
>> 		name    = 'Markdown to HTML';
>> 		events  = ( 'email.display' );
>> 		input   = 'canonical';
>> 		output  = 'html';
>> 		select  = '(content-type.type !exists or (content-type.type = text 
>> and content-type.subtype = plain)) and content-type.markup = 
>> markdown';
>> 		script  = '#!/usr/bin/env bash\necho "<div 
>> markup=\\"markdown\\">"\n/usr/local/bin/multimarkdown\necho 
>> "</div>"\n';
>> 		uuid = 'DB65F8BE-6DE5-4BD5-AB9A-0A27599BE8C5';
>> 	}
>
>>
>> 	#!/bin/sh
>> 	
>> 	tee /tmp/foo.mailmate | sed -e 's/2  
>> AE883AA-33F3-4330-A544-A3B12C621468//g' | 
>> /usr/local/bin/multimarkdown
>
> That's very clever.
>
> Possible to upload the script in RAW-format?
>
> What is the last UUID? (AE883AA-33F3-4330-A544-A3B12C621468) is it 
> different from the line above? Can you please explain your solution?

I've attached the script. To use it (until someone can explain how I can 
properly use script support to do this), you would save mysundown 
somewhere safe (e.g. ~/bin) and do something like this:

```bash
chmod +x ~/bin/mysundown
mv /Applications/MailMate.app/Contents/SharedSupport/bin/sundown to 
/Applications/MailMate.app/Contents/SharedSupport/bin/sundown.orig
ln -s ~/bin/mysundown 
/Applications/MailMate.app/Contents/SharedSupport/bin/sundown
```

Note that you'll have to do the last two steps ever time MailMate 
updates.

I've made a couple changes since my last email.

MultiMarkdown treats subsequent lines with no blank between them as 
continuations (which is correct for the spec), but you don't really want 
that for email, and many markdown processors make that an option. So the 
script now appends two spaces after each line to force a break. So far 
that's worked everywhere except for the use of backticks to create a 
code block. So I've worked around that. There may be other things that 
it breaks, but so far it's doing okay with everything I've thrown at it. 
Any more tweaks and I'll have to switch from sed to perl or something. 
View this raw (or the text version) to see the original markdown. I 
don't know if the sundown processor supported these or not, I wasn't 
able to get tables to work in my brief experiments, but I wanted to use 
the same pre-processor I used elsewhere anyway.



Another side effect/bug with MultiMarkdown; multiple blank lines are 
treated like a single blank line.

## Some Examples

```javascript
var i = 1;
int a = 2;
```

That was the case where a space after ``javascript`` screwed up the 
processing, by making multi markdown think it was a single line code 
block instead of a pre-code block.[^footnote]

[^footnote]: At this point I'm probably giving MultiMarkdown TMI. Of 
course if you really want TMI, ask me about my 
MultiMarkdown->MediaWiki/Jira converter and the workflow I use for 
writing documents in Scrivener that end up in the Wiki.

Here's a table:

| This is header1 | This is header2 | This is header 3 |
| --- | ---: | :---: |
| left | right | center |
| spanning two columns || some |
[_Table Header_]

Some samples from the github page on markdown:

Inline-style:
![alt 
text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png 
"Logo Title Text 1")

Reference-style:
![alt text][logo]

[logo]: 
https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png 
"Logo Title Text 2"


The latest MultiMarkdown download can be found 
[here](http://fletcherpenney.net/multimarkdown/download/).


     ## Some Examples

     ```javascript
     var i = 1;
     int a = 2;
     ```

     That was the case where a space after ``javascript`` screwed up the 
processing, by making multi markdown think it was a single line code 
block instead of a pre-code block.[^footnote]

     [^footnote]: At this point I'm probably giving MultiMarkdown TMI. 
Of course if you really want TMI, ask me about my 
MultiMarkdown->MediaWiki/Jira converter and the workflow I use for 
writing documents in Scrivener that end up in the Wiki.

     Here's a table:

     | This is header1 | This is header2 | This is header 3 |
     | --- | ---: | :---: |
     | left | right | center |
     | spanning two columns || some |
     [_Table Header_]

     Some samples from the github page on markdown:

     Inline-style:
     ![alt 
text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png 
"Logo Title Text 1")

     Reference-style:
     ![alt text][logo]

     [logo]: 
https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png 
"Logo Title Text 2"


     The latest MultiMarkdown download can be found 
[here](http://fletcherpenney.net/multimarkdown/download/).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freron.com/pipermail/mailmate/attachments/20131202/cd407e8b/attachment-0001.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: mysundown
URL: <http://lists.freron.com/pipermail/mailmate/attachments/20131202/cd407e8b/attachment-0001.ksh>


More information about the mailmate mailing list