Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Get Selection in Markdown #82
For capturing article snippets (for republication, or just taking notes), a feature to get the selection in Markdown format would be incredibly useful.
Ideally, the Markdown would include:
Beside html2text, there's the kramdown Ruby library, which since the 0.9.0 version also converts an HTML document into a kramdown (Markdown + some extensions) document.
kramdown is my favorite Markdown converter, mainly because it also supports IDs and tables. The tables format is compatible with the MultiMarkdown one.
added a commit
Mar 12, 2012
OK, this has been added and I've just released v1.0.5 so let me know how you like it after updating.
Unfortunately, unlike Markdown -> HTML conversion, HTML -> Markdown is quite lossy. Especially since the HTML being converted is rarely originally generated from Markdown. For this reason the Markdown created may not be perfect or clean but should be valid. Hopefully, html.md (the library I created based on Make.text) will mature as bugs are identified and fixed. Keep in mind that the original code was intended as a bookmarklet and last updated almost 5 years ago.
Also, it's worth noting that, since the selection HTML is actually detached from the original document it's impossible to get the computed style and therefor work out exactly what elements are visible on the page. So expect to see some hidden content from time to time.
No problem. I'm the same. 90% of Template is written in 5 minute intervals while I wait for server restarts and temperamental tools. I used to just swear at the legacy software during this time, so improving Template is much more productive.
For simplicity's sake, the following template can be used;
Why is it escaping symbols sometimes?
I could do this in a future release but I might not enable by default unless you think it would be best to. This would probably mean that the existing Markdown predefined template would need renamed to something like "Markdown Link".
html.md escapes all Markdown special characters to ensure that you don't get an accidental header etc. It's not as pleasing to the eyes but should be perfectly valid Markdown. It's far safer (and easier) to just escape these.
This one confused me until I realised that it could look like an ordered list to Markdown, hence the escape.
The asterisks are escaped as they would be seen as an unordered list when the original page didn't use that.