urltomarkdown/readme.md

98 lines
2.9 KiB
Markdown
Raw Normal View History

2022-01-09 22:25:11 +00:00
# Convert a webpage to markdown
Provides a web service that downloads a requested web page and outputs a markdown version.
2022-01-30 20:50:42 +00:00
Example request, supply url:
2022-01-09 22:25:11 +00:00
2022-01-10 09:36:59 +00:00
GET https://urltomarkdown.herokuapp.com/?url=https%3A%2F%2Fwww.mozilla.org%2Fen-GB%2Ffirefox%2F
2022-01-09 22:25:11 +00:00
2022-01-10 09:36:59 +00:00
Response:
2022-01-09 22:25:11 +00:00
2022-02-04 12:44:49 +00:00
```
Meet our family of products
---------------------------
* [![](https://www.mozilla.org/media/protocol/img/logos/firefox/browser/logo.eb1324e44442.svg)
2022-01-09 22:25:11 +00:00
...
2022-02-04 12:44:49 +00:00
[Join Firefox](https://accounts.firefox.com/signup?entrypoint=mozilla.org-firefox_home&form_type=button&utm_source=mozilla.org-firefox_home&utm_medium=referral&utm_campaign=firefox-home&utm_content=secondary-join-firefox) [Learn more about joining Firefox](https://www.mozilla.org/en-GB/firefox/accounts/)
```
Optionally request inline title:
GET https://urltomarkdown.herokuapp.com/?url=https%3A%2F%2Fwww.mozilla.org%2Fen-GB%2Ffirefox%2F&title=true
Response:
```
# Firefox - Protect your life online with privacy-first products — Mozilla (UK)
Meet our family of products
---------------------------
...
```
Title is also returned in HTTP header.
```
X-Title: Firefox%20-%20Protect%20your%20life%20online%20with%20privacy-first%20products%20%E2%80%94%20Mozilla%20(UK)
```
2022-01-09 22:25:11 +00:00
2022-01-30 20:50:42 +00:00
Alternative request, supply url and html:
POST https://urltomarkdown.herokuapp.com/
url=https%3A%2F%2Fwww.mozilla.org%2Fen-GB%2Ffirefox%2F
html=%3C!doctype%20html%3E%3Chtml%20...
2022-01-13 13:26:51 +00:00
Inspired by [Heck Yeah Markdown](http://heckyesmarkdown.com)
## Also of interest:
2022-01-30 20:50:42 +00:00
### Bookmarklet
2022-01-13 13:26:51 +00:00
A bookmarklet for SimpleNote on iOS/iPadOS (based on [simpleclip](https://gist.github.com/byrney/b21456682e77a0d51708)):
```
javascript:(
function()
{
var request=new XMLHttpRequest();
var url="https://urltomarkdown.herokuapp.com/?url="+encodeURIComponent(location.href);
request.onreadystatechange=function() {
2022-01-18 19:59:07 +00:00
if(request.readyState==4&&request.status==200) {
2022-01-20 13:13:07 +00:00
let text = '# ' + decodeURIComponent(request.getResponseHeader('X-Title')) + '\n' + request.responseText;
2022-01-18 19:59:07 +00:00
location.href="simplenote://new?content="+encodeURIComponent(text);
2022-01-13 13:26:51 +00:00
}
};
request.open("GET",url, true);
request.send();
}
)();
```
2022-01-30 20:50:42 +00:00
### Safari Snippets
Using [Safari Snippets](https://apps.apple.com/us/app/safari-snippets/id1126048257)
with the following code solves the issue that some sites prevent javascript bookmarklets accessing a resource on a different domain
```
var request=new XMLHttpRequest();
var herokuurl="https://urltomarkdown.herokuapp.com/";
request.onreadystatechange=function()
{
if(request.readyState==4&&request.status==200) {
let text = '# ' + decodeURIComponent(request.getResponseHeader('X-Title')) + '\n' + request.responseText;
location.href="simplenote://new?content="+encodeURIComponent(text);
}
};
request.open("POST", herokuurl, true);
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
html=document.documentElement.innerHTML;
request.send("html="+encodeURIComponent(html)+"&url="+encodeURIComponent(window.location.href));
```