This package has been deprecated

Author message:

This package has been deprecated

@saekitominaga/htmlconvert-anchor-host
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Display the host name of the <a href> element in HTML right after the anchor.

npm version Build Status Coverage Status

Examples

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 {
}

Methods

static convert(html: string, options: Option): string

Option

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
}

Readme

Keywords

none

Package Sidebar

Install

npm i @saekitominaga/htmlconvert-anchor-host

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

32.8 kB

Total Files

9

Last publish

Collaborators

  • saekitominaga