-
Notifications
You must be signed in to change notification settings - Fork 56
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
Else block always runs #150
Comments
If there is more than one line of code, simply require two blank lines instead of one for the chunk to be considered complete. |
(i.e. two |
Brilliant! |
Wait, how does it do it for python, then? |
It doesn't. Since Hydrogen is 100% language-agnostic, it uses only general syntax elements like indentation and the Recently a separate python-specific add-on package was developed to expand code lines. See nikitakit/hydrogen-python#10 for the difficulty of correctly implementing this feature. This is something Hydrogen struggles with in general because of its language-independentness... Here's the same issue in Javascript. I think it's something that could be improved in Hydrogen... If you had a suggestion I might mention it to the other maintainers and try to create a PR for it. |
I thought you were in charge of that, or is it too much of a pain to implement? You can nest if/else in an ifelse fold if if is followed by else in the next line? |
I am. And I edited it recently to include the ending But it's just a plain regex setting (that a core Atom package then implements) and Atom can't do regexes across lines anyways. So I don't think it's possible to say " |
In Javascript, you could put |
Multi-line regex? |
At least not for syntax highlighting. I doubt it allows it here, though I could try it out. |
Wait, this is odd. Python has multi-line strings. Doesn't it highlight them? Conceptually, |
Yes, but the token that it looks for in the regular expression never spans a newline. I.e. the That's why it's impossible, for example, to highlight Setext headers in Markdown |
Actually, it is ended by an else block or a line containing anything that doesn't start with |
But that is not the same, tho, right? Because you can look for environment delimiters...at least that is what I'm assuming. |
The markdown example has no delimiter to start the header, just to end it. |
With the syntax highlighting yes. But not the fold end marker to my knowledge. I haven't tried but I'd be surprised. |
What's a simple regex to try?
|
Something like that, yeah. Remember that you can have |
So |
Oh right we use |
@mcaceresb
This is because we run other commands after the
if
clause gets sent. Not really sure the best way to fix this. In Jupyter Notebook/Atom you can just be careful to only send the entire if/else block. In Jupyter console, you can fix this by wrapping the entire block in a pair of braces.Console workaround:
The text was updated successfully, but these errors were encountered: