3 var entities = require('parse-entities');
5 module.exports = factory;
7 /* Factory to create an entity decoder. */
8 function factory(ctx) {
9 decoder.raw = decodeRaw;
13 /* Normalize `position` to add an `indent`. */
14 function normalize(position) {
15 var offsets = ctx.offset;
16 var line = position.line;
20 if (!(line in offsets)) {
24 result.push((offsets[line] || 0) + 1);
34 * See https://github.com/wooorm/parse-entities
35 * for the warnings. */
36 function handleWarning(reason, position, code) {
41 ctx.file.message(reason, position);
44 /* Decode `value` (at `position`) into text-nodes. */
45 function decoder(value, position, handler) {
47 position: normalize(position),
48 warning: handleWarning,
56 /* Decode `value` (at `position`) into a string. */
57 function decodeRaw(value, position) {
58 return entities(value, {
59 position: normalize(position),
60 warning: handleWarning