As some of you probably know, since revision 948, TextMate supports the ability to have the entire document together with all the scope information as input for command. This is done by setting a key "inputFormat" with value "xml" into the plist file for the command, and setting the input to the command to be the entire document. This will input the document in a "pseudo-xml" format, of the type: <scopename>text</scopename>, with nestings etc.
The ScopeHandler class is a Ruby class I just put together that offers you an easy interface to this “xml”-style input. I've set up a home page for this class with a couple of descriptions and examples here: http://skiadas.dcostanet.net/afterthought/the-scopehandler-class/ The actual file can be found here: http://skiadas.dcostanet.net/uploads/scopeHandler.rb Use at your own risk. Let me know if you do. Feel free to suggest additions/corrections/more examples/ideas for use.
Haris
On 13/4/2006, at 6:37, Charilaos Skiadas wrote:
[...] I've set up a home page for this class with a couple of descriptions and examples here:
This is pretty sweet! A few comments (I can’t comment on the page):
* you mention one could use `echo` as command (to test the XML input), you probably meant `cat`. * maybe let the ScopeHandler take an IO object instead of a string (so we can just pass it STDIN.) * you also need to escape/unscape &/&.
On Apr 13, 2006, at 12:09 AM, Allan Odgaard wrote:
This is pretty sweet! A few comments (I can’t comment on the page):
Quite true and irritating that the page doesn't allow for comments. I'll need to mess with the configurations somewhere. In any case, I created a blog post so that people can comment: http://skiadas.dcostanet.net/afterthought/2006/04/12/the-scopehandler- class/
- you mention one could use `echo` as command (to test the XML
input), you probably meant `cat`.
yeap, good catch.
- maybe let the ScopeHandler take an IO object instead of a string
(so we can just pass it STDIN.)
Hm, that'll probably make sense. I changed it.
- you also need to escape/unscape &/&.
Updated it. I guess the order of gsubs matters on this one :)
Haris