import HtmlConvertAnchorHost from '@saekitominaga/htmlconvert-anchor-host';
HtmlConvertAnchorHost.convert('<p><a href="https://example.com/" class="anchor-host">Example Domain</a></p>', { class: 'anchor-host' }); // <p><a href="https://example.com/">Example Domain</a><span>example.com</span></p>
HtmlConvertAnchorHost.convert('<p><a href="https://example.com/" class="anchor-host">Example Domain</a></p>', { class: 'anchor-host', host_element: 'b' }); // <p><a href="https://example.com/">Example Domain</a><b>example.com</b></p>
HtmlConvertAnchorHost.convert('<p><a href="https://example.com/" class="anchor-host">Example Domain</a></p>', { class: 'anchor-host', host_class: 'host' }); // <p><a href="https://example.com/">Example Domain</a><span class="host">example.com</span></p>
HtmlConvertAnchorHost.convert('<p><a href="https://example.com/" class="anchor-host">Example Domain</a></p>', { class: 'anchor-host', host_parentheses: ['(', ')'] }); // <p><a href="https://example.com/">Example Domain</a><span>(example.com)</span></p>
try {
HtmlConvertAnchorHost.convert('<p><a class="anchor-host">Example Domain</a></p>', { class: 'anchor-host' }); // Error: Elements without the `href` attribute are not processed
} catch {
}
try {
HtmlConvertAnchorHost.convert('<p><a href="foo" class="anchor-host">Example Domain</a></p>', { class: 'anchor-host' }); // Error: Relative paths are not processed
} catch {
}
interface Option {
class: string; // Class name of the element to be converted
host_element?: string; // Element name of host display part (Default is 'span')
host_class?: string; // Class name to be set in the element of the host display part
host_parentheses?: string[]; // Parentheses to be set before and after the host display part
}