Web service for web page to Markdown conversion
 
 
 
Go to file
Lee Hanken bdd1e26114 Added OpenAPI specification 2024-04-21 15:49:07 +01:00
node_modules added unit tests 2022-12-23 12:03:25 +00:00
tests added unit tests 2022-12-23 12:03:25 +00:00
Dockerfile added unit tests 2022-12-23 12:03:25 +00:00
html_table_to_markdown.js another attempt at parsing code blocks better 2022-11-22 11:37:33 +00:00
index.js exit after reading from url when ignoring posted html 2022-12-21 23:11:15 +00:00
license.txt another attempt at parsing code blocks better 2022-11-22 11:37:33 +00:00
package-lock.json added unit tests 2022-12-23 12:03:25 +00:00
package.json added unit tests 2022-12-23 12:03:25 +00:00
readme.md another attempt at parsing code blocks better 2022-11-22 11:37:33 +00:00
url_to_markdown_apple_dev_docs.js include period after number in ordered lists when parsing apple dev docs 2022-05-03 12:15:56 +01:00
url_to_markdown_common_filters.js added filter for stackoverflow to hide editor 2022-11-05 02:22:55 +00:00
url_to_markdown_formatters.js refactor into modules 2022-12-21 22:28:59 +00:00
url_to_markdown_processor.js refactor into modules 2022-12-21 22:28:59 +00:00
url_to_markdown_readers.js added unit tests 2022-12-23 12:03:25 +00:00
urltomarkdown.openapi.json Added OpenAPI specification 2024-04-21 15:49:07 +01:00

readme.md

Convert a webpage to markdown

Provides a web service that downloads a requested web page and outputs a markdown version.

Example request, supply url:

GET https://urltomarkdown.herokuapp.com/?url=https%3A%2F%2Fwww.mozilla.org%2Fen-GB%2Ffirefox%2F

Response:

Meet our family of products
---------------------------

*   [![](https://www.mozilla.org/media/protocol/img/logos/firefox/browser/logo.eb1324e44442.svg)  

	...

[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)

Optionally suppress links:

GET https://urltomarkdown.herokuapp.com/?url=https%3A%2F%2Fwww.mozilla.org%2Fen-GB%2Ffirefox%2F&links=false

Alternative POST request, supply url and html in POST body:

POST https://urltomarkdown.herokuapp.com/?title=true&links=false
	
	url=https%3A%2F%2Fwww.mozilla.org%2Fen-GB%2Ffirefox%2F
	
	html=%3C!doctype%20html%3E%3Chtml%20...

Inspired by Heck Yeah Markdown

Also of interest:

Bookmarklet

A bookmarklet for SimpleNote on iOS/iPadOS (based on simpleclip):

javascript:(
	function()
	{
		var request=new XMLHttpRequest();
		var url="https://urltomarkdown.herokuapp.com/?url="+encodeURIComponent(location.href);
		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("GET",url, true);
		request.send();
		}
)();

Safari Snippets

Using Safari Snippets to inject 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));