@pollinations/cli 0.1.50 → 0.1.51

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.js CHANGED
@@ -14,7 +14,7 @@ var init_package = __esm({
14
14
  "package.json"() {
15
15
  package_default = {
16
16
  name: "@pollinations/cli",
17
- version: "0.1.50",
17
+ version: "0.1.51",
18
18
  description: "The Pollinations CLI \u2014 for humans, AI agents, and everything in between",
19
19
  type: "module",
20
20
  bin: {
@@ -843,9 +843,20 @@ var docsCommand = new Command3("docs").description("Show Pollinations API docume
843
843
  sections[sections.length - 1] += line;
844
844
  }
845
845
  const needle = endpoint.replace(/^\//, "").toLowerCase();
846
- const headingMatches = sections.filter(
847
- (s) => /^#{1,6} /.test(s) && s.split("\n")[0].toLowerCase().includes(needle)
848
- );
846
+ const headingMatches = [];
847
+ let selectedLevel = 0;
848
+ for (const section of sections) {
849
+ const level = section.match(/^(#{1,6}) /)?.[1].length;
850
+ if (!level) continue;
851
+ if (selectedLevel && level > selectedLevel) {
852
+ headingMatches[headingMatches.length - 1] += section;
853
+ } else if (section.split("\n")[0].toLowerCase().includes(needle)) {
854
+ selectedLevel = level;
855
+ headingMatches.push(section);
856
+ } else {
857
+ selectedLevel = 0;
858
+ }
859
+ }
849
860
  const matches = headingMatches.length ? headingMatches : sections.filter(
850
861
  (s) => s.toLowerCase().includes(needle)
851
862
  );