Hi Till,
What about the following? I basically search for a pattern
"not backslash" + (even number of backslashes) + % + rest
Probably, removing \verb|| etc is not worth the trouble till users
face a problem...
Srinath
============ vim solution ====================
" StripComments: {{{
" Description:
function! StripComments(str)
return substitute(a:str, '\\\@<!\(\\\\\)*\zs%.*', '', 'g')
endfunction " }}}
echo StripComments('This is a %comment')
echo StripComments('This is not a \%comment')
echo StripComments('This is a \\%comment')
echo StripComments('This is not a \\\%comment')
echo StripComments('This is a \\\\%comment')
=========== python solution =================
import re
re_comment = re.compile(r'(?<!\\)((\\\\)*)%.*')
def strip_comments(instr):
print re.sub(re_comment, r'\1', instr)
strip_comments(r'This is a %comment')
strip_comments(r'This is not a \%comment')
strip_comments(r'This is a \\%comment')
strip_comments(r'This is not a \\\%comment')
strip_comments(r'This is \a %comment')
=======================================
On Sun, Jan 31, 2010 at 11:23 AM, Till Maas <ope...@ti...> wrote:
> On Sun, Jan 31, 2010 at 07:03:05AM +0000, Jan Larres wrote:
>
>> I recently found another small bug with the BibTeX completion. If there
>> is a commented out \bibliography{} command before the actual one,
>> latex-suite erroneously tries to use the commented out one. In my case
>> this led to completion not working because the commented out command
>> referred to a non-existing file.
>>
>> Since there was a BibTeX example posted recently, you can just reuse
>> that and insert a line like
>>
>> %\bibliography{doesnotexist}
>>
>> before the existing \bibliography{} command.
>
> Yes, I can reproduce this. Does someone maybe new a good way to always
> strip "%"-style comments from a line in a tex file? Currently there are
> afaics several different approaches with regexes in vim-latex, therefore
> I would like to have one way I can use everywhere. It is not just
> everything since a %-sign to the end of the line, as you can see in
> these examples:
>
> %comment
> this is \%not a comment
> this is \\%again a comment
> this is \\\%not a comment anymore
>
> Also I am not sure about verbatim-environments and the \verb command,
> but maybe there will always be some cases, where it does not work.
>
> Regards
> Till
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> Vim-latex-devel mailing list
> Vim...@li...
> https://lists.sourceforge.net/lists/listinfo/vim-latex-devel
>
>
|