yoastseo
Version:
Yoast client-side content analysis
37 lines (35 loc) • 1.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _countWords = _interopRequireDefault(require("../helpers/word/countWords.js"));
var _htmlParser = _interopRequireDefault(require("../helpers/html/htmlParser"));
var _helpers = require("../helpers");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/**
* A result of the word count calculation.
*
* @typedef WordCountResult
* @property {string} text The text with all HTML blocks removed and shortcodes filtered out.
* @property {number} count The number of words found in the text.
* @property {string} unit The unit used in the text length calculations, always "word".
*/
/**
* Count the words in the text.
*
* @param {Paper} paper The Paper object.
*
* @returns {WordCountResult} The number of words found in the text, plus "word" as the unit used in calculating the text length.
*/
function _default(paper) {
let text = paper.getText();
text = (0, _htmlParser.default)(text);
text = (0, _helpers.filterShortcodesFromHTML)(text, paper._attributes && paper._attributes.shortcodes);
return {
text: text,
count: (0, _countWords.default)(text),
unit: "word"
};
}
//# sourceMappingURL=wordCountInText.js.map