Closed nicinabox closed 10 years ago
Might be worth making the comment syntax configurable via a regex or something like that instead?
Yeah, that would be awesome. I would worry about the user getting the regex right though. I had to do quite a bit of testing to make sure this one worked out. The chance of someone using a custom regex and getting it wrong is quite high.
I was actually thinking of implementing a generic version of tag support like @mtford90 suggested. My thought was to have two potential inputs for the user, a simplified and a full regex method.
The full regex would accept an actual regex and would assume the user knows what they are doing / tests their regex properly. It would use the users regex verbatim for the _comment_regex
(https://github.com/nhmood/watson-ruby/blob/master/lib/watson/parser.rb#L211)
The simplified version would require a predefined format:
[tag_syntax]
>>TAG<< +++ COMMENT
Then, it would create a regex based off the TAG
and COMMENT
locations in the string (essentially replace TAG
and COMMENT
with \w+
or something of the likes) and use the generated regex for _comment_regex
.
I haven't tried implementing this yet so I don't know how hard / if it is possible, but it doesn't seem too far fetched.
You would then specify which form (simplified vs. full) in the config file by prepending something to the string (r
for full regex perhaps)
I will give this a go, if I can't get anywhere or find that it will take too long I'll accept this PR :)
Predefined format is what I thought would be easiest as well. I don't think it's too far-fetched: replace the keywords with regex and off you go, like you said.
Maybe I should just send a PR for that instead?
Yeah if you want to implement and submit a PR that would be great! I only thought of a potential solution, no implementation yet, plus it would be an extension to the work you did for this PR.
See #237 for configurable implementation :)
Closed with #237, thanks :)
Hi there!
I've been trying to work watson into my daily workflow, but the major hangup was the tag syntax. All of our comments are in the
TAG: x
syntax, rather than watson's[tag] - x
. This PR adds support for both and clarifies the comment regex. I hope you consider it!Thanks!