Sunday·10·March·2013
Rendering Markdown, Asciidoc and Friends automatically while Editing //at 15:41 //by abe
Partially because of Markdown being Github’s markup format of choice, I enjoy writing documents in simple markup formats more and more.
There’s though one common annoyance with these formats compared to writing plain HTML…
The Annoyance
They need to be rendered (i.e. more or less compiled) before you can view your outpourings rendered, e.g. in the web browser. So the workflow usually is:
- Saving the current file in your favourite editor
- Switch to terminal with commandline
- Cursor up, Enter
- Switch to your favourite web browser
- Hit the reload button
Using a Specialized Editor with Live Preview
One choice would be to use a specific editor with live rendering. The one I know in Debian (from Wheezy on) is ReText (Debian package retext). It supports Markdown and reStructuredText.
But as with most simple GUI editors, I miss there many of the advanced editing commands possible with Emacs.
Using Emacs’ Markdown Mode
Then there is the Markdown Mode
for Emacs (part of Debian’s emacs-goodies-el package), where
you can get a “preview” by pressing C-c C-c p
. But for
some reason this takes several seconds, opens a new buffer
and window with the rendered HTML code and then starts
(hardcoded) Firefox (which is not my preferred web browser). And if you do that a
second time without closing Firefox first, it won’t just reload the
file but will open a new tab. You might think that just hitting reload
should suffice. But no, the new tab has a different file name, so
reload doesn’t help. Additionally it may not use my preferred Markdown
implementation. Meh.
Well, I probably could fix all those issues with Markdown Mode, it’s only Emacs Lisp. Heck, the called command is even configurable. But fixing at least four issues to fix one workflow annoyance? Maybe some other time, but not as long there are other nice choices…
Using inotifywait to Render on Write
So everytime you save the currently edited file, you immediately want to rerender the same HTML file from it. This can be easily automated by using Linux’ inotify kernel subsystem which notices changes to the filesystem, and reports those to applications which ask for it.
One such tool is inotifywait
which can either output all
or just specific events, or just exit if the first requested event
occurs. With the latter it’s easy to write a while loop on the
commandline which regenerates a file after every write access. I use
either Pandoc or Asciidoc for that since both generate full HTML pages
including header and footer, but you can use that also with Markdown
to render just the HTML body. Most browsers render it correctly
anyway:
while inotifywait -q -e modify index.md; do pandoc -s -f markdown -t html -o index.html index.md; done while inotifywait -q -e modify index.txt; do asciidoc index.txt; done while inotifywait -q -e modify index.md; do markdown index.md > index.html; done
This solution is even editor- and build-system-agnostic (But not operating-system-agnostic.)
inotifywait is part of inotify-tools, a useful set of commandline tools to interface with inotify. They’re packaged in Debian as inotify-tools, too.
Using mdpress for Markdown plus Impress.js based Slides
The ruby-written mdpress is a special case of the previous case. It’s
a commandline tool to convert Markdown into Impress.js based slide
shows and it has an option named --automatic
which causes
it to keep running and automatically update the presentation as soon
as changes are made to the Markdown file.
mdpress is not yet in Debian, but there’s an ITP for it and
Impress.js itself recently entered Debian as libjs-impress.
Nevertheless, two dependencies (highlight.js,
ITP‘ed, ruby-launchy, ITP‘ed) are still missing in Debian.
Tagged as: Asciidoc, Emacs, emacs-goodies-el, GitHub, HTML, Impress.js, inotify, inotify-tools, inotifywait, ITP, Major-Mode, Markdown, mdpress, oneliner, Pandoc, reST, ReText, Ruby, slides, Wheezy
// show without comments // write a comment
Related stories
Sunday·25·May·2008
Google Open Source Jam and Webtuesday Hackday //at 22:45 //by abe
I was at two geek events in Zurich this week: At the Google Open Source Jam Zurich on Thursday evening and at the first Webtuesday Hackday on Saturday.
Somehow I expected both events to be quite similar, but they weren’t.
Google Open Source Jam
When I read “Jam” or “Jam Session” I think of Jazz musicians spontaneously playing together. So for me “Open Source Jam” sounded like a hack session where some spontaneous coding is done. But there was no spontaneous collaboration at Open Source Jam at all. It’s just (more or less spontaneous) talks about different topics and chatting. So I was quite disappointed from that event.
There were though quite a lot of people I knew from e.g. Webtuesday, Chaostreff or Debian. I even met some people I just knew from IRC until then.
Half of the talks were sole propaganda talks though, e.g. for Webtuesday Hackday, OpenExpo and Soaring as a geek sport. Not really wrongly placed talks, but not what I expected in talks at Open Source Jam.
The few rooms and floors I saw reminded me very much to IKEA Children’s Paradies, just even more motley. Though it felt all sterile and wasn’t by far as cool as I expected after what I read elsewhere of Google offices.
I also think that several of the Google employees showed some contrived friendlyness, and questions I asked e.g. why I have to give them my e-mail address and employer’s name (what do unemployed or self-employed people do?) got answered with answers I do not really believe – like “for security”. A leopard doesn’t change its spots. A data squid probably neither, even not at events labeled with OSS and said to be for the community.
I suspect that finding new employees is one of the reasons behind such events at Google. But after my first visit at one of their locations, this company still makes me feel uncomfortable. And I’m even more sure than before that I wouldn’t want to work there.
Not sure if I’ll attend the Google Open Source Jam a second time.
Webtuesday Hackday
Webtuesday Hackday also was not as I expected, but still more close to my expectations: the Webtuesday crowd gathers for hacking instead of having long talks. :-)
There were surprisingly many people from outside Zurich, from Munich and Belgium, from Lake Constance and Lausaunne – not only the usual suspects (who were there anyway ;-).
The event took place at Liip’s new office. They still look a little bit empty and steril, but all the toys (mini rugby balls, Wii, plush figures on floor lamps) and people around made them very alive. And they had very cool lamps in the form of their company logo in the office. They sure have a good interior designer. :-)
Although most participants found time to do some hacking, many found less time than they expected so we hope that we can glue the talks a little bit more together in regards of timing to cause less interruptions of the hacking.
The food was also better at Hackday, too, but mostly because we ate outside. ;-) For lunch we were at Lily’s Stomach Supply at Langstrasse (very recommendable!) and in 6he evening we were at Pizzeria Grottino 79 near Helvetiaplatz. Had a Pizza Vesuvio with Gruyère cheese there.
Hackday also had a surprise for me: The IRC channel at Hackday was but when I entered the channel there were someone in I didn’t expect there: tklauser aka Tobias Klauser aka tuxedo. Even more surprising, he read about my project idea for Hackday – a semantic feed cache proxy – and liked it, so he decided to come over to Zurich and join the project.
We didn’t came that far until Tobias had to leave again, but the progamming language and partially also libraries had been nailed: Ruby and it’s WEBrick framework. After the Hackday I worked on it a few more hours and it now already saves feeds to a cache. The Mercurial repository is at http://noone.org/hg/sfc-proxy.
There were several reasons which spoke for using Ruby instead of Perl (my favourite progamming language and the one I’m most experienced in): Ruby brings HTTP and RSS support already in it’s standard classes and Tobias is more experienced in Ruby than Perl. I started to learn Ruby a few years ago to look beyond my own nose and to get my hands dirty on some object-oriented and nice programming language, but I hadn’t found an appropriate project until now, so this was one more reason to not do it in Perl.
I also worked on my Debian package of Conkeror during Hackday. It’s already usable and I now use Conkeror as primary web browser on my EeePC, but e.g. the man page is still missing. As soon as I have the minimum in necessary documentation ready I’ll let it upload to Debian Experimental (since its dependency XULRunner 1.9 is also only in Debian Experimental yet). The Mercurial repository for the Debian packaging of Conkeror is at http://noone.org/hg/conkeror/debian
Those who were still at Hackday in the evening decided that the
Webtuesday Hackday should become a regular institution and should take
place approximately every two months, but stay a one day event (for
now). I already look forward to the next Webtuesday Hackday.
Tagged as: Atom, Conkeror, data squid, Debian Experimental, Die Welt ist klein, Events, Freenode, Google, Hackday, Hacks, hg, HTTP, IRC, liip, Mercurial, NDA, Open Source, Open Source Jam, Other Blogs, Perl, Planet Webtuesday, proxy, RDF, RSS, Ruby, SFC, tuxedo, WEBrick, Webtuesday, XULRunner, Zürich
// show without comments // write a comment
Related stories
Thursday·02·March·2006
Blosxom like alternatives to Blosxom //at 02:10 //by abe
I really like the simplicity of Blosxom as blogging framework and I also like Perl very much. But somehow this Perl 4 alike global variables madness of Blosxom v2 sucks in several ways: It effectively prevents Blosxom from being used with mod_perl and it’s just not what I would call an API. I would like to have a more object-oriented plugin API and it should be save for use with FastCGI, mod_perl or similar possibilities to cache the parsed script code instead of reparsing with each request. Another thing should be a tagging facility. Had to write that by myself for Blosxom v2. (Wasn’t that hard though.) But since Blosxom v3 development seemed to have stopped in May 2004, I have been thinking about and looking for alternatives.
First thought was to write a Blosxom clone by myself using Embperl as framework (as I did with web galleries after not finding any web gallery software fitting all my needs).
But since I got infected with Ruby recently, I also thought about writting a Blosxom clone in Ruby, which would give me quite a lot of Ruby experience and would make a good fit since Ruby as well as Blosxom have some kind of Zen (or KISS) philosophy. The next thought was: I can’t be the first to come up with that idea and googled a little bit.
First thing I digged up was Rage, some kind of Blosxom on Rails. But I didn’t find any source code although the author seems to prefer open source software. Seems as if it is seems to be ready for production but not ready for public release.
The next thing I found was hint to some Blosxom clones in the Ruby Application Archive (RAA). Unfortunately two of them (sakura and lily) seem to have Japanese only web pages. :-(
But for luck the third Ruby based Blosxom clone found in the RAA, Blosxonomy, seems to be quite well featured, under actual development, has a english written web page and one of if its main concepts is taggability. And also the other core concepts sound fine: simplicity, extensibility and compatibility. Sounds really perfect and I’ll probably give it a try, but not on my current blog host: There is no Ruby installed and it’s not my own box.
Now playing: Rolling Stones — Ruby Tuesday
Tagged as: Blogging, Blosxom, Blosxonomy, CGI, Embperl, mod_perl, Now Playing, Open Source, Perl, Ruby, Ruby on Rails, Tagging
// show without comments // write a comment