I played with a script that displays the selected text in Chrome and views it on Google, offering the four best options, and then pasting the appropriate link. It is pasted in different formats, depending on which page is currently open in Chrome - DokuWiki with the opening of DokuWiki, HTML with regular websites, and I want to have rich text for my WordPress WYSIWYG editor.
I tried using pbpaste -Prefer rtf to see which link on rich text, without any other style, looked like on a file cabinet, but it still displays the text. After saving the file in a text editor and experimenting, I came up with the following
text = %q|{\rtf1{\field{\*\fldinst{HYPERLINK "URL"}}{\fldrslt TEXT}}}| text.gsub!("URL", url) text.gsub!("TEXT", stext)
(I had to use gsub because somehow when using %Q and #{} to insert variables, the line did not work)
This works, however, when I insert it, there is an extra line-line before and after the link. What would a string look like to avoid this?
source share