Archive for February, 2010

Wanted: Schedule Monkey

February 24, 2010

If you have any open source writing or writing-related opportunities, let us know and we’ll pimp them here.

Love technology? Love a challenge? We have the job for you.

Red Hat, the defining technology company of the 21st century, continues to expand its team to create compelling open source products.

We need someone to monkey around with our schedules. We have a bunch of schedules for our writers, and we need to merge them into one uber-schedule. We’re working with open source tools, so we need someone who isn’t scared of TaskJuggler.

You don’t need millions of years in the industry – you just need to be able to learn new tricks.

This is a part-time job is based in Brisbane, Australia. Check it out on seek.com.

Advertisements

Turning a comma-separated list into an <itemizedlist>

February 13, 2010

Something I encounter occasionally is a comma-separated list of items in a paragraph that really should be an <itemizedlist>. So I created a script takes the selected text and creates an <itemizedlist> by splitting the text up where ever a comma appears.

I use TextMate for my editing and write scripts for it using ruby. Many of my colleagues use gedit so I have also created a gedit version. There are no instructions here on how to set these up in your editor, that is an exercise left up to the reader.

As an example:

publish, security, subscription, subscription-listener, and interface 

is turned into

<itemizedlist>
    <listitem><para>publish</para></listitem>
    <listitem><para>publish</para></listitem>
    <listitem><para>security</para></listitem>
    <listitem><para>subscription</para></listitem>
    <listitem><para>subscription-listener</para></listitem>
    <listitem><para>and interface</para></listitem>
</itemizedlist>

Note that it relies on the use of the serial comma to get the last item and doesn’t remove the “and” from the beginning of the last item. I have kept each <listitem> on a single line for neatness because the use-case for this script usually involves the items in the list being single words or very short phrases.

The gedit snippet

Note that this is Python, so the white space at the beginning of lines does matter.

<itemizedlist>
$<
text = $GEDIT_SELECTED_TEXT
tab = "    "
joined = ""
output = "";

for line in text.split("\n"):
  line = line.strip()
  joined = joined+" "+line

for item in joined.split(","):
  item = item.strip();
  if item != "" :
    output += tab+"<listitem\><para\>item</para\></listitem\>\n";

return output;
>
</itemizedlist>

TextMate command script

#!/usr/bin/env ruby -w
text = ENV['TM_SELECTED_TEXT']
tab = "    "
joined = ""
text.each do |line|
	line = line.strip
	joined = joined+" "+line
end

puts "<itemizedlist>"

joined.split(",").each  do |item|
  item = item.strip
  if item != "" then
    puts "#{tab}<listitem><para>#{item}</para></listitem>"
  end
end

puts "</itemizedlist>"

Cross-posted from: http://shinysparkly.com/blog/2010/02/12/turning-a-comma-seperated-list-into-a-itemizedlist/