@deadair/plugin-sdk 0.54.0 → 0.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,9 +20,12 @@ import type { HostFetchInit, PluginHost } from './plugin.host.js';
20
20
  * host can check a claim against the text it came from, and prose that has been
21
21
  * through a plugin's own paraphrase is prose nothing can check.
22
22
  *
23
- * The one thing removed that is not furniture is a paragraph announcing itself as an advertisement
24
- * — see {@link SPONSOR_OPENERS}. It is still a cut rather than a rewrite: what is left is the
25
- * publisher's own prose, and what went is prose the publisher was paid for.
23
+ * Three things removed are not furniture: a paragraph announcing itself as an advertisement (see
24
+ * {@link SPONSOR_OPENERS}), a paragraph in which the writer pitches their own book or newsletter
25
+ * (see {@link SELF_PROMOTION}), and a paragraph set entirely in italics (see
26
+ * {@link setEntirelyInEmphasis}), which is the publisher's note about the story rather than the
27
+ * story. All three are still cuts rather than rewrites: what is left is the publisher's own prose,
28
+ * and what went is prose the publisher was paid for or wrote about itself.
26
29
  *
27
30
  * ## Wrong in one direction on purpose
28
31
  *
@@ -1 +1 @@
1
- {"version":3,"file":"article.parse.d.ts","sourceRoot":"","sources":["../src/article.parse.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,OAAQ,CAAC;AAwIvC;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,MAA0B,GAAG,MAAM,GAAG,SAAS,CAgCrG;AA2BD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,YAAY,CAC9B,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,aAAa,EACpB,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAChC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CA0B7B"}
1
+ {"version":3,"file":"article.parse.d.ts","sourceRoot":"","sources":["../src/article.parse.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,OAAQ,CAAC;AA8LvC;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,MAA0B,GAAG,MAAM,GAAG,SAAS,CAgCrG;AA2BD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,YAAY,CAC9B,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,aAAa,EACpB,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAChC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CA0B7B"}
package/dist/index.js CHANGED
@@ -578,13 +578,15 @@ var SPONSOR_OPENERS = [
578
578
  "paid partnership",
579
579
  "presented by",
580
580
  "promoted by",
581
+ "read more:",
581
582
  "sponsored",
582
583
  "sponsored by",
583
584
  "sponsored content",
584
585
  "sponsored survey",
585
586
  "support for this",
586
587
  "support comes from",
587
- "this post is sponsored"
588
+ "this post is sponsored",
589
+ "your support helps"
588
590
  ];
589
591
  function opensWithASponsor(text2) {
590
592
  const said = text2.toLowerCase();
@@ -595,6 +597,13 @@ function opensWithASponsor(text2) {
595
597
  });
596
598
  }
597
599
  __name(opensWithASponsor, "opensWithASponsor");
600
+ var SELF_PROMOTION = /\b(?:check out my (?:book|newsletter|podcast)|for more of my work|sign up for (?:my|our) newsletter|subscribe to (?:my|our))\b/i;
601
+ function setEntirelyInEmphasis(markup) {
602
+ if (!/<(em|i)\b/i.test(markup)) return false;
603
+ const outside = markup.replace(/<(em|i)\b[^>]*>[\s\S]*?<\/\1>/gi, "").replace(/<[^>]*>/g, "").replace(/&nbsp;|&#160;/gi, "").replace(/[\s\p{P}]/gu, "");
604
+ return outside.length === 0;
605
+ }
606
+ __name(setEntirelyInEmphasis, "setEntirelyInEmphasis");
598
607
  var CONTAINERS = [
599
608
  /<article\b[^>]*>([\s\S]*?)<\/article>/i,
600
609
  /<main\b[^>]*>([\s\S]*?)<\/main>/i
@@ -607,7 +616,7 @@ function extractArticle(html, maxChars = ARTICLE_MAX_CHARS) {
607
616
  for (const match of body.matchAll(PARAGRAPH)) {
608
617
  const text2 = withoutApparatus(plainText(match[1] ?? ""));
609
618
  if (text2 === void 0 || text2.length < MIN_PARAGRAPH_CHARS) continue;
610
- if (opensWithASponsor(text2)) continue;
619
+ if (opensWithASponsor(text2) || SELF_PROMOTION.test(text2) || setEntirelyInEmphasis(match[1] ?? "")) continue;
611
620
  if (!paragraphs.includes(text2)) paragraphs.push(text2);
612
621
  }
613
622
  if (paragraphs.length === 0) return void 0;