mirror of
https://github.com/lossless-group/perplexed-plugin.git
synced 2026-07-22 06:49:50 +00:00
fix(sources-footer): emit [N] format so cite-wide can convert to hex citations
The previous footer used ordered-list style ("1. [Title](URL)"), which
cite-wide's LLM citation parser ignores. Cite-wide's REFDEF_NUM_RE expects
each line to start with [N] (square-bracketed digit), optionally followed by
a colon, then the link.
New format per source:
[1] [Title](URL)
[2] [Title](URL)
This matches cite-wide/src/services/llmCitationParserService.ts:91 verbatim,
so running cite-wide's "convert numeric citations to hex" command on a file
generated by this plugin now picks up the footer references and rewrites
them to the project's [^hexId] form.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f6fa7e2deb
commit
3575dc168f
1 changed files with 4 additions and 2 deletions
|
|
@ -63,12 +63,14 @@ function wrapThinkBlocks(text: string): string {
|
|||
|
||||
function buildSourcesFooter(sources: PerplexitySource[]): string {
|
||||
if (!sources.length) return '';
|
||||
// Format matches cite-wide's REFDEF_NUM_RE (`[N] <content>`) so the
|
||||
// existing "convert to hex citations" command can process this footer.
|
||||
// See cite-wide/src/services/llmCitationParserService.ts.
|
||||
const lines = sources.map((s, i) => {
|
||||
const n = i + 1;
|
||||
const title = (typeof s.title === 'string' && s.title) ? s.title : (s.url ?? 'Source');
|
||||
const url = s.url ?? '';
|
||||
const date = (typeof s.date === 'string' && s.date) ? ` (${s.date})` : '';
|
||||
return url ? `${n}. [${title}](${url})${date}` : `${n}. ${title}${date}`;
|
||||
return url ? `[${n.toString()}] [${title}](${url})` : `[${n.toString()}] ${title}`;
|
||||
});
|
||||
return '\n\n## Sources\n\n' + lines.join('\n') + '\n';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue