Files
klammertext/mac/error.cpp
Andy Kopra 37b6ba1c4f Verbatim-safe typography, ^-punctuation quoting, full-range ^UUUU^, polyglot html
Typographic transforms (---, quote pairs, ~) no longer touch verbatim
text: @c/@code/@source_listing content and ^'...'^ spans show exactly the
characters written. "^" before any punctuation character quotes it in
every target (the apostrophe excepted: ^' opens a literal span), with the
new :resolve option on @@@target declaring per-target renderings. The
^UUUU^ code-point form accepts 4-6 hex digits, the full Unicode range.
The html output and transform spellings are polyglot (XML-valid), in
preparation for an EPUB target. New suites: transform_test, character_test
(engine), typography_test (SKS).

(from dev 07ce5ea86a0a)
2026-08-23 20:48:26 +02:00

39 lines
1.3 KiB
C++

#include "error.h"
#include "show.h"
#include "util.h"
#include "file.h"
bool display_source(const std::string& filename_arg)
{
if (filename_arg.empty()) {
return false;
} else {
fs::path filename = fs::path(filename_arg).filename();
return sks_commands.count(filename) == 0;
}
}
void Error::print_message(const std::string& epilog)
{
// The separator is not cosmetic: the description ends with a sentence, and
// appending the advice straight onto it ran the two together into one word
// ("...for an unspecified targetkdiag loads no klammerset..."). m_desc is
// then justified to 80 columns, so the break has to be a blank line rather
// than a single newline, which justify() would fold back into the flow.
if (epilog != "") {
m_desc += "\n\n" + epilog + "\n";
}
m_desc = justify(m_desc, 80, 0);
std::cerr << "\n" << red << command_name << " (" << m_type << " error)";
if (display_source(m_loc.m_filename)) {
std::cerr << ":\n " << m_loc.m_filename;
}
if (m_loc.m_line > -1) {
std::cerr << ", line " << m_loc.m_line;
}
if (m_loc.m_chr > -1) {
std::cerr << ", character " << m_loc.m_chr + 1;
}
std::cerr << ":\n\n" << m_desc << reset << "\n";
}