Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V3.9.3 #270

Merged
merged 4 commits into from
May 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions LatexIndent/Document.pm
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,19 @@ sub output_indented_text{
$logger->info("Not outputting to file; see -w and -o switches for more options.");
}

# output the log file information
$self->output_logfile();

# output to screen, unless silent mode
print ${$self}{body} unless $switches{silentMode};

return;
}

sub output_logfile{

my $self = shift;
#
# put the final line in the logfile
$logger->info("${$masterSettings{logFilePreferences}}{endLogFileWith}") if ${$masterSettings{logFilePreferences}}{endLogFileWith};

Expand All @@ -162,19 +175,18 @@ sub output_indented_text{
# open log file
my $logfileName = $switches{logFileName}||"indent.log";
my $logfile;
open($logfile,">","${$self}{cruftDirectory}/$logfileName") or die "Can't open $logfileName";
my $logfilePossible = 1;
open($logfile,">","${$self}{cruftDirectory}/$logfileName") or $logfilePossible =0;

foreach my $line (@{LatexIndent::Logger::logFileLines}){
print $logfile $line,"\n";
}
if($logfilePossible){
foreach my $line (@{LatexIndent::Logger::logFileLines}){
print $logfile $line,"\n";
}

# close log file
close($logfile);

# output to screen, unless silent mode
print ${$self}{body} unless $switches{silentMode};
# close log file
close($logfile);
}

return;
}

sub process_body_of_text{
Expand Down
10 changes: 6 additions & 4 deletions LatexIndent/FileExtension.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ sub file_extension_check{
if ($fileName ne "-"){
if (!$ext) {
$logger->info("*File extension work:");
$logger->info("latexindent called to act upon $fileName without a file extension;\nsearching for file with an extension in the following order (see fileExtensionPreference):");
$logger->info(join("\n",@fileExtensions));
$logger->info("latexindent called to act upon $fileName without a file extension;\nsearching for files in the following order (see fileExtensionPreference):");
$logger->info($fileName.join("\n$fileName",@fileExtensions));

my $fileFound = 0;
# loop through the known file extensions (see @fileExtensions)
Expand All @@ -70,13 +70,15 @@ sub file_extension_check{
$logger->fatal("I searched for $fileName$_");
}
$logger->fatal("but couldn't find any of them.\nConsider updating fileExtensionPreference.\nExiting, no indendation done.");
die "I couldn't find a match for $fileName in fileExtensionPreference.\nExiting, no indendation done.";
$self->output_logfile();
die "ERROR: I couldn't find any of the following files: ".$fileName.join(", $fileName",@fileExtensions)." (see fileExtensionPreference)\nExiting, no indendation done.";
}
} else {
# if the file has a recognised extension, check that the file exists
unless( -e $fileName ){
my $message = "I couldn't find $fileName, are you sure it exists?.\nNo indentation done.\nExiting.";
my $message = "ERROR: I couldn't find $fileName, are you sure it exists?\nNo indentation done.\nExiting.";
$logger->fatal("*$message");
$self->output_logfile();
die $message;
}
}
Expand Down
14 changes: 14 additions & 0 deletions LatexIndent/Logger.pm
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ sub warn{
print $logfileline,"\n" if $switches{screenlog};
}

sub fatal{
my $self = shift;
my $logfileline = shift;
if ($logfileline =~ m/^\*/s){
$logfileline =~ s/^\*/FATAL /s;
$logfileline =~ s/^/ /mg;
$logfileline =~ s/^\h+FATAL/FATAL/s;
} else {
$logfileline =~ s/^/ /mg;
}
push(@logFileLines,$logfileline);
print $logfileline,"\n" if $switches{screenlog};
}

sub trace{
my $self = shift;
my $logfileline = shift;
Expand Down
4 changes: 2 additions & 2 deletions LatexIndent/Version.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ use warnings;
use Exporter qw/import/;
our @EXPORT_OK = qw/$versionNumber $versionDate/;

our $versionNumber = '3.9.2';
our $versionDate = '2021-04-06';
our $versionNumber = '3.9.3';
our $versionDate = '2021-05-07';
1
2 changes: 1 addition & 1 deletion defaultSettings.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# defaultSettings.yaml for latexindent.pl, version 3.9.2, 2021-04-06
# defaultSettings.yaml for latexindent.pl, version 3.9.3, 2021-05-07
# a script that aims to
# beautify .tex, .sty, .cls files
#
Expand Down
3 changes: 3 additions & 0 deletions documentation/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# changelog.md

## V3.9.3, April 7, 2021
minor updates to log file creation https://github.com/cmhughes/latexindent.pl/issues/145

## V3.9.2, April 6, 2021
minor update to include noindent block bug fix for https://github.com/cmhughes/latexindent.pl/issues/266

Expand Down
4 changes: 2 additions & 2 deletions documentation/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
# built documents.
#
# The short X.Y version.
version = u'3.9.2'
version = u'3.9.3'
# The full version, including alpha/beta/rc tags.
release = u'3.9.2'
release = u'3.9.3'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
Loading