Document language for dates; @eval pathname resolution and :cwd (from dev bc7cd62b6f68)

@date/@datetime gain :lang (German: "16. Juni 1910") over a document-wide
Language state variable, and :number for the numeric form (en 6/16/1910,
de 16.06.1910 per DIN 5008).  @eval finds Python modules next to the file
that names them regardless of the cwd, and the new :cwd option runs an
eval in a chosen working directory (@source_file uses it to resolve
against the document).  Two new test suites ship in tst/.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-27 20:25:49 +02:00
parent f84603ee19
commit 61b21d1397
12 changed files with 309 additions and 15 deletions

View File

@@ -259,6 +259,16 @@ std::vector<std::string> State::all_names()
}
void State::add_search_dir(const std::string& dir)
{
if (!dir.empty()
&& std::find(m_search_dirs.begin(), m_search_dirs.end(), dir)
== m_search_dirs.end()) {
m_search_dirs.push_back(dir);
}
}
std::string State::python_code()
{
(void)K::log(3);
@@ -267,7 +277,12 @@ std::string State::python_code()
std::stringstream ss {};
ss << "import sys\n";
for (auto d : sks_dirs()) {
strings_t python_dirs = sks_dirs();
// The directories of the files this Machine has read: a module next to
// the file whose @eval names it is found regardless of the cwd.
python_dirs.insert(python_dirs.end(),
m_search_dirs.begin(), m_search_dirs.end());
for (auto d : python_dirs) {
auto python_files = pathnames_with_extension(d, "py");
if (!python_files.empty()) {
ss << "sys.path.append('" << d << "')\n";