auto
  /   ˆ{‹„„-i[D<†ªoZƒ›Ù«Â457_‘I|¥‰ÓMdœv ©ƒ†ü+=ÂÁ  5   ˆl–äY>” ”¾R( 	ÅåÁãL©‹Fÿ�þB gßòJèÃ'óÅƒh¹ÄÃÂ É    ‹      Í”]o›0†ïû+Î|±;8²­MS‘)M¢”iš¦]8Øk#ã5ë~ýì�(YÕtW»l?ïá}ýE_dó4ÿ´Ãûüv
‹ï¦“ˆ‡ø1J³<ë†þ @Ï�Ê˜v„¸Ýnýmä+½Æ|‰•ÙÔCìŒ–…ñ¹á$¹ ®/¹ Z	Æí¨‘¦É¤áâ;¨P}3�ä"ÂZ®]UN±G¬÷*ºRüÁžÚñÝ/Øj§wŸ:¡¦‚{f¡&&Fµ$¡r³†N1AY¨¦ÃUÍš¯þZ–Xmbòy’Î¿XMåÔ	ePiQÆämÏ®çñIfl#(²§™Ûž™²ÎÀFqYJÁÏÂw=|'œ/˜õL&ºBËÖHÕQ´O£ªîZf³¾²	*}JõÿÝl°â—ÉXÜ,Ç³<›,û)á®ÄÑÝqH²`Z42©Ea”~Ø›ì/›U×^š°· ÝÚ‘Àƒ'É¿ð]ªš}êüœg‹—»g²vÅÔqêû‘ÑpFÞàÊ/!ŽìþŸD¢qîù!Ï¡ùlšàµ7zAa4
ßücš?Ü}¸?—wÇ™b7üd§ô{~        auto
  ?   ˆl–Ým_Jå2Ž¥2 ƒp ¸”Å£�þB2‰få	,¯:ã€óÆƒqç…Å_ˆI|¥�+V[(ÅÄ â    package LatexIndent::TrailingComments;

#	This program is free software: you can redistribute it and/or modify
#	it under the terms of the GNU General Public License as published by
#	the Free Software Foundation, either version 3 of the License, or
#	(at your option) any later version.
#
#	This program is distributed in the hope that it will be useful,
#	but WITHOUT ANY WARRANTY; without even the implied warranty of
#	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#	GNU General Public License for more details.
#
#	See http://www.gnu.org/licenses/.
#
#	Chris Hughes, 2017
#
#	For all communication, please visit: https://github.com/cmhughes/latexindent.pl
use strict;
use warnings;
use LatexIndent::Tokens qw/%tokens/;
use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active $is_m_switch_active/;
use LatexIndent::GetYamlSettings qw/%mainSettings/;
use LatexIndent::LogFile qw/$logger/;
use Data::Dumper;
use Exporter qw/import/;
our @EXPORT_OK
    = qw/remove_trailing_comments put_trailing_comments_back_in $trailingCommentRegExp add_comment_symbol construct_trailing_comment_regexp @trailingComments/;
our @trailingComments;
our $commentCounter = 0;
our $trailingCommentRegExp;

sub construct_trailing_comment_regexp {
    my $notPreceededBy = qr/${${$mainSettings{fineTuning}}{trailingComments}}{notPreceededBy}/;

    $trailingCommentRegExp = qr/$notPreceededBy%$tokens{trailingComment}\d+$tokens{endOfToken}/;
}

sub add_comment_symbol {

    # add a trailing comment token after, for example, a square brace [
    # or a curly brace { when, for example, BeginStartsOnOwnLine == 2
    my $self  = shift;
    my %input = @_;

    my $commentValue = ( defined $input{value} ? $input{value} : q() );

    # increment the comment counter
    $commentCounter++;

    # store the comment -- without this, it won't get processed correctly at the end
    push( @trailingComments,
        { id => $tokens{trailingComment} . $commentCounter . $tokens{endOfToken}, value => $commentValue } );

    # log file info
    $logger->trace("*Updating trailing comment array") if $is_t_switch_active;
    $logger->trace( Dumper( \@trailingComments ), 'ttrace' ) if ($is_tt_switch_active);

    # the returned value
    return $tokens{trailingComment} . $commentCounter . $tokens{endOfToken};
}

sub remove_trailing_comments {
    my $self = shift;

    $commentCounter = 0;

    $logger->trace("*Storing trailing comments") if $is_t_switch_active;

    my $notPreceededBy = qr/${${$mainSettings{fineTuning}}{trailingComments}}{notPreceededBy}/;

    # perform the substitution
    ${$self}{body} =~ s/
                            $notPreceededBy  # not preceded by a \
                            %        # % 
                            (
                                \h*? # followed by possible horizontal space
                                .*?  # and anything else
                            )
                            $        # up to the end of a line
                        /   
                            # increment comment counter and store comment
                            $commentCounter++;
                            push(@trailingComments,{id=>$tokens{trailingComment}.$commentCounter.$tokens{endOfToken},value=>$1});

                            # replace comment with dummy text
                            "%".$tokens{trailingComment}.$commentCounter.$token