@ansvar/singapore-law-mcp
Version:
Complete Singapore law database — 523 Acts, 28K+ provisions from Singapore Statutes Online (sso.agc.gov.sg) with full-text search, definitions, and citation support
31 lines • 1.19 kB
JavaScript
/**
* format_citation — Format a Singapore legal citation per standard conventions.
*
* Singapore uses common law citation style:
* - "Section N [Act Title Year]" (formal)
* - "s N [Act Title]" (short)
*/
export async function formatCitationTool(input) {
const format = input.format ?? 'full';
const trimmed = input.citation.trim();
// Parse "Section N <act>" or "s N <act>" or "<act> s N"
const secFirst = trimmed.match(/^(?:Section|s\.?)\s*(\d+[A-Za-z]*)\s+(.+)$/i);
const secLast = trimmed.match(/^(.+?)[,;]?\s*(?:Section|s\.?)\s*(\d+[A-Za-z]*)$/i);
const section = secFirst?.[1] ?? secLast?.[2];
const act = secFirst?.[2] ?? secLast?.[1] ?? trimmed;
let formatted;
switch (format) {
case 'short':
formatted = section ? `s ${section} ${act.split('(')[0].trim()}` : act;
break;
case 'pinpoint':
formatted = section ? `s ${section}` : act;
break;
case 'full':
default:
formatted = section ? `Section ${section} ${act}` : act;
break;
}
return { original: input.citation, formatted, format };
}
//# sourceMappingURL=format-citation.js.map