Fsnotes: Suggestions for improved "Add Selection to FSNotes" service

Created on 1 Dec 2019  路  9Comments  路  Source: glushchenko/fsnotes

Describe your feature request
A clear and concise description of what you want to happen.

Right now the "Add Selection to FSNotes" service just grabs plain text. It doesn't preserve links in the text and it doesn't preserve the URL of the source page. I would like an updated version that grabs selected text with markdown formatting so that links are preserved, and appends the URL of the source page (and perhaps the title as well?) at the bottom for future reference.

Additional context
Add any other related information here. macOS or iOS?

Would be good if there was a share extension on iOS that worked similarly. I haven't looked into this yet.

request

Most helpful comment

@gingerbeardman maybe just use markdown Plain Text syntax

All 9 comments

I tried this originally and Rich Text wouldn't work as a Service so I had to do Plain Text.

Any thoughts @glushchenko ?

@gingerbeardman maybe just use markdown Plain Text syntax

Interesting idea, to convert to markdown in the service. I'm not sure how easy that will be but will give it some thought.

I tried this again and the problem is that for our use case the Automator workflow processes only plain text from the browser.

Rich text is available to create a new TextEdit note, for example, but when sending the text to another app as we do, only plain text is used.

We need some way of:

  1. getting the rich text
  2. converting it to markdown

Alternatives

  • HTML to Markdown, but it is too much to ask of users to copy HTML source rather than selected text

Would something like this help?

http://heckyesmarkdown.com/

(There's an API.)

No worries, I have a first version working (with one caveat)

  • line breaks are not currently respected

Feel free to open in Automator and try to improve what I have so far.

(download below)

Credits

I had uploaded a broken version, fixed version now above.

Line breaks are removed in the part of the workflow that creates the URL. Trying to fix now.

Here we go!

An AppleScript voodoo incantation about delimiters solved the line break issue.

use framework "Foundation"
use scripting additions

on run {input, parameters}
    set AppleScript's text item delimiters to {return & linefeed, return, linefeed, character id 8233, character id 8232}
    set myText to input
    set nsInput to current application's NSString's stringWithString:("fsnotes://new/?txt=" & myText)
    set characterSet to current application's NSCharacterSet's URLQueryAllowedCharacterSet()
    set escapedInput to (nsInput's stringByAddingPercentEncodingWithAllowedCharacters:characterSet) as text
    return escapedInput
end run

Working download:
Add Selection as Markdown to FSNotes.workflow.zip

Also added to Wiki page.

Have fun!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

peanutputter picture peanutputter  路  4Comments

jakemkc picture jakemkc  路  3Comments

fi0 picture fi0  路  4Comments

lowski picture lowski  路  3Comments

jakemkc picture jakemkc  路  4Comments