seo-editor
Version:
Copywriting keyword to-do list automation
18 lines (16 loc) • 2.16 kB
JavaScript
/**
* @name seo-editor
* @fileoverview Copywriting keyword to-do list automation
* @version 2.0.8
* @author Roy Revelt, Codsen Ltd
* @license MIT
* {@link https://codsen.com/os/seo-editor/}
*/
var p="2.0.8";var f=p;function g(t){return typeof t=="string"&&t.length===1&&t.toUpperCase()!==t.toLowerCase()}function h(t,u){for(let l=t.length;l--&&t[l]?.counts?.length;)t[l].lengthCompensation=u-t[l].length;return t}var E=/[a-zA-Z0-9_'\u0392-\u03c9\u0400-\u04FF\u0027]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|[\u00E4\u00C4\u00E5\u00C5\u00F6\u00D6]+|[\u0531-\u0556\u0561-\u0586\u0559\u055A\u055B]+|\w+/g;function V(t){return t.split(/\r?\n/).filter(u=>!u.trim().startsWith("#")&&!u.trim().startsWith(">")).join(`
`).trim()}function x(t){return typeof t=="string"&&t.trim().startsWith("- ")}function N(t="",u=""){let l=Date.now(),n=u.split(/^[ \t]*---+/m).map(e=>V(e).toLowerCase()).filter(e=>e.trim()),s=[],r=0,a=0,b=n.length?n.map(()=>0):[0],m=t.toLowerCase().split(/\r?\n/);return t.trim()?(m.forEach((e,S)=>{if(x(e)){a++;let o=e.trim().slice(2).trim(),{length:L}=o;r=Math.max(r,o.length),s.push({extracted:o,length:L,counts:n.map((i,D)=>{if(!i.includes(o))return 0;let c=0,d=0;for(;i.includes(o,d);){let $=i.indexOf(o,d);!g(i[$-1])&&(!g(i[$+o.length])||i[$+o.length].toLowerCase()==="s"&&!g(i[$+o.length+1]))&&(c+=1),d+=$+o.length}return c&&(b[D]+=1),c}),lengthCompensation:r})}else s[~-s.length]?.counts.length&&(s=h(s,r)),s.push({extracted:"",counts:[],length:0,lengthCompensation:0}),r=0}),x(m[~-m.length])&&(s=h(s,r)),{todoLines:s,chunkWordCounts:n.map(e=>e.match(E)?.length||0),chunkLengths:n.map(e=>e.length),todoTotal:a,completion:b,log:{timeTakenInMilliseconds:Date.now()-l,version:f}}):{todoLines:[],chunkWordCounts:n.map(e=>e.match(E)?.length||0),chunkLengths:n.map(e=>e.length),todoTotal:0,completion:n.length?n.map(()=>0):[0],log:{timeTakenInMilliseconds:Date.now()-l,version:f}}}export{N as editor,g as isLetter,h as setLengthCompensation,f as version};
/*!
* word-regex <https://github.com/jonschlinkert/word-regex>
*
* Copyright (c) 2015 Jon Schlinkert.
* Licensed under the MIT license.
*/