I made some science.
-
Comments:
- here.
You too can make science, by participating in the MIT weblog survey. Go on, you know you want to…
You too can make science, by participating in the MIT weblog survey. Go on, you know you want to…
There are a couple of instances of scripts out there that automatically apply abbr and acronym tags to pages, but I wanted to be able to do the same in ecto. This is also the first time I wrote a plugin script for ecto, and I wanted to do it in python. Please note that this here script is untested until I get onto my Mac and test the hell out of it. The script works, with the caveat listed in TODO.
1 #! /usr/bin/env python
2
3 'A script for ecto that adds abbr and acronym tags to the text'
4
5 TODO = '''
6 Fix it so that acronyms without a space either side (for example,
7 that finish a sentence) work.
8
9 Lookup on the internet for a list of acronyms/abbreviations?
10 '''
11
12 acronyms={'WYSIWYG':'What You See Is What You Get',
13 'DOM':'Document Object Model'}
14 abbrs={'XHTML':'eXtensible HyperText Markup Language',
15 'NSLU2':'[Linksys] Network Storage Link (USB) 2.0'}
16
17 # Add more values to your hearts content…
18
19 # get input data - depends on implementation. For ecto:
20 import sys
21 data = open(sys.argv[1]).read()
22
23 # replace only the first instance of each acronym/abbreviation
24 for each in acronyms:
25 data.replace(' '+each+' ', '<acronym title="'+acronyms[each]+'">'+each+'</acronym>',1)
26 for each in abbrs:
27 data.replace(' '+each+' ', '<abbr title="'+abbrs[each]+'">'+each+'</abbr>',1)
28
29 #return data to ecto
30 open(sys.argv[1],'w').write(data)
Note: Comments turned off: too much Spam on this entry.
I know I fixed the Search box in my sidebar, but it’s broken again. I’ll work on fixing it. Do'h! Update: it isn’t broken, just not working how I’d like. It treats all entries as though they are surrounded by double-quotes, for example, searching for Connections Blogsome returns no hits, even though there are posts that have both of these words in them. Whoops! Searching for that will now bring up this post, since those two words now appear in that order. Swapping the order of those words and searching will not find any posts…unless I wrote Blgsme Cnnectins somewhere, with the * replaced by o… Update 2: Now it seems to work. I did put a request in on the forum – I wonder if they fixed it…that was quick!