# give/4.18.0/src/Promotions/InPluginUpsells/resources/js/utils.js

GiveWP – Donation Plugin and Fundraising Platform, version 4.18.0. 44 lines.

- Page: https://pluginprobe.com/plugins/give/4.18.0/code/src/Promotions/InPluginUpsells/resources/js/utils.js
- Raw: https://pluginprobe.com/plugins/give/4.18.0/raw/src/Promotions/InPluginUpsells/resources/js/utils.js
- Modified: 2022-06-17T00:03:36+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/give/4.18.0/code/src/Promotions/InPluginUpsells/resources/js/utils.js#L10-L20`.

```javascript
/**
 * Replaces double asterisks with `<strong>` tags.
 *
 * @param {string} text
 * @returns {string}
 */
export function transformStrong(text) {
    // Keep track of whether we're inside a <strong> tag.
    let startingTag = false;

    return text.replaceAll('**', () => {
        // Reverse the starting tag state to determine the current state.
        startingTag = !startingTag;
        // Return the appropriate tag.
        return startingTag ? '<strong>' : '</strong>';
    });
}

/**
 * Replaces double asterisks with `<em>` tags.
 *
 * @param {string} text
 * @returns {string}
 */
export function transformEmphasis(text) {
    // Keep track of whether we're inside an <em> tag.
    let startingTag = false;

    return text.replaceAll('**', () => {
        // Reverse the starting tag state to determine the current state.
        startingTag = !startingTag;
        // Return the appropriate tag.
        return startingTag ? '<em>' : '</em>';
    });
}

/**
 * Get an asset URL.
 *
 * @param {string} filename (without leading slash).
 * @returns {string} asset URL
 */
export const assetUrl = (filename) => `${window.GiveAddons.assetsUrl}${filename}`;

```
