|
96 | 96 | (from-range (nth node 1) content)
|
97 | 97 | (seq node)))
|
98 | 98 |
|
| 99 | +(defn section-content [content node] |
| 100 | + (from-range (nth node 1) content)) |
| 101 | + |
99 | 102 | (defn h1-prompt-content [content node]
|
100 | 103 | (merge
|
101 | 104 | (-> node (nth 2) (nth 3) (nth 1) (from-range content) (parse-h1))
|
102 |
| - ;; TODO merge a description and filter node content |
103 | 105 | (if (some section? node)
|
| 106 | + ;; prompt is broken up with real sections |
104 | 107 | (merge
|
105 | 108 | {:content (->> node
|
106 |
| - (filter section?) |
| 109 | + (filter list?) |
107 | 110 | (filter (complement (partial description-section? content)))
|
108 | 111 | #_(filter (complement atx-heading-section?))
|
109 |
| - (map (partial section-content-without-headings content)) |
| 112 | + (map (partial section-content content)) |
110 | 113 | (apply str)
|
111 | 114 | (string/trim))}
|
112 |
| - (when-let [description (->> node |
113 |
| - (filter section?) |
114 |
| - (filter (partial description-section? content)) |
115 |
| - first |
116 |
| - (section-content-without-headings content) |
117 |
| - (string/trim))] |
| 115 | + (when-let [description (some->> node |
| 116 | + (filter section?) |
| 117 | + (filter (partial description-section? content)) |
| 118 | + first |
| 119 | + (section-content-without-headings content) |
| 120 | + (string/trim))] |
118 | 121 | {:description description}))
|
| 122 | + ;; the contene is just one big section with no description |
119 | 123 | {:content (string/trim (section-content-without-headings content node))})))
|
120 | 124 |
|
121 | 125 | (def heading-1-loc->top-level-section-node (comp zip/node zip/up zip/up))
|
|
196 | 200 | (some (fn [loc] (when (section? (zip/node loc)) loc))))]
|
197 | 201 | (when-let [first-code-block
|
198 | 202 | (->>
|
199 |
| - (iterate zip/right (zip/down first-section)) |
200 |
| - (some (fn [loc] (when (fenced-code-block? (zip/node loc)) loc))))] |
| 203 | + (iterate zip/right (zip/down first-section)) |
| 204 | + (some (fn [loc] (when (fenced-code-block? (zip/node loc)) loc))))] |
201 | 205 | first-code-block))]
|
202 | 206 | (->
|
203 | 207 | (from-range (-> loc zip/node (nth 5) (nth 1)) content)
|
|
0 commit comments