-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added SublimeLinter-contrib-csl for Citation Style Language #106
Conversation
I don't find the You could probably rename the repo to match our |
Haha, your eyes are just fine, it' hasn't been upstream-ed yet citation-style-language/utilities#40
I'll do that. Would your prefer I just close this PR, wait for the citation-style-language/utilities to merge (or not, and perhaps offer a version that uses a repo from my github…) and then re-open a new PR? Or just keep this open in the interim? |
Fixed the missing -contrib- bit… |
Hm, looks like |
Oh sure, if that's something that's common why not! I was just trying to figure out the most "logical" location for it. The idea for the script comes from utilities maintained by that org, so I thought if it was in one of their repos (the aptly named "utilities" one!) then it would have more legitimacy from (possible) user's perspective… |
Yeah sure, but then we have to wait for the merge, the repo has no commits since 2017. Maybe they waited just for your PR. |
Ah, you do have good eyes… |
I don't have an example plugin. Assuming
If that works: Somehow tell git to add Create an empty file |
Manual: "If including executables or shared libraries, add a .no-sublime-package file. Adding this file to the root of your repository will prevent Package Control from keeping your package packed as a .sublime-package file in ST3." See also SublimeLinter/package_control_channel#106 (comment)
There you go :) |
Yeah, that looks okay.
To put the |
I agree with you entirely that at this point, it would make a lot more sense to have the whole http request and json decode in the linter. I'm absolutely no python dev and I apologize in advance for anything weird, but I came up with this: import requests
from SublimeLinter.lint import PythonLinter
class SublimeLinterContribCsl (PythonLinter):
cmd = None
regex = r'^M="(?P<message>.+)" L=(?P<line>\d+) C=(?P<col>\d+)$'
defaults = {
'selector': 'source.csl, text.xml'
}
def run(self, cmd, code):
url = "https://validator.w3.org/nu/"
files = { 'file': ('style.csl', code) }
data = {
'schema': 'https://raw.githubusercontent.com/citation-style-language/schema/v1.0.1/csl.rnc https://raw.githubusercontent.com/citation-style-language/schema/602ad40976b7b455a3ce0b79f5534e8e75f088e9/csl.sch',
'parser': 'xml',
'laxtype': 'yes',
'level': 'error',
'out': 'json',
'showsource': 'no'
}
response = requests.post(url, data=data, files=files)
json = response.json()
for error_report in json['messages']:
return('M="{}" L={:d} C={:d}'.format(error_report['message'].encode('utf-8'), error_report['firstLine'], error_report['firstColumn'])) The above run() function works in a standalone script, but this show up when I try it in linter.py:
So obviously, the
So, I guess I'm just going about this the wrong way. Do I need to call out from the plugin framework through the use of the Sorry this is getting longer and longer… thank you for your patience. |
Okay down the rabbit hole. It is basically not possible to not use requests for uploading files using the standard Python3.3 library. You can add requests as a dependency in Sublime by creating just another file
As a developer you have to call The return type of
If that works, better though you return just the
|
Wow you're a great teacher thanks for taking the dive!
Two notes : I also had to import logging to get logger to work. Maybe the internet offline check is overkill? |
Yes, you need to import The offline check is overkill, what you probably should do is to add a timeout to the |
From #106 (comment) "contrib-csl comes before contrib-css... here in this PR" so you need to edit this PR before we can ship. |
Oh… i had done, just forgot to push: bd2ed90 |
Oh so you did! Sorry my eyes aren't working…
Ok, fixed.
I've implemented timeout and put in two exception handlers for timeout and connection error. I used a rather high timeout (60 sec) on the |
Just make a new release. EDIT: LGTM! 😁 |
Done! Thanks again @kaste for this interesting initiation to writing SublimeLinter plugins! You rock! 🎸 |
Hi,
I just thought I'd share this linter I created to integrate a shell script that validates Citation Style Language (CSL), a specific schema of XML.
Thanks in advance for your reviews, advice and possible inclusion.
PS: I'm sorry about the name, I didn't realize all contribs should include SublimeLinter-contrib-name, and named my repo SublimeLinter-csl 😕 Is that a problem?