|
2 | 2 |
|
3 | 3 | # %% auto 0 |
4 | 4 | __all__= ['Placements','empty','find_var','call_endp','find_dname','find_msg_id','curr_dialog','find_msgs','msg_idx', |
5 | | -'read_msg','add_html','del_msg','run_msg','add_msg','update_msg','load_gist','gist_file', |
| 5 | +'read_msg','add_html','del_msg','run_msg','add_msg','update_msg','url2note','load_gist','gist_file', |
6 | 6 | 'import_string','is_usable_tool','mk_toollist','import_gist','tool_info','asdict'] |
7 | 7 |
|
8 | 8 | # %% ../nbs/00_core.ipynb |
@@ -191,6 +191,16 @@ def update_msg( |
191 | 191 | ifnotmsgidandnotmsg:raiseTypeError("update_msg needs either a dict message or `msgid=`") |
192 | 192 | returncall_endp('add_relative_',dname,placement='update',msgid=msgid,**kwargs) |
193 | 193 |
|
| 194 | +# %% ../nbs/00_core.ipynb |
| 195 | +defurl2note( |
| 196 | +url:str,# URL to read |
| 197 | +extract_section:bool=True,# If url has an anchor, return only that section |
| 198 | +selector:str=None# Select section(s) using BeautifulSoup.select (overrides extract_section) |
| 199 | +): |
| 200 | +"Read URL as markdown, and add a note below current message with the result" |
| 201 | +res=read_url(url,as_md=True,extract_section=extract_section,selector=selector) |
| 202 | +returnadd_msg(res) |
| 203 | + |
194 | 204 | # %% ../nbs/00_core.ipynb |
195 | 205 | defload_gist(gist_id:str): |
196 | 206 | "Retrieve a gist" |
@@ -270,5 +280,6 @@ def tool_info(): |
270 | 280 | - &`read_msg`: Get the message indexed in the current dialog. |
271 | 281 | - &`del_msg`: Delete a message from the dialog. |
272 | 282 | - &`add_msg`: Add/update a message to the queue to show after code execution completes. |
273 | | -- &`update_msg`: Update an existing message.''' |
| 283 | +- &`update_msg`: Update an existing message. |
| 284 | +- &`url2note`: Read URL as markdown, and add a note below current message with the result''' |
274 | 285 | add_msg(cts) |