New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Selection in Markdown #82

Closed
ghost opened this Issue Mar 6, 2012 · 13 comments

Comments

Projects
None yet
1 participant
@ghost

ghost commented Mar 6, 2012

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:

  • Bold, italic and other text formatting
  • Links
  • Image references
  • Tables

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.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 6, 2012

I'd like to reference issue #76, but I don't know how to go about that...

ghost commented Mar 6, 2012

I'd like to reference issue #76, but I don't know how to go about that...

@ghost ghost assigned neocotic Mar 6, 2012

@neocotic

This comment has been minimized.

Show comment
Hide comment
@neocotic

neocotic Mar 6, 2012

Member

You've just referenced it now :) You just needed to include the hash link.

I'll look in to these soon as I'll need to find/create a JavaScript port of one of these libraries.

That said, I definitely want this feature!

Member

neocotic commented Mar 6, 2012

You've just referenced it now :) You just needed to include the hash link.

I'll look in to these soon as I'll need to find/create a JavaScript port of one of these libraries.

That said, I definitely want this feature!

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 6, 2012

That said, I definitely want this feature!

Yes, I think it will take Template to a whole new level. You'll probably even be mentioned in the Mac Power Users podcast. :)

ghost commented Mar 6, 2012

That said, I definitely want this feature!

Yes, I think it will take Template to a whole new level. You'll probably even be mentioned in the Mac Power Users podcast. :)

@neocotic

This comment has been minimized.

Show comment
Hide comment
@neocotic

neocotic Mar 9, 2012

Member

I've found a good bookmarklet that I'm going to try and create a complete library based on called html.md.

Once this is done I can import it in to template and allow it to be used.

Member

neocotic commented Mar 9, 2012

I've found a good bookmarklet that I'm going to try and create a complete library based on called html.md.

Once this is done I can import it in to template and allow it to be used.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 9, 2012

Wow, great news! :)

Man, I'm happy...

ghost commented Mar 9, 2012

Wow, great news! :)

Man, I'm happy...

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 9, 2012

Make.text

Cool... And exists since 2006/2007... Totally escaped my radar... Great find!

ghost commented Mar 9, 2012

Make.text

Cool... And exists since 2006/2007... Totally escaped my radar... Great find!

@neocotic

This comment has been minimized.

Show comment
Hide comment
@neocotic

neocotic Mar 12, 2012

Member

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.

Member

neocotic commented 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.

@neocotic neocotic closed this Mar 12, 2012

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 13, 2012

Thanks for this, neocotic! Today was a tough day, little free time... I'll take it for a test drive tomorrow!

ghost commented Mar 13, 2012

Thanks for this, neocotic! Today was a tough day, little free time... I'll take it for a test drive tomorrow!

@neocotic

This comment has been minimized.

Show comment
Hide comment
@neocotic

neocotic Mar 13, 2012

Member

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;

{selectionMarkdown}
Member

neocotic commented Mar 13, 2012

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;

{selectionMarkdown}
@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 13, 2012

I used to just swear at the legacy software during this time, so improving Template is much more productive.

:D

{selectionMarkdown}

Ok. I'll add it now... Maybe in the future it could come as a default template? -- "Selection in Markdown"

ghost commented Mar 13, 2012

I used to just swear at the legacy software during this time, so improving Template is much more productive.

:D

{selectionMarkdown}

Ok. I'll add it now... Maybe in the future it could come as a default template? -- "Selection in Markdown"

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 13, 2012

Why is it escaping symbols sometimes?

**Welcome to Issue \#145 (February 17, 2005) of MIND CHATTER**

Notice the \#.

**2\. Please send Mind Chatter to a friend, and please send us your questions, comments, and suggestions.**

Here it's \.

And more...

\* Feature Article  
_Spiral Dynamics: A New Model for Understanding the Values that Shape Our World, Part 3_  
by Bill Harris, Director (scroll to item \#7)  

\* Glowing Testimonial of the Month (scroll to \#8)

Source: https://www.centerpointe.com/newsletter/edition_145.php

ghost commented Mar 13, 2012

Why is it escaping symbols sometimes?

**Welcome to Issue \#145 (February 17, 2005) of MIND CHATTER**

Notice the \#.

**2\. Please send Mind Chatter to a friend, and please send us your questions, comments, and suggestions.**

Here it's \.

And more...

\* Feature Article  
_Spiral Dynamics: A New Model for Understanding the Values that Shape Our World, Part 3_  
by Bill Harris, Director (scroll to item \#7)  

\* Glowing Testimonial of the Month (scroll to \#8)

Source: https://www.centerpointe.com/newsletter/edition_145.php

@neocotic

This comment has been minimized.

Show comment
Hide comment
@neocotic

neocotic Mar 13, 2012

Member

Ok. I'll add it now... Maybe in the future it could come as a default template? -- "Selection in Markdown"

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".

Why is it escaping symbols sometimes?

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.

Here it's \.

This one confused me until I realised that it could look like an ordered list to Markdown, hence the escape.

And more...

The asterisks are escaped as they would be seen as an unordered list when the original page didn't use that.

Member

neocotic commented Mar 13, 2012

Ok. I'll add it now... Maybe in the future it could come as a default template? -- "Selection in Markdown"

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".

Why is it escaping symbols sometimes?

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.

Here it's \.

This one confused me until I realised that it could look like an ordered list to Markdown, hence the escape.

And more...

The asterisks are escaped as they would be seen as an unordered list when the original page didn't use that.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Mar 14, 2012

neocotic, I want to test it more thoroughly... should have some time this evening... I'll also reply to your last comment then...

ghost commented Mar 14, 2012

neocotic, I want to test it more thoroughly... should have some time this evening... I'll also reply to your last comment then...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment