Action

PDF Expert > Bear

Posted by @kerim, Last update about 5 years ago - Unlisted

Take annotations export from PDF Expert, strip the word “highlight” and page numbers, as well as blank lines, then send to Bear with the appropriate tag instead of the line “sent from my iPhone.” (Designed to facilitate copying to outlining software later on.)

Steps

  • script

    draft.addTag("annotation");
    draft.update();
  • script

    var textToInsert = "? ";
    
    var sel = editor.getSelectedText();
    var selRange = editor.getSelectedRange();
    
    draft.content = textToInsert + draft.content;
    draft.update();
    
    editor.activate();
    
    if (!sel || sel.length == 0) {
      editor.setSelectedRange(selRange[0]+textToInsert.length,0);
    }
    else {
      editor.setSelectedRange(selRange[0]+textToInsert.length, selRange[1],0);
    }
  • script

    // define regex to use...
    const findRegex = /highlight\s.*?\:\s/g;
    // define replacement expression...
    const replaceWith = "";
    
    // do the replacement...
    draft.content = draft.content.replace(findRegex, replaceWith);
    draft.update();
  • script

    // define regex to use...
    const findRegex2 ='Sent from my iPhone';
    // define replacement expression...
    const replaceWith2 = "#reading/annotations";
    
    // do the replacement...
    draft.content = draft.content.replace(findRegex2, replaceWith2);
    draft.update();
  • callbackUrl

    template
    bear://x-callback-url/create?title=[[title]]&text=[[body]]
    waitForResponse
    false
    encodeTags
    true

Options

  • After Success Archive
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.