UNPKG

@npmstuff/argdown-core

Version:

A pluggable parser for the Argdown argumentation syntax

32 lines 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SaysWhoPlugin = void 0; const ArgdownPluginError_1 = require("../ArgdownPluginError"); const model_1 = require("../model/model"); class SaysWhoPlugin { constructor() { this.name = "SaysWhoPlugin"; this.run = (_request, response) => { (0, ArgdownPluginError_1.checkResponseFields)(this, response, ["map", "arguments"]); for (let node of response.map.nodes) { processNodesRecursively(node, response); } }; } } exports.SaysWhoPlugin = SaysWhoPlugin; const processNodesRecursively = (node, response) => { if (node.type === model_1.ArgdownTypes.ARGUMENT_MAP_NODE) { const argument = response.arguments[node.title]; if (argument && argument.data && argument.data.proponent) { const proponent = argument.data.proponent; node.labelText = `${proponent}: ${node.labelText}`; } } else if ((0, model_1.isGroupMapNode)(node)) { for (let child of node.children) { processNodesRecursively(child, response); } } }; //# sourceMappingURL=SaysWhoPlugin.js.map