Hi there,
I'm working on a particular form of yaml (called Feedback) which I'm using as a way of marking up suggestions for documentation. It's still in very early days (say, about 3 hours), but I'm having trouble writing my own language grammar for it.
An example Feedback file currently looks like this:
thesis_author: chris version: 1 commenter: sam
errata: 6: para: 1 comments:
- suggestion: "_in which there are no jobs_, what are jobs? Wouldn't it be simpler to just say that DynaSOAr (oh the pain of mixed case acronyms!) only consists of services?"
para: 2 comments:
- query: "If you're capitalising Web service with capital W, lower case s, why is 'Web Service Provider' all uppercase?"
- typo: "_who's responsibility is to recieve..._ should be whose, and receive. Does LyX still not have a spell-checker? :-("
- typo: "_dynmaically_ should be dynamically"
- suggestion: "_The ability to dynmaically deploy services in response to consumer requests without interruption to the invocation gives considerable scope for different deployment patterns._ This sentence needs breaking down."
This document describes some comments on paragraphs 1 and 2 of page 6 of chris's thesis. As you can see, there are currently three types of comment, a query, suggestion and typo.
I would like the file to have all the features of yaml (inheriting from the lovely yaml bundle), yet override certain things. I want everything between underscores to be italicised (although this will probably change due to code_variables), and I want the different types of comment to be understood by the language grammar separately. I also want certain keywords to be understood.
Attempting to implement these, I came up with the following:
{ scopeName = 'source.yaml.feedback'; fileTypes = ( 'feedback' ); patterns = ( { name = 'markup.italic.feedback'; begin = '_'; end = '_'; }, { name = 'keyword.control.feedback.suggestion'; begin = '- suggestion: "'; end = '"'; patterns = ( { name = 'keyword.operator.feedback'; match = 'suggestion'; } ); }, { include = 'source.yaml'; }, ); }
However, I didn't get the behaviour I wanted. Nothing seems to be in italics, the suggestion keyword is scoped as 'keyword.control.feedback.suggestion', and 'source.yaml.feedback' only. There's no mention of 'keyword.operator.feedback'.
Is there anything obvious that I seem to be doing incorrectly? How is it possible to get a bunch of characters to be scoped with different names. I want to be able to write something like:
{ name = 'keyword.control.feedback'; match = '\b(suggestion|query|typo|technical)\b'; },
I'm sorry if I'm being a numpty with this!
Thanks in advance of any help, Sam Aaron
After a bit more work I've come up with the following:
{ scopeName = 'source.feedback'; fileTypes = ( 'feedback' ); patterns = ( { name = 'meta.comment.suggestion.feedback'; match = '\s- suggestion:\s".*"\s?\n'; }, { name = 'keyword.other.feedback'; match = '\b(suggestion|query|typo)\b'; }, { name = 'markup.italic.feedback'; match = '\b_.*?_\b'; }, ); }
This is a list of rules I'd like to get working, but they don't seem to play nicely together. For example, if the meta pattern matches a line, then the keyword and markup patterns fail to match anything inside the meta pattern.
If I add a final pattern at the end of the patterns list:
{ include = 'source.yaml'; },
Then this seems to override the keyword and markup patterns, but not the meta pattern. I really don't understand this behaviour.
Hopefully this makes my query a little easier to understand.
Thanks again, Sam Aaron
On 08/10/06, sam aaron sam.maillists@googlemail.com wrote:
Hi there,
I'm working on a particular form of yaml (called Feedback) which I'm using as a way of marking up suggestions for documentation. It's still in very early days (say, about 3 hours), but I'm having trouble writing my own language grammar for it.
An example Feedback file currently looks like this:
thesis_author: chris version: 1 commenter: sam
errata: 6: para: 1 comments:
- suggestion: "_in which there are no jobs_, what are jobs?
Wouldn't it be simpler to just say that DynaSOAr (oh the pain of mixed case acronyms!) only consists of services?"
para: 2 comments: - query: "If you're capitalising Web service with capital W,
lower case s, why is 'Web Service Provider' all uppercase?"
- typo: "_who's responsibility is to recieve..._ should be
whose, and receive. Does LyX still not have a spell-checker? :-("
- typo: "_dynmaically_ should be dynamically" - suggestion: "_The ability to dynmaically deploy services in
response to consumer requests without interruption to the invocation gives considerable scope for different deployment patterns._ This sentence needs breaking down."
This document describes some comments on paragraphs 1 and 2 of page 6 of chris's thesis. As you can see, there are currently three types of comment, a query, suggestion and typo.
I would like the file to have all the features of yaml (inheriting from the lovely yaml bundle), yet override certain things. I want everything between underscores to be italicised (although this will probably change due to code_variables), and I want the different types of comment to be understood by the language grammar separately. I also want certain keywords to be understood.
Attempting to implement these, I came up with the following:
{ scopeName = 'source.yaml.feedback'; fileTypes = ( 'feedback' ); patterns = ( { name = 'markup.italic.feedback'; begin = '_'; end = '_'; }, { name = 'keyword.control.feedback.suggestion'; begin = '- suggestion: "'; end = '"'; patterns = ( { name = 'keyword.operator.feedback'; match = 'suggestion'; } ); }, { include = 'source.yaml'; }, ); }
However, I didn't get the behaviour I wanted. Nothing seems to be in italics, the suggestion keyword is scoped as 'keyword.control.feedback.suggestion', and 'source.yaml.feedback' only. There's no mention of 'keyword.operator.feedback'.
Is there anything obvious that I seem to be doing incorrectly? How is it possible to get a bunch of characters to be scoped with different names. I want to be able to write something like:
{ name = 'keyword.control.feedback'; match = '\b(suggestion|query|typo|technical)\b'; },
I'm sorry if I'm being a numpty with this!
Thanks in advance of any help, Sam Aaron
On 8. Oct 2006, at 19:07, sam aaron wrote:
[...] I didn't get the behaviour I wanted. Nothing seems to be in italics [...]
The YAML grammar use begin/end rules and inside those, your rules are not active.
http://lists.macromates.com/pipermail/textmate/2006-September/ 012876.html
The YAML grammar use begin/end rules and inside those, your rules are not active.
That's interesting, so there's no possibility of overriding the YAML rules if I include them with one of my patterns?
Interestingly, even if I don't include the YAML rules, I still have the issues I explained previously:
This is a list of rules I'd like to get working, but they don't seem to play nicely together. For example, if the meta pattern matches a line, then the keyword and markup patterns fail to match anything inside the meta pattern.
I tried reading the TextMate manual for help on this, but didn't find anything on mixing patterns, and pattern precedence. Is there any information resource that someone could point me towards with relation to these issues?
Thanks, Sam Aaron
On 8. Oct 2006, at 22:53, sam aaron wrote:
The YAML grammar use begin/end rules and inside those, your rules are not active.
That's interesting, so there's no possibility of overriding the YAML rules if I include them with one of my patterns?
Nope.
Interestingly, even if I don't include the YAML rules, I still have the issues I explained previously: [...]
You did not provide any sample document, but it appears to me that what you want is for the different rules to overlap, i.e. match the same characters in the document.
This is not how the parser works. When one rule has matched a portion of the text, no other rules can match that text.
This is not how the parser works. When one rule has matched a portion of the text, no other rules can match that text.
ok, so only one scope can be applied to each character of the document?
but it appears to me that what you want is for the different rules to overlap, i.e. match the same characters in the document.
yes, for some reason i thought that this was possible. For example, consider the following line:
* this is part of a list _here i want italics_
I thought it was possible to have the characters between the underscores to belong to an 'italic scope' and also a 'list item scope'. I guess you kind of achieve this by naming the italics scope as an extention of the list scope: list.italics or is it recommended to just use an italics scope, losing its relationship with the list?
My next question (which I think I already know the answer to), so if I want to have the equivalent of an underscore italics rule, i have to declare it as an internal pattern to all the patterns I want itallic behaviour inside? I guess this is where you'd use the grammar repository?
Sorry for the potentially obvious questions.
Thanks, Sam
On 9. Oct 2006, at 18:39, sam aaron wrote:
This is not how the parser works. When one rule has matched a portion of the text, no other rules can match that text.
ok, so only one scope can be applied to each character of the document?
Only one rule can assign a scope to a particular character, yes. But scopes nest, so if you use a begin/end rule, everything matching inside this, will inherit the scope of the begin/end rule.
but it appears to me that what you want is for the different rules to overlap, i.e. match the same characters in the document.
yes, for some reason i thought that this was possible. For example, consider the following line:
- this is part of a list _here i want italics_
I thought it was possible to have the characters between the underscores to belong to an 'italic scope' and also a 'list item scope'. I guess you kind of achieve this by naming the italics scope as an extention of the list scope: list.italics or is it recommended to just use an italics scope, losing its relationship with the list?
You nest the rules, e.g.:
{ name = 'markup.list'; begin = '^ * '; // simplified list item start end = '$'; // end list item at end-of-line patterns = ( { name = 'markup.italic'; begin = '_'; end = '_'; } ); }
My next question (which I think I already know the answer to), so if I want to have the equivalent of an underscore italics rule, i have to declare it as an internal pattern to all the patterns I want itallic behaviour inside? I guess this is where you'd use the grammar repository?
Yes.
thanks for your clarifications Allan :-)
On 09/10/06, Allan Odgaard throw-away-1@macromates.com wrote:
On 9. Oct 2006, at 18:39, sam aaron wrote:
This is not how the parser works. When one rule has matched a portion of the text, no other rules can match that text.
ok, so only one scope can be applied to each character of the document?
Only one rule can assign a scope to a particular character, yes. But scopes nest, so if you use a begin/end rule, everything matching inside this, will inherit the scope of the begin/end rule.
but it appears to me that what you want is for the different rules to overlap, i.e. match the same characters in the document.
yes, for some reason i thought that this was possible. For example, consider the following line:
- this is part of a list _here i want italics_
I thought it was possible to have the characters between the underscores to belong to an 'italic scope' and also a 'list item scope'. I guess you kind of achieve this by naming the italics scope as an extention of the list scope: list.italics or is it recommended to just use an italics scope, losing its relationship with the list?
You nest the rules, e.g.:
{ name = 'markup.list'; begin = '^ \* '; // simplified list item start end = '$'; // end list item at end-of-line patterns = ( { name = 'markup.italic'; begin = '_'; end = '_'; } ); }
My next question (which I think I already know the answer to), so if I want to have the equivalent of an underscore italics rule, i have to declare it as an internal pattern to all the patterns I want itallic behaviour inside? I guess this is where you'd use the grammar repository?
Yes.
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate