UNPKG

legal-markdown-js

Version:

Node.js implementation of LegalMarkdown for processing legal documents with markdown and YAML - Complete feature parity with Ruby version

23 lines 845 B
function escapeAttr(s) { return s .replace(/&/g, '&amp;') .replace(/"/g, '&quot;') .replace(/'/g, '&#39;') .replace(/</g, '&lt;') .replace(/>/g, '&gt;'); } function escapeContent(s) { return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;'); } export function fieldSpan(fieldName, content, kind = 'imported') { const cls = kind === 'missing' ? 'legal-field missing-value' : kind === 'highlight' || kind === 'crossref' ? 'legal-field highlight' : 'legal-field imported-value'; return `<span class="${cls}" data-field="${escapeAttr(fieldName)}">${escapeContent(content)}</span>`; } export function missingFieldSpan(fieldName) { return fieldSpan(fieldName, `[[${fieldName}]]`, 'missing'); } //# sourceMappingURL=field-span.js.map