How to use the decode function from html-entities

Find comprehensive JavaScript html-entities.decode code examples handpicked from public code repositorys.

html-entities.decode is a function that decodes HTML entities in a string and returns the decoded string.

1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
_unescapeHtmlEntities: function (str) {
  if (!str) {
    return str;
  }

  return htmlEntities.decode(str);
},

/**
 * Finds entity inside of the JSONLD graphs and returns value from the specified field
fork icon43
star icon0
watch icon8

+ 3 other calls in file

18
19
20
21
22
23
24
25
26
27
    if(process.env[configKey]){
        config[configKey] = process.env[configKey];
    }
});

config.customCss = typeof config.customCss !== 'undefined' ? escape.decode(config.customCss) : null;
config.footerHtml = typeof config.footerHtml !== 'undefined' ? escape.decode(config.footerHtml) : null;
config.googleAnalytics = typeof config.googleAnalytics !== 'undefined' ? escape.decode(config.googleAnalytics) : null;

// setup theme
fork icon1
star icon4
watch icon1

+ 5 other calls in file

How does html-entities.decode work?

html-entities.decode is a function provided by the html-entities library that takes a string as input and decodes any HTML entities in the string, such as & for &, The function scans the input string for occurrences of these entities, and replaces them with their corresponding characters. The resulting decoded string is then returned by the function. For example, if the input string was "I like & love < JavaScript!", the html-entities.decode function would return "I like & love < JavaScript!" after decoding the [[[& and [[[

229
230
231
232
233
234
235
236
237
238
        themes: getThemes(),
        message: clearSessionValue(req.session, 'message'),
        messageType: clearSessionValue(req.session, 'messageType'),
        helpers: req.handlebars.helpers,
        config: req.app.config,
        footerHtml: typeof req.app.config.footerHtml !== 'undefined' ? escape.decode(req.app.config.footerHtml) : null,
        googleAnalytics: typeof req.app.config.googleAnalytics !== 'undefined' ? escape.decode(req.app.config.googleAnalytics) : null,
        csrfToken: req.csrfToken()
    });
});
fork icon1
star icon4
watch icon1

+ 3 other calls in file

2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
coi: coins,
login: login,
domain: dbinfo.domain,
userdata: result,
email: entities.decode(decrypt(result.email)),
address: entities.decode(decrypt(result.address.street)),
postnumber: entities.decode(decrypt(result.address.postnumber)),
city: entities.decode(decrypt(result.address.city)),
country: entities.decode(decrypt(result.address.country)).toUpperCase(),
user_firstname: entities.decode(result.fullname.firstname),
fork icon0
star icon0
watch icon1

+ 62 other calls in file

Ai Example

1
2
3
4
5
6
7
const Entities = require("html-entities").AllHtmlEntities;
const entities = new Entities();

const encodedString = "This is an & example with HTML entities.";
const decodedString = entities.decode(encodedString);

console.log(decodedString); // This is an & example with HTML entities.

In this example, we first import the AllHtmlEntities class from the html-entities library and create an instance of it. We then create an example string with HTML entities, and pass it to the decode method of our entities instance. Finally, we log the decoded string to the console, which would output: This is an & example with HTML entities..

191
192
193
194
195
196
197
198
199
200
    if (array.manifests[i].manifestId === parseInt(id)) {
        item = array.manifests[i];
    }
}
if (item !== null) {
    item.manifest = entities.decode(item.manifest);
    return Promise.resolve(item);
} else {
    return Promise.reject('Cannot found manifest with this manifestId : ' + id);
}
fork icon0
star icon0
watch icon1

+ 9 other calls in file

171
172
173
174
175
176
177
178
179
180
    });
  });
}
else if (['select', 'resource'].includes(component.type)) {
  // Prepare the Lodash template by deleting tags and html entities
  const clearTemplate = Entities.decode(component.template.replace(/<\/?[^>]+(>|$)/g, ''));
  const templateExtractor = (item) => interpolate(clearTemplate, {item});

  const valuesExtractor = (value) => {
    // Check if this is within a datagrid.
fork icon0
star icon0
watch icon1

+ 9 other calls in file