andrewheiss / SublimeStataEnhanced

Plugin that adds support for Stata 11–15 for Sublime Text 2 and 3
55 stars 22 forks source link

Comments after line continuation marks #23

Closed ewancarr closed 8 years ago

ewancarr commented 9 years ago

Problem

Where there are comments after line continuation marks (///), the line continuation regex in text_2_stata.py isn't triggered, so the line continuation marks are stripped altogether.

For example:

label define countryname    ///
     1 "Belgium"            /// BE
     2 "Bulgaria"           /// BG
     3 "Switzerland"        /// CH
     4 "Cyprus"             //  CY

Results in:

. label define countryname   1 "Belgium" 

.  2 "Bulgaria" 
unrecognized command:  2 invalid command name
r(199);

.  3 "Switzerland" 
unrecognized command:  3 invalid command name
r(199);

.  4 "Cyprus"
unrecognized command:  4 invalid command name
r(199);

Fix

I've found that extending the line continuation regex (line 18), to additionally match anything after ///, fixes this.

From:

clean = re.sub("/{3,}\\n", " ", clean)

To:

clean = re.sub("/{3,}.*\\n", " ", clean)

But I haven't tested this extensively.

NilsEnevoldsen commented 9 years ago

Notably, even a single space after the line continuation marks will trigger this bug.