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

Output context with "unmatched #/" message #1287

Merged
merged 2 commits into from
Dec 5, 2023
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
behavior
- Basic Fixup options are now persistent across different runs of Guiguts
- The Word Count and QuickSearch Count dialogs have clearer titles
- "Unmatched `#/`" message when rewrapping now includes two lines of
context to help user track down which blockquote is failing
- Included latest version of ebookmaker (0.12.36)
- Included latest version of Epubcheck (5.1.0)
- New TROUBLESHOOTING.md guide included with release
Expand Down
4 changes: 4 additions & 0 deletions src/guiguts.pl
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@
# Redirect warn by overriding signal handler
local $SIG{__WARN__} = \&::warnerror;

# Ensure stdout & stderr accept utf8 characters
binmode( STDOUT, ":utf8" );
binmode( STDERR, ":utf8" );

# An alternative for catching Tk background errors,
# but they are caught by the warn override above
# sub Tk::Error {
Expand Down
10 changes: 10 additions & 0 deletions src/lib/Guiguts/SelectionMenu.pm
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,16 @@ sub selectrewrap {
( $leftmargin, $firstmargin, $rightmargin ) = setblockmargins($::blockwrap);
} else {
::warnerror("Close blockquote (#/) found with no matching open markup");

# Last line in block is the closing markup, and output up to
# two more context lines before that
my @splitsel = split( /\n/, $notpmselection );
my $ncontext = scalar @splitsel;
$ncontext = 3 if $ncontext > 3;
::infoerror("Context:");
for my $ln ( 1 .. $ncontext ) {
::infoerror(" $splitsel[$ln-$ncontext-1]");
}
}
}
} else {
Expand Down
Loading