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
JavaScript
function escapeAttr(s) {
return s
.replace(/&/g, '&')
.replace(/"/g, '"')
.replace(/'/g, ''')
.replace(/</g, '<')
.replace(/>/g, '>');
}
function escapeContent(s) {
return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
}
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