0 | module Cheerio.Traversing
  1 |
  2 | import Cheerio.Data
  3 | import Cheerio.Utils
  4 |
  5 | -- find
  6 |
  7 | %foreign "node:lambda: (selector, cheerio) => cheerio.find(selector)"
  8 | prim_find : String -> Cheerio -> PrimIO Cheerio
  9 |
 10 | export
 11 | find : HasIO io => String -> Cheerio -> io Cheerio
 12 | find selector cheerio = primIO $ prim_find selector cheerio
 13 |
 14 |
 15 | -- parents by selector
 16 | %foreign "node:lambda: (selector, cheerio) => cheerio.parent(selector)"
 17 | prim_parensBy : String -> Cheerio -> PrimIO Cheerio
 18 |
 19 | export
 20 | parentBy : HasIO io => String -> Cheerio -> io Cheerio
 21 | parentBy selector cheerio = primIO $ prim_parensBy selector cheerio
 22 |
 23 |
 24 | export
 25 | parent : HasIO io => Cheerio -> io Cheerio
 26 | parent = parentBy ""
 27 |
 28 | -- parents
 29 | %foreign "node:lambda: cheerio => cheerio.parents()"
 30 | prim_parents :  Cheerio -> PrimIO Cheerio
 31 |
 32 | -- parents by selector
 33 | %foreign "node:lambda: (selector, cheerio) => cheerio.parents(selector)"
 34 | prim_parenstBy : String -> Cheerio -> PrimIO Cheerio
 35 |
 36 | export
 37 | parentsBy : HasIO io => String -> Cheerio -> io Cheerio
 38 | parentsBy selector cheerio = primIO $ prim_parenstBy selector cheerio
 39 |
 40 | export
 41 | parents : HasIO io => Cheerio -> io Cheerio
 42 | parents = parentsBy ""
 43 |
 44 |
 45 | -- up to but not including the element matched by the selector,
 46 | %foreign "node:lambda: (selector, cheerio) => cheerio.parentsUntil(selector)"
 47 | prim_parentsUntil : String -> Cheerio -> PrimIO Cheerio
 48 |
 49 | export
 50 | parentsUntil : HasIO io => String -> Cheerio -> io Cheerio
 51 | parentsUntil selector cheerio = primIO $ prim_parentsUntil selector cheerio
 52 |
 53 |
 54 | -- closest by selector
 55 | %foreign "node:lambda: (selector, cheerio) => cheerio.closest(selector)"
 56 | prim_closestBy : String -> Cheerio -> PrimIO Cheerio
 57 |
 58 | export
 59 | closestBy : HasIO io => String -> Cheerio -> io Cheerio
 60 | closestBy selector cheerio = primIO $ prim_closestBy selector cheerio
 61 |
 62 | export
 63 | closest : HasIO io => Cheerio -> io Cheerio
 64 | closest = closestBy ""
 65 |
 66 |
 67 | -- nextBy by selector
 68 | %foreign "node:lambda: (selector, cheerio) => cheerio.next(selector)"
 69 | prim_nextBy : String -> Cheerio -> PrimIO Cheerio
 70 |
 71 | export
 72 | nextBy : HasIO io => String -> Cheerio -> io Cheerio
 73 | nextBy selector cheerio = primIO $ prim_nextBy selector cheerio
 74 |
 75 | export
 76 | next : HasIO io => Cheerio -> io Cheerio
 77 | next = nextBy ""
 78 |
 79 |
 80 | -- nextAll by selector
 81 | %foreign "node:lambda: (selector, cheerio) => cheerio.nextAll(selector)"
 82 | prim_nextAll : String -> Cheerio -> PrimIO Cheerio
 83 |
 84 | export
 85 | nextAllBy : HasIO io => String -> Cheerio -> io Cheerio
 86 | nextAllBy selector cheerio = primIO $ prim_nextAll selector cheerio
 87 |
 88 | export
 89 | nextAll : HasIO io => Cheerio -> io Cheerio
 90 | nextAll = nextBy ""
 91 |
 92 |
 93 |
 94 | -- up to but not including the element matched by the selector,
 95 | %foreign "node:lambda: (selector, cheerio) => cheerio.nextUntil(selector)"
 96 | prim_nextUntil : String -> Cheerio -> PrimIO Cheerio
 97 |
 98 | export
 99 | nextUntil : HasIO io => String -> Cheerio -> io Cheerio
100 | nextUntil selector cheerio = primIO $ prim_nextUntil selector cheerio
101 |
102 |
103 |
104 | -- prevBy by selector
105 | %foreign "node:lambda: (selector, cheerio) => cheerio.prev(selector)"
106 | prim_prevBy : String -> Cheerio -> PrimIO Cheerio
107 |
108 | export
109 | prevBy : HasIO io => String -> Cheerio -> io Cheerio
110 | prevBy selector cheerio = primIO $ prim_prevBy selector cheerio
111 |
112 | export
113 | prev : HasIO io => Cheerio -> io Cheerio
114 | prev = prevBy ""
115 |
116 |
117 | -- prevAll by selector
118 | %foreign "node:lambda: (selector, cheerio) => cheerio.prevAll(selector)"
119 | prim_prevAll : String -> Cheerio -> PrimIO Cheerio
120 |
121 | export
122 | prevAllBy : HasIO io => String -> Cheerio -> io Cheerio
123 | prevAllBy selector cheerio = primIO $ prim_prevAll selector cheerio
124 |
125 | export
126 | prevAll : HasIO io => Cheerio -> io Cheerio
127 | prevAll = prevBy ""
128 |
129 |
130 | -- up to but not including the element matched by the selector,
131 | %foreign "node:lambda: (selector, cheerio) => cheerio.prevUntil(selector)"
132 | prim_prevUntil : String -> Cheerio -> PrimIO Cheerio
133 |
134 | export
135 | prevUntil : HasIO io => String -> Cheerio -> io Cheerio
136 | prevUntil selector cheerio = primIO $ prim_prevUntil selector cheerio
137 |
138 |
139 |
140 | -- siblings by selector
141 | %foreign "node:lambda: (selector, cheerio) => cheerio.siblings(selector)"
142 | prim_siblingsBy : String -> Cheerio -> PrimIO Cheerio
143 |
144 | export
145 | siblingsBy : HasIO io => String -> Cheerio -> io Cheerio
146 | siblingsBy selector cheerio = primIO $ prim_siblingsBy selector cheerio
147 |
148 | export
149 | siblings : HasIO io => Cheerio -> io Cheerio
150 | siblings = siblingsBy ""
151 |
152 |
153 |
154 | -- children by selector
155 | %foreign "node:lambda: (selector, cheerio) => cheerio.children(selector)"
156 | prim_childrenBy : String -> Cheerio -> PrimIO Cheerio
157 |
158 | export
159 | childrenBy : HasIO io => String -> Cheerio -> io Cheerio
160 | childrenBy selector cheerio = primIO $ prim_childrenBy selector cheerio
161 |
162 | export
163 | children : HasIO io => Cheerio -> io Cheerio
164 | children = childrenBy ""
165 |
166 | -- Gets the children of each element in the set of matched elements, including text and comment nodes.
167 | %foreign "node:lambda: (cheerio) => cheerio.contents()"
168 | prim_contents : Cheerio -> PrimIO Cheerio
169 |
170 | export
171 | contents : HasIO io =>Cheerio -> io Cheerio
172 | contents cheerio = primIO $ prim_contents cheerio
173 |
174 | -- first
175 | %foreign "node:lambda: (cheerio) => cheerio.first()"
176 | prim_first : Cheerio -> PrimIO Cheerio
177 |
178 | export
179 | first : HasIO io =>Cheerio -> io Cheerio
180 | first cheerio = primIO $ prim_first cheerio
181 |
182 |
183 | -- last
184 | %foreign "node:lambda: (cheerio) => cheerio.last()"
185 | prim_last : Cheerio -> PrimIO Cheerio
186 |
187 | export
188 | last : HasIO io =>Cheerio -> io Cheerio
189 | last cheerio = primIO $ prim_last cheerio
190 |
191 |
192 | -- end
193 | %foreign "node:lambda: (cheerio) => cheerio.end()"
194 | prim_end : Cheerio -> PrimIO Cheerio
195 |
196 | export
197 | end : HasIO io =>Cheerio -> io Cheerio
198 | end cheerio = primIO $ prim_end cheerio
199 |
200 |
201 | -- is
202 | %foreign "node:lambda: (selector, cheerio) => cheerio.is(selector)"
203 | prim_is : String -> Cheerio -> PrimIO Bool
204 |
205 | export
206 | is : HasIO io =>  String -> Cheerio -> io Bool
207 | is selector cheerio = primIO $ prim_is selector cheerio
208 |
209 | -- is
210 | %foreign "node:lambda: (idx, cheerio) => cheerio.is(idx)"
211 | prim_eq : Int32 -> Cheerio -> PrimIO Cheerio
212 |
213 | export
214 | eq : HasIO io =>  Int -> Cheerio -> io Cheerio
215 | eq idx cheerio = primIO $ prim_eq (cast idx) cheerio
216 |
217 |
218 | -- end
219 | %foreign "node:lambda: (toList, cheerio) => toList(cheerio.toArray())"
220 | prim_toArray : (AnyPtr -> Ptr (List AnyNode)) -> Cheerio -> PrimIO (List AnyNode)
221 |
222 | export
223 | toArray : HasIO io =>Cheerio -> io (List AnyNode) 
224 | toArray cheerio = primIO $ prim_toArray arrayToList cheerio