Sat, 11 Jul 2009 02:14:33 +0100
Add util module and move first helper function into it
6
cf40d55f8122
Add util module and move first helper function into it
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 | |
cf40d55f8122
Add util module and move first helper function into it
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 | -- Takes "Why I like fish" and returns "why-i-like-fish" |
cf40d55f8122
Add util module and move first helper function into it
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 | function make_short_title(long_title) |
cf40d55f8122
Add util module and move first helper function into it
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 | local short_title = long_title:gsub("%W+", "-"):lower():sub(1,45) |
cf40d55f8122
Add util module and move first helper function into it
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 | if #long_title:gsub("%W+", "-") > 45 then |
cf40d55f8122
Add util module and move first helper function into it
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 | short_title = short_title:gsub("%-%w+$", ""); |
cf40d55f8122
Add util module and move first helper function into it
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 | end |
cf40d55f8122
Add util module and move first helper function into it
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 | return short_title; |
cf40d55f8122
Add util module and move first helper function into it
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 | end |