Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Our editors are copying from Word and pasting into AE regularly. The Word documents they are working with are produced by a variety of external sources anduse the full spectrum of quotes. Does anyone have a snippet of ACL that can be run on save (XML)to convert all quotes to simple straight quotes?
Thanks for your help all!
Ashley
I had this same issue a few years ago and solved it by adding a callback function whenever a paste is done in arbortext. This may look convoluted and could probably be simplified but it works. I put this line in the instance.acl of the document:
doc_add_callback( current_doc(), 'paste', 'paste_callback');
and the function is this:
function paste_callback( doc, default, op )
{
if ( op == 1 )
{
# returning the -1 aborts the paste operation which is what we want since
# sub_quote will do it instead
sub_quote;
return -1;
}
else if ( op == 2 )
{
# this is where processing occurs
return 0;
}
}
which calls this:
#THIS ALIAS WILL SUBSTITUTE STRAIGHT QUOTES FOR CURLY QUOTES ON PASTE OPS
alias sub_quote {
if (buffer_doc(_APT_DRAGDROP_PASTEBUF) != -1) {
if (buffer_empty(_APT_DRAGDROP_PASTEBUF) == 0) { #Then we have a drag/drop op
set paste = _APT_DRAGDROP_PASTEBUF;
paste;
set paste=default;
return;
}
} else {
buffer_clipboard_contents($oldtxt);
}
$newtxt = java_static('id.lso.gems.epic.EpicUtil', 'subCurlyQuotes', $oldtxt);
insert_buffer($newtxt, 1, default,0);
#set pendingdelete=on;
if (length($newtxt) > 0) {
paste; #testbuf;
} else {
message_box("Paste buffer is empty. Please select text you wish to copy and try again.", 0);
}
set paste=default;
}
The java function is:
public static String subCurlyQuotes(String selectedText) {
selectedText = selectedText.replaceAll(String.valueOf('\u201C'), "");
selectedText = selectedText.replaceAll(String.valueOf('\u201D'), "");
return selectedText;
}