Utility functions used by the convert.
- Source:
Methods
(static) collapseHeaders(content, headers, open) → {string}
Wraps specified header levels and their content in collapsible details elements.
Processes headers from highest level (h2) to lowest (h6) to maintain hierarchy.
A header's content includes all content until the next header of equal or higher significance.
Parameters:
| Name | Type | Description |
|---|---|---|
content |
string | The HTML content containing headers to be collapsed. |
headers |
string | Comma-separated list of header levels to collapse (e.g., "h2,h3"). |
open |
boolean | Determines if the details should be open by default. |
- Source:
Returns:
The HTML content with specified headers wrapped in details elements.
- Type
- string
(static) convertNotes(str, startCount) → {Object}
Converts special note syntax in a string to HTML elements for displaying notes.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
str |
string | The string containing note syntax to be converted. |
|
startCount |
number | 0 | The starting count for footnotes. |
- Source:
Returns:
Object with content and updated count.
- Type
- Object
(static) makeDetails(content, open) → {string}
Creates an HTML details element with the given content. Called by processOutput and processSource.
Parameters:
| Name | Type | Description |
|---|---|---|
content |
string | The HTML content to be placed inside the details tag. |
open |
boolean | Determines if the details should be open by default. |
- Source:
Returns:
An HTML string representing a details element.
- Type
- string
(static) replaceAndLog(text, input, output) → {string}
Replaces occurrences of a pattern in a string and optionally logs the replacement.
Parameters:
| Name | Type | Description |
|---|---|---|
text |
string | The text in which replacements are to be made. |
input |
RegExp | string | The pattern to search for in the text. |
output |
function | string | The replacement text or a function that returns the replacement text. |
- Source:
Returns:
The text after performing the replacements.
- Type
- string
(static) replaceEmojis(text) → {string}
Replaces specified emoji characters in the text with their corresponding HTML entities. Convert emojis to html entities
Parameters:
| Name | Type | Description |
|---|---|---|
text |
string | The text containing emojis to be replaced. |
- Source:
Returns:
The text with emojis replaced by HTML entities.
- Type
- string