@llm-newsletter-kit/core 1.1.3 → 1.1.4

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.
package/dist/index.cjs CHANGED
@@ -843,7 +843,8 @@ function markdownToHtml(markdown) {
843
843
  const window = new jsdom.JSDOM('').window;
844
844
  const purify = DOMPurify(window);
845
845
  const sanitized = purify.sanitize(html);
846
- const withTargetBlank = addTargetBlankToAnchors(sanitized);
846
+ const withCorrectedUrls = correctMalformedUrls(sanitized);
847
+ const withTargetBlank = addTargetBlankToAnchors(withCorrectedUrls);
847
848
  const withDelReplaced = replaceDelTagsWithTilde(withTargetBlank);
848
849
  return correctUnconvertedBoldSyntax(withDelReplaced);
849
850
  }
@@ -875,6 +876,22 @@ function correctUnconvertedBoldSyntax(htmlString) {
875
876
  // Matches "**" followed by one or more non-asterisk characters, followed by "**"
876
877
  return htmlString.replace(/\*\*([^*]+)\*\*/g, '<b>$1</b>');
877
878
  }
879
+ function correctMalformedUrls(htmlString) {
880
+ // Pattern matches anchors with `)` followed by URL-encoded characters
881
+ // Capture groups:
882
+ // 1: attributes before href
883
+ // 2: URL base (before `)`)
884
+ // 3: URL-encoded part (starts with %)
885
+ // 4: attributes after href
886
+ // 5: link text base (before `)`)
887
+ // 6: decoded text after `)` in link text
888
+ const regex = /<a\s+([^>]*?)href="([^"]*?)\)(%[0-9A-Fa-f]{2}[^"]*?)"([^>]*?)>([^<]*?)\)([^<]*?)<\/a>/g;
889
+ return htmlString.replace(regex, (_match, beforeHref, urlBase, _encodedPart, afterHref, textBase, decodedTextInLink) => {
890
+ // The decoded text is already in the link text (decodedTextInLink)
891
+ // We just need to move it outside the anchor along with the `)`
892
+ return `<a ${beforeHref}href="${urlBase}"${afterHref}>${textBase}</a>)${decodedTextInLink}`;
893
+ });
894
+ }
878
895
 
879
896
  let GenerateNewsletter$1 = class GenerateNewsletter extends BaseLLMQuery {
880
897
  maxOutputTokens;
@@ -1 +1 @@
1
- {"version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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.js CHANGED
@@ -841,7 +841,8 @@ function markdownToHtml(markdown) {
841
841
  const window = new JSDOM('').window;
842
842
  const purify = DOMPurify(window);
843
843
  const sanitized = purify.sanitize(html);
844
- const withTargetBlank = addTargetBlankToAnchors(sanitized);
844
+ const withCorrectedUrls = correctMalformedUrls(sanitized);
845
+ const withTargetBlank = addTargetBlankToAnchors(withCorrectedUrls);
845
846
  const withDelReplaced = replaceDelTagsWithTilde(withTargetBlank);
846
847
  return correctUnconvertedBoldSyntax(withDelReplaced);
847
848
  }
@@ -873,6 +874,22 @@ function correctUnconvertedBoldSyntax(htmlString) {
873
874
  // Matches "**" followed by one or more non-asterisk characters, followed by "**"
874
875
  return htmlString.replace(/\*\*([^*]+)\*\*/g, '<b>$1</b>');
875
876
  }
877
+ function correctMalformedUrls(htmlString) {
878
+ // Pattern matches anchors with `)` followed by URL-encoded characters
879
+ // Capture groups:
880
+ // 1: attributes before href
881
+ // 2: URL base (before `)`)
882
+ // 3: URL-encoded part (starts with %)
883
+ // 4: attributes after href
884
+ // 5: link text base (before `)`)
885
+ // 6: decoded text after `)` in link text
886
+ const regex = /<a\s+([^>]*?)href="([^"]*?)\)(%[0-9A-Fa-f]{2}[^"]*?)"([^>]*?)>([^<]*?)\)([^<]*?)<\/a>/g;
887
+ return htmlString.replace(regex, (_match, beforeHref, urlBase, _encodedPart, afterHref, textBase, decodedTextInLink) => {
888
+ // The decoded text is already in the link text (decodedTextInLink)
889
+ // We just need to move it outside the anchor along with the `)`
890
+ return `<a ${beforeHref}href="${urlBase}"${afterHref}>${textBase}</a>)${decodedTextInLink}`;
891
+ });
892
+ }
876
893
 
877
894
  let GenerateNewsletter$1 = class GenerateNewsletter extends BaseLLMQuery {
878
895
  maxOutputTokens;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@llm-newsletter-kit/core",
3
3
  "private": false,
4
4
  "type": "module",
5
- "version": "1.1.3",
5
+ "version": "1.1.4",
6
6
  "description": "An extensible framework to automate your entire newsletter workflow. Handles data collection, LLM-based content analysis, and email generation, letting you focus on your unique domain logic.",
7
7
  "main": "dist/index.cjs",
8
8
  "module": "dist/index.js",