With Asciidoc becoming more popular due to Asciidoctor I started authoring documents in Asciidoc and thought it would be a good idea to use that for my blogging as well (in the long run I may set up my blog in Awestruct, but for now Blogger has to do.
Usually I am using
MarsEdit to write my posts, as it is just convenient for me. MarsEdit now allows to write custom text filters since the recently released version 3.6. There are a few such filters provided like for Markdown or Textile, so that you can write blog posts inside MarsEdit in those markup languages and still be able to post to e.g. Blogger, which requires html.
When I saw the filters announced, I thought, that should be possible with Asciidoc as well.
So basically to achieve this, you need to create a directory
~/Library/Application Support/MarsEdit/TextFilters/Asciidoc_0.0.1
and then create a file Asciidoc.rb
with the following content:
#!/usr/bin/ruby
require 'rubygems'
require 'asciidoctor'
input = $stdin.read
puts Asciidoctor.render(input)
Make that file executable and install the AsciiDoctor gem.
Then (re-start) MarsEdit and select Asciidoc as Preview Text filter in the connection settings of the blogger account ( see Mars Edit per Blog Settings ). Then click on the "Posting" tab and click on "Apply preview filter before posting".
Unfortunately I have not yet found out how to include (remote) images
- NOTE
Not all AsciiDoc markups make sense, as AsciiDoctor usually uses some CSS, that may not be present on the target blog system. It may be not too hard though to create a special "blogger" backend, that uses
blogger css for that or to tell blogger to accept the AsciiDoctor css files
This screenshot shows MarsEdit with source and preview.
I hope this little post makes sense and encourages people to experiment with it in order to make AsciiDoc a real alternative to
No comments:
Post a Comment