Stylish-Custom-0.1.1.xpi auto!important doesn't get re-enabled after changing the key UnComment ignores starting/ending whitespace chars in selected text (by ignore i mean remove)
@BoffinbraiN if your regexp skills can suggest something better var selectedText = selectedText.replace(/^[\s]*\/\*/, ""); var selectedText = selectedText.replace(/\*\/[\s]*$/, "");
Actually, #2 - Uncomment ... happened to me once. But when i highlighted the same block again, it worked all right. Can i change those iconds to my own? Like the window icon? Looked in about:config for the image location, thought i can 're-locate' it, didn't find it.
Right, i remember now. It (style or a portion) needs to be highlighted. 'Merge' seems to be a bit out of place, IMO. Maybe something like Compress or Compact?
Posted By: ChoGGi var selectedText = selectedText.replace(/^[\s]*\/\*/, ""); var selectedText = selectedText.replace(/\*\/[\s]*$/, "");
Have you tried this: var selectedText = selectedText.replace(/\/\*(.*?)\*\//g,"$1"); Should actually uncomment all comments in selectedText, regardless where they appear. Only thing which could go wrong here: If there's something like "/* blabla /* bla */ bla */" (i.e. a comment inside of a comment), it would break - and make it " bla */". Hm. Could be this one is better: var selectedText = selectedText.replace(/\/\*([^\*]*?)\*\//g,"$1"); which should, given above example, first remove the inner comment markers, and then the outer (because of the "g" = "global" at the end).
Just "out of my mind", not tested - please try first or check with the references. "$1" is a so called back-reference and will be replaced by the first parenthesis term - just as an explanation.
(Remark: Quoting RegExps here is a pain in the `echo app|sed 's/p/s/g'`- the preview suggests you need to double-escape, and after posting it turns out to not be the case...)
Edit: Could be it does not work like that due to the "global" replace (not sure whether you would need a loop over matches for that). If you just want to remove one tuple per time, simply try omitting the "g" then.
Posted By: makondoMaybe something like Compress or Compact?
that doesn't sound like what it does though :)
@Izzy it's easy enough to remove all comments, i'm trying to get just the outer ones (the /* is easy, it's that */ that is annoying) i'll go give your regexp a try, btw you can add \ with (which i'm guessing you did)\
Stylish-Custom-0.1.2.xpi UnComment ignores starting/ending whitespace chars in selected text without removing whitespace
@Izzy they didn't really work but your mention of parenthesis fixed the problem i was having, so thank you :) if anyone is interested var selectedText = selectedText.replace(/^([\s]*)\/\*([\s\S]*)\*\/([\s]*)$/gm,"$1$2$3");
@Izzy they didn't really work but your mention of parenthesis fixed the problem i was having, so thank you :)
I wasn't expecting it to work out-of-the-box - but as I see, you got the idea behind it (i.e. masking the whole string and using back-references), so it was somehow useful at last.
var selectedText = selectedText.replace(/^([\s]*)\/\*([\s\S]*)\*\/([\s]*)$/gm,"$1$2$3");
Jepp - sounds fine. The only irritating thing is the "[\s\S]" part - i.e. "all whitespaces and non-whitespaces". On a quick look, this should be identical to ".*" (all characters). But probably there's some side-effect involved - such as ".*" not matching dots if you do not explicitly tell it to ("/.*/s" AFAIR)? Just out of curiosity.
The other question left: Did you try that on my fine "bla" string ("/* blabla /* bla */ bla */"), i.e. a comment inside the comment? Ooops - yes, should work (since it's greedy). But what about "/* blabla /* bla */"? Could probably happen if one is a bit careless marking the correct block. As long as the outer "/*" has a matching part somewhere behind that string, there should be no problem with the resulting " blabla /* bla ", as the comment would be closed. But probably it's hard to find a "perfect solution" for this:
as it is, it may cause an error (if there's no other closing "*/" behind)
removing it "syntactically correct" (i.e. the inner comment only) could have the same result
running a syntax check first and warn the user ("this may cause..since... Proceed nevertheless?") would probably be not a bad idea, but a huge overhead
ChoGGi, please don't count this a "request" - I'm just brainstorming and pointing. Decide however you like, it will be fine for me (concerning this issue and for now ).
@purpler: It started as a kind of "fork", but was decided to continue as "addon for the addon". This way both projects have their profits: The original Stylish can be extended with the features of this Stylish-Custom - and Stylish-Custom automatically uses fixes and new features of new Stylish versions. To me, this looks like the best way - the only little "disadvantage" is you have to install two extensions instead of one. I can live with that
Posted By: Alirezaaaif you can, add "Open in external editor" button too.
it's already there, but you need itsalltext
Posted By: IzzyThe only irritating thing is the "[\s\S]" part - i.e. "all whitespaces and non-whitespaces". On a quick look, this should be identical to ".*" (all characters).
it leaves the one in the middle and some space on the outside
it goes from the start till the first /* then everything in the middle then the last */ and any whitespace, then joins the whitespaces with the middle if someone runs it on just a /* or */ it doesn't change anything
Posted By: purplermaybe a chance of merging it to upstream stylish release or as a fork?
it's staying separate from stylish. it was a fork, but overlays should be less work when stylish is upgraded (or none at all)
Posted By: IzzyThe only irritating thing is the "[\s\S]" part - i.e. "all whitespaces and non-whitespaces". On a quick look, this should be identical to ".*" (all characters).
(The decimal point) matches any single character except the newline characters: \n \r \u2028 or \u2029. ([\s\S] can be used to match any character including newlines.)
See - I knew there was something. And now I know what it is - thank you again, ChoGGi: You taught me something important to keep in mind!
But what about "/* blabla /* bla */"?
it leaves the one in the middle and some space on the outside
Meaning it returns something like " blabla /* bla ", if I got this right - which means a single "/*" is left, as I guessed already. So what. A warning would be nice in this case, I guess, since the result may break the script. Not sure how the original comment would be treated by JS - but I assume JS would not choke on the "inner comment open" but treat it as part of the comment instead - so after removing the outer comment marks, the problem arises.
You may say that's up to the style writer, and I'm with you. Though it would be nice to be warned in such a case - do you agree? So maybe you count it as a "suggestion" for stylish-custom 0.2.5 or the like?
OK, I can live with that. But could you tell me what happened here: First two items map to the same function. But the second arrow seems to go nowhere. Latest Stylish (1.0.1) and latest Stylish-Custom (0.1.1).
In my opinion, using replace(/\/\*([\s\S]*?)\*\//g, '$1') is the best option. You don't need to specify anything to the left or right of the comment because those are untouched by the replacer. Using the *? means it will match as little as possible and thus work like a real CSS parser will, stopping at the first */, no matter how many /* go before it. Using /g and using [\s\S] have already been explained above. If anyone has code that contains nested or unmatching numbers of comment openings/closings, their syntax is most likely invalid already and so it's not our responsibility to fix it. We just want to remove matching comment boundaries. (Currently in 0.1.2, trying to un-comment a string like boffi/*n*/brain doesn't work at all.)
PS. I still don't see the difference between the Stylish standard 'Turn All Styles On/Off' and the custom 'Disable/Restore Stylish Rules'.
i don't want it to remove boffi/*n*/brain, i was trying to remove them from the outside with maybe some whitespace (the opposite of the Comment button)
PS. I still don't see the difference between the Stylish standard 'Turn All Styles On/Off' and the custom 'Disable/Restore Stylish Rules'.
if you use turn all off you won't be able to work on another style, you will be able to with disable rules
Posted By: Izzy@makondo: ChoGGi didn't announce a 0.1.2, so you probably offering me some spyware
Posted By: ChoGGi right in the mid. of this page:Stylish-Custom-0.1.2.xpi UnComment ignores starting/ending whitespace chars in selected text without removing whitespace...
Am i the only one who see this ^ ? Izzy, are you toying with me?!
i've added an update all button for 0.1.3 (little problem though you need to close then open the manage window or the update styles won't change) i'm going to see about an option to change the window icons before i release 0.1.3
Comments
auto!important doesn't get re-enabled after changing the key
UnComment ignores starting/ending whitespace chars in selected text (by ignore i mean remove)
@BoffinbraiN if your regexp skills can suggest something better
var selectedText = selectedText.replace(/^[\s]*\/\*/, "");
var selectedText = selectedText.replace(/\*\/[\s]*$/, "");
Can i change those iconds to my own? Like the window icon? Looked in about:config for the image location, thought i can 're-locate' it, didn't find it.
var selectedText = selectedText.replace(/\/\*(.*?)\*\//g,"$1");
Should actually uncomment all comments in selectedText, regardless where they appear. Only thing which could go wrong here: If there's something like "/* blabla /* bla */ bla */" (i.e. a comment inside of a comment), it would break - and make it " bla */". Hm. Could be this one is better:
var selectedText = selectedText.replace(/\/\*([^\*]*?)\*\//g,"$1");
which should, given above example, first remove the inner comment markers, and then the outer (because of the "g" = "global" at the end).
Just "out of my mind", not tested - please try first or check with the references. "$1" is a so called back-reference and will be replaced by the first parenthesis term - just as an explanation.
(Remark: Quoting RegExps here is a pain in the `echo app|sed 's/p/s/g'`- the preview suggests you need to double-escape, and after posting it turns out to not be the case...)
Edit: Could be it does not work like that due to the "global" replace (not sure whether you would need a loop over matches for that). If you just want to remove one tuple per time, simply try omitting the "g" then.
@Izzy it's easy enough to remove all comments, i'm trying to get just the outer ones (the /* is easy, it's that */ that is annoying)
i'll go give your regexp a try, btw you can add \ with (which i'm guessing you did)
\
UnComment ignores starting/ending whitespace chars in selected text without removing whitespace
@Izzy they didn't really work but your mention of parenthesis fixed the problem i was having, so thank you :)
if anyone is interested
var selectedText = selectedText.replace(/^([\s]*)\/\*([\s\S]*)\*\/([\s]*)$/gm,"$1$2$3");
if you can, add "Open in external editor" button too.
The other question left: Did you try that on my fine "bla" string ("/* blabla /* bla */ bla */"), i.e. a comment inside the comment? Ooops - yes, should work (since it's greedy). But what about "/* blabla /* bla */"? Could probably happen if one is a bit careless marking the correct block. As long as the outer "/*" has a matching part somewhere behind that string, there should be no problem with the resulting " blabla /* bla ", as the comment would be closed. But probably it's hard to find a "perfect solution" for this:
a much needed addition to Stylish :)
maybe a chance of merging it to upstream stylish release or as a fork?
https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/RegExp it leaves the one in the middle and some space on the outside
it goes from the start till the first /* then everything in the middle then the last */ and any whitespace, then joins the whitespaces with the middle
if someone runs it on just a /* or */ it doesn't change anything it's staying separate from stylish. it was a fork, but overlays should be less work when stylish is upgraded (or none at all)
You may say that's up to the style writer, and I'm with you. Though it would be nice to be warned in such a case - do you agree? So maybe you count it as a "suggestion" for stylish-custom 0.2.5 or the like?
First two items map to the same function. But the second arrow seems to go nowhere. Latest Stylish (1.0.1) and latest Stylish-Custom (0.1.1).
also can you get a screen shot of those menuitems in domi?
and anything in the error console?
That shot above, could be a theme but it appears to be the default, right?
@makondo: ChoGGi didn't announce a 0.1.2, so you probably offering me some spyware
replace(/\/\*([\s\S]*?)\*\//g, '$1')
is the best option. You don't need to specify anything to the left or right of the comment because those are untouched by the replacer. Using the *? means it will match as little as possible and thus work like a real CSS parser will, stopping at the first */, no matter how many /* go before it. Using /g and using [\s\S] have already been explained above. If anyone has code that contains nested or unmatching numbers of comment openings/closings, their syntax is most likely invalid already and so it's not our responsibility to fix it. We just want to remove matching comment boundaries. (Currently in 0.1.2, trying to un-comment a string likeboffi/*n*/brain
doesn't work at all.)PS. I still don't see the difference between the Stylish standard 'Turn All Styles On/Off' and the custom 'Disable/Restore Stylish Rules'.
i'm going to see about an option to change the window icons before i release 0.1.3
@makondo :) miight be a little bit before the next one. got a new cpu today, but the mb is having a bit of an issue