This commit is contained in:
Your Name
2026-10-09 09:36:17 +08:00
parent 88b94c2fc6
commit 51d8fd409e
727 changed files with 3753398 additions and 102 deletions
@@ -12,7 +12,6 @@ final class TcmAncientBooksReference
{
public const COMMIT = 'db0155dc7c42b9c6b3736896661f317c7110038f';
public const INDEX_VERSION = 3;
public const REPOSITORY_URL = 'https://github.com/xiaopangxia/TCM-Ancient-Books';
private const MARKER = '[TCM_ANCIENT_BOOKS:' . self::COMMIT . ']';
/** Modern terms are mapped to searchable historical headings/phrases. */
@@ -136,7 +135,7 @@ final class TcmAncientBooksReference
'path' => $path,
'line' => $line,
'commit' => self::COMMIT,
'url' => self::REPOSITORY_URL . '/blob/' . self::COMMIT . '/' . rawurlencode($path) . '#L' . $line,
'url' => '',
];
if (count($sources) >= $limit) {
break;
@@ -145,6 +144,20 @@ final class TcmAncientBooksReference
return $sources;
}
/** Keep saved citations and excerpts, but never expose an external source URL. */
public static function localizeSources(array $sources): array
{
$localized = [];
foreach ($sources as $source) {
if (!is_array($source)) {
continue;
}
$source['url'] = '';
$localized[] = $source;
}
return $localized;
}
public static function augmentQuery(string $query): string
{
if (str_contains($query, self::MARKER)) {
@@ -189,7 +202,7 @@ final class TcmAncientBooksReference
$lines[] = '《' . $source['title'] . '》' . ($source['chapter'] !== '' ? '「' . $source['chapter'] . '」' : '')
. ' 第' . $source['line'] . '行:' . mb_substr($source['excerpt'], 0, 80, 'UTF-8');
}
$lines[] = '只可引用上述原文;书名、篇章、行号及固定提交链接由系统保存并展示。保持原任务的 JSON 结构与来源编号。';
$lines[] = '只可引用上述原文;书名、篇章、文件名、行号及资料版本由系统保存并展示。保持原任务的 JSON 结构与来源编号。';
return implode("\n", $lines);
}