Problem pasting from Livecode to Mac Mail

Brian Milby brian at milby7.com
Fri Jan 12 12:42:43 EST 2018


So there are 2 issues with how LiveCode is handling placing text onto the
clipboard:
- converting plain text to HTML on the clipboard
- using <p> tags for each line break when converting to HTML

I’m not sure of the reasoning behind the first issue. I understand wanting
to have the native LC format for rich text, but if placing plain text on
the clipboard, I think that the user wants plain text and not HTML.

The second issue may take some additional thought/discussion. Looking at
the code, it uses the <p> tag to wrap attributes, so eliminating it
globally isn’t an option. Magic happens here:

fieldhtml.cpp / export_html_emit_paragraphs
fieldh.cpp / MCField::doexport

If it was changed to use <br> for single line breaks and only assuming a
paragraph when there are 2, that would probably take care of it in most
cases. Paragraphs are split by /n here (internal LC styled text
representation):

fieldh.cpp / MCField::texttoparagraphs

Still digging...
On Fri, Jan 12, 2018 at 3:23 AM Peter Reid via use-livecode <
use-livecode at lists.runrev.com> wrote:

> Sorry, forgot to change Subject in previous posting...
>
> Hi Richard
>
> I found this problem was particularly annoying when trying to extract info
> from vCards exported from Contacts on the Mac, so I developed a tiny app in
> LC called vCardClipper.
>
> I've put together a web page about this app together with download links
> to a Mac App and the source code.  Here's the link to this web page, help
> yourself:
>
> https://www.reid-it.co.uk/downloads/downvcclip.htm
>
> The key is to paste HTML format text into Mail replacing RETURN with
> "<br>" and replacing spaces with "&nbrsp;". The code is in the following
> handler (which is in the stack script):
>
> on loadClipboard pPlainText, pPasteMode
>    -- pPasteMode: HTML or text
>    set itemDelimiter to "."
>    put item 1 of the version into tLCversion
>    lock the clipboard
>    if tLCversion >= "8" then
>       -- for LC 8.x or later:
>       set the fullClipboardData to empty
>       switch pPasteMode
>          case "HTML"
>             put pPlainText into tHTMLtext
>             replace return with "<br>" in tHTMLtext
>             replace space with " " in tHTMLtext
>             set the fullClipboardData["HTML"] to "<p>" & tHTMLtext & "</p>"
>             break
>          case "text"
>             set the fullClipboardData["text"] to pPlainText
>             break
>       end switch
>    else
>       -- for LC 7.x or earlier:
>       switch pPasteMode
>          case "HTML"
>             put pPlainText into tHTMLtext
>             replace return with "<br>" in tHTMLtext
>             replace space with " " in tHTMLtext
>             set the clipboardData["HTML"] to "<p>" & tHTMLtext & "</p>"
>             break
>          case "text"
>             set the clipboardData["text"] to pPlainText
>             break
>       end switch
>    end if
>    unlock the clipboard
> end loadClipboard
>
>
> Peter
> --
> Peter Reid
> Loughborough, UK
>
> > On 10 Jan 2018, at 9:38am, use-livecode-request at lists.runrev.com wrote:
> >
> > Message: 5
> > Date: Tue, 9 Jan 2018 10:09:51 -0800
> > From: Richard Burkett <richard.burkett at sbcglobal.net>
> > To: use-livecode at lists.runrev.com
> > Subject: Problem pasting from Livecode to Mac Mail
> > Message-ID: <BF402ECC-C11D-4526-82C2-B5267520D414 at sbcglobal.net>
> > Content-Type: text/plain;     charset=utf-8
> >
> > Does anyone have a solution to this problem: I set the clipboard in
> LiveCode to the text of a field or variable that has returns after each
> line. When I paste that into Mac Mail, the text appears double-spaced as if
> it has two returns, but clearly there is just one (or a combination of CR
> and LF?). I?ve tried all the keys for setting the clipboard and also
> writing a script to delete line feeds, or CR characters, but nothing works.
> It?s either no returns, or what appears to be double-spaced returns.
> >
> > If I paste the text first into Text Edit, then copy it, and paste into
> Mac Mail it?s fine - single line spacing. What?s LiveCode adding to each
> line that causes Mac Mail to show the pasted text as double spaced? Is
> there a way to filter/remove that?
> >
> > Richard Burkett
> > richard.burkett at sbcglobal.net
>
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list