MCPcopy Create free account
hub / github.com/TruthHun/BookStack / parseEntity

Function parseEntity

static/word2md/mammoth.browser.js:26852–26883  ·  view source on GitHub ↗
(parser)

Source from the content-addressed store, hash-verified

26850 }
26851
26852 function parseEntity (parser) {
26853 var entity = parser.entity
26854 var entityLC = entity.toLowerCase()
26855 var num
26856 var numStr = ''
26857
26858 if (parser.ENTITIES[entity]) {
26859 return parser.ENTITIES[entity]
26860 }
26861 if (parser.ENTITIES[entityLC]) {
26862 return parser.ENTITIES[entityLC]
26863 }
26864 entity = entityLC
26865 if (entity.charAt(0) === '#') {
26866 if (entity.charAt(1) === 'x') {
26867 entity = entity.slice(2)
26868 num = parseInt(entity, 16)
26869 numStr = num.toString(16)
26870 } else {
26871 entity = entity.slice(1)
26872 num = parseInt(entity, 10)
26873 numStr = num.toString(10)
26874 }
26875 }
26876 entity = entity.replace(/^0+/, '')
26877 if (numStr.toLowerCase() !== entity) {
26878 strictFail(parser, 'Invalid character entity')
26879 return '&' + parser.entity + ';'
26880 }
26881
26882 return String.fromCodePoint(num)
26883 }
26884
26885 function beginWhiteSpace (parser, c) {
26886 if (c === '<') {

Callers 1

writeFunction · 0.70

Calls 1

strictFailFunction · 0.70

Tested by

no test coverage detected