[TxMt] Re: LaTeX Tidy and code folding with \labels

Robert Milton robert.gomez.milton at gmail.com
Tue Nov 29 19:04:39 UTC 2016


Done.

> On 29 Nov 2016, at 12:17, René Schwaiger <sanssecours at f-m.fm> wrote:
> 
> Hi Robert,
> 
>> On 29 Nov 2016, at 12:05 , Robert Milton <robert.gomez.milton at gmail.com> wrote:
>> 
>> Hi guys,
>> I guess this is primarily of interest to Rene Schwaiger. A long time ago we discussed LaTeX Tidy, \labels and code folding. I love everything about LaTex Tidy except for the fact that it puts \labels on a separate line to \begin or \end, so when I use code folding all I see is a list of \begins, \ends, \sections and the like, without a \label in sight. Rene pointed me to latextidy.pl, which was the help I needed, and I hacked the file so the code now ends
>> 
>> 	$string =~ s/({[^}]*}[ \t]*)(\n[ \t]*)((\[[^\]]*\][ \t]*)*(\\label[ \t]*(\[[^\]]*\][ \t]*)*{[^}]*}[ \t]*)*)\n?[ \t]*/$1$3$2/mg;
>> 	$string =~ s/((\\label[ \t]*(\[[^\]]*\][ \t]*)*{[^}]*}[ \t]*)+)(\n[ \t]*)(\\end{[^}]*})/$4$1$5/mg;
>> 	$string =~ s/(\\section.*(\\label[ \t]*(\[[^\]]*\][ \t]*)*{[^}]*}[ \t]*))(\S)/$1\n$4/mg;
>> 	$string =~ s/(?<=\S)[ \t]*(?:\n[ \t]*){0,2}(\\section)/\n\n\n$1/mg;
>> 	$string =~ s/(?<=\S)[ \t]*(?:\n[ \t]*){0,1}(\\subsection)/\n\n$1/mg;
>> 
>> 	print $string;
>> 
>> I’ve been using this for a while now and it has proved fairly reliable. I’ve allowed for optional arguments on \labels, labels pinned to \end (for captioned environments), and insert blank lines before \sections and \subsections. Now when I code fold I see not just the environments but their \labels, which mean something to me.
> 
> thank you very much for looking into this. I would be very interested in merging your changes! Can you please open a pull request [1] containing your changes at the official GitHub page of the LaTeX bundle [2]?
> 
> [1]: https://help.github.com/articles/creating-a-pull-request <https://help.github.com/articles/creating-a-pull-request>
> [2]: https://github.com/textmate/latex.tmbundle <https://github.com/textmate/latex.tmbundle>
> 
>> This message is intended in the spirit of giving back. Please feel free to ignore this hack, or try it out, change it, whatever.
>> 
>> Regards
>> Robert Milton
> 
> Kind regards,
>  René
> 
> _______________________________________________
> textmate mailing list
> textmate at lists.macromates.com <mailto:textmate at lists.macromates.com>
> http://lists.macromates.com/listinfo/textmate <http://lists.macromates.com/listinfo/textmate>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20161129/e39b2257/attachment.html>


More information about the textmate mailing list