This is rather technical question for Keith. Lets say I have an Applescript and I want to use it to create an RTF link wrapped in an inline annotation I can paste from the system clipboard into Scrivener’s editor. The link itself is easy using textutil (with a caveat of the font styling):
echo " <a href=\"http://http://literatureandlatte.com/\">L&L</a> " | textutil -format html -convert rtf -stdin -stdout | pbcopy -Prefer rtf
The question is what is the RTF for an inline annotation or comment assuming it is something custom (doubt textutil could generate it)?
Assuming it is custom and based on a test scrivener doc (binder saved doc with a link in an inline annotation) I created a “minimal” RTF fragment:
{\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf200
\f0\fs28 \cf0 L:
\f1\fs24 \{\\Scrv_annot \\color=\{\\R=0.619608\\G=0.043137\\B=0.011765\} \\text=
\f0\fs28 {\field{\*\fldinst{HYPERLINK "http://literatureandlatte.com/"}}{\fldrslt L&L}}
\f1\fs24 \\end_Scrv_annot\}}
Copies into the clipboard as RTF, but when pasted to Scrivener the escaping yields no working annotation (the link works however):
L: {\Scrv_annot \color={\R=0.619608\G=0.043137\B=0.011765} \text= L&L \end_Scrv_annot}
OK so lets try to see what Scrivener itself copies to the clipboard (public.rtf, found using Clipboard Viewer):
{\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf200
\stshfdbch0{\fonttbl\f0\fnil\fcharset0 GraublauSlab-Regular;}
{\colortbl;\red255\green255\blue255;}
{\stylesheet {\s0 Normal;}}
{\*\expandedcolortbl;;}
\deftab720
\paperw12240\paperh15840\margl1800\margr1800\margt1440\margb1440\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\tx9360\tx10080\tx10800\tx11520\pardeftab720\sl336\slmult1\pardirnatural\qj\partightenfactor0
\f0\fs28 \cf0 L: {\chatn{\*\annotation\pard\plain\f0\fs28\b0\i0\ul0 {\field{\*\fldinst{HYPERLINK "http://literatureandlatte.com/"}}{\fldrslt L&L}}}}\f0\fs28\b0 \i0 \ul0 }
To generate this minimal fragment:
{\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf200
\f0\fs28 \cf0 L: {\chatn{\*\annotation\pard\plain\f0\fs28\b0\i0\ul0 {\field{\*\fldinst{HYPERLINK "http://literatureandlatte.com/"}}{\fldrslt L&L}}}}\f0\fs28\b0\i0\ul0 }
This is different to what is saved. If I then use pbpaste I get L: wrapped in an inspector comment containing the L&L link. This would almost work. Obviously Scrivener is doing some other magic to be able to copy and paste inline annotations and deal with the font styling (I would like the pasted text to match the style).
So what I’m asking:
What is the minimal RTF plain text fragment that would trigger an inline annotation containing a link, and not change the font styling? Perhaps Applescript has some better mechanism to paste RTF to the clipboard better, but so far pbpaste -Prefer rtf does most of what is needed. I suspect you do not use public.rtf but a custom clipboard field for this?