seemore 1.12.14 → 1.12.16

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/cli/index.js CHANGED
@@ -1641,7 +1641,9 @@ function createRemarkPlugins(options) {
1641
1641
  // frontmatter strip is the one thing that must come first — its keys are metadata, not
1642
1642
  // content. Heading ids stay off: `## Title [#title]` is noise in a paste.
1643
1643
  remarkSeemoreMarkdownSource,
1644
- [remarkLLMs, { as: MARKDOWN_EXPORT, headingIds: false }],
1644
+ function() {
1645
+ return remarkSeemoreLLMs.call(this, options);
1646
+ },
1645
1647
  remarkHeading,
1646
1648
  remarkAdmonition,
1647
1649
  remarkDirectiveAdmonition,
@@ -1668,6 +1670,27 @@ function createRemarkPlugins(options) {
1668
1670
  () => remarkSeemoreLinks(options)
1669
1671
  ];
1670
1672
  }
1673
+ function remarkSeemoreLLMs(options) {
1674
+ const snapshot = remarkLLMs.call(this, { as: MARKDOWN_EXPORT, headingIds: false });
1675
+ return (tree, file) => {
1676
+ try {
1677
+ snapshot(tree, file);
1678
+ } catch (error) {
1679
+ options.onWarning(
1680
+ `Could not convert ${file.path} back to Markdown for copying (${error.message}); the raw file is copied instead.`
1681
+ );
1682
+ const fallback = { type: "root", children: [{ type: "html", value: sourceOf(tree, file) }] };
1683
+ snapshot(fallback, file);
1684
+ tree.children.unshift(...fallback.children.slice(0, -1));
1685
+ }
1686
+ };
1687
+ }
1688
+ function sourceOf(tree, file) {
1689
+ const source = String(file.value);
1690
+ const yaml = tree.children[0]?.type === "yaml" ? tree.children[0] : void 0;
1691
+ const end = yaml?.position?.end.offset;
1692
+ return end === void 0 ? source : source.slice(end).trimStart();
1693
+ }
1671
1694
  function createRehypePlugins(options) {
1672
1695
  return [
1673
1696
  // A fence in a language Shiki has no grammar for (anything an AI dreamt up) is plain code