bugGNU nano - Bugs: bug #23270, a # inside a string is improperly...

 
 

bug #23270: a # inside a string is improperly highlighted as a comment

Submitted by:  Mark Pinto <markybob>
Submitted on:  Fri 16 May 2008 07:55:56 PM UTC  
 
Severity: 3 - NormalStatus: Fixed
Assigned to: Benno Schulenberg <bens>Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 17 May 2014 07:29:30 PM UTC, comment #3:

The requirement that "#" must be preceded by blank space (or be the first character of a line) in order to be recognized as a comment starter has been added to SVN, r4863. I think that is a reasonable requirement that will almost always be met, when people intend to have legible comments. It solves your issue of having a "#" tightly embedded in a string, but as Chris explained, it cannot be fixed in general. Therefore closing this.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Sun 23 Feb 2014 10:30:50 AM UTC, comment #2:

I would propose that for a # to be recognized as a comment starter it must not be directly preceded by anything but whitespace. Of course Python itself will recognize it as a comment, but it's ugly to glue a comment to a statement, so I would argue that it is proper then to not colour it. It is not a general solution, of course, but it would avoid this case and probably some others.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Tue 03 Jun 2008 03:11:38 AM UTC, comment #1:

Unfortunately this is just a demomstration of the fact that syntax highlighting is done in a sequential order. There is probably a way to fix this but it would probably require a fairly intensive regular expression.

A simpler fix would be to move the comment line:
color brightred "#.*$"
to above all the "color brighgreen" lines, but then strings embedded in comments would be equally mis-highlighted:

# This string will be "improperly highlighted"

Chris Allegretta <astyanax>
Project Administrator
Fri 16 May 2008 07:55:56 PM UTC, original submission:

nano should not highlight characters after a '#' as a comment if it is inside a single or double quote. an example of this would be:

url = "http://mail.google.com/mail/?view=cm&fs=1&to=%s#compose"

"#compose" is not a comment, but part of the string

Mark Pinto <markybob>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bens (Posted a comment)
  • -unavailable- added by astyanax (Posted a comment)
  • -unavailable- added by markybob (Submitted the item)
  • -unavailable- added by markybob
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 22 Jul 2016 03:02:52 PM UTCbensStatusReady For Test=>Fixed
    Sat 17 May 2014 07:29:30 PM UTCbensStatusNeed Info=>Ready For Test
      Open/ClosedOpen=>Closed
    Sun 23 Feb 2014 10:30:50 AM UTCbensStatusNone=>Need Info
      Assigned toNone=>bens
      Summaryfaulty python syntax highlighting=>a # inside a string is improperly highlighted as a comment
    Fri 16 May 2008 07:55:56 PM UTCmarkybobCarbon-Copy-=>Added -unavailable-

    Back to the top


    Powered by Savane 3.1-cleanup1