Skip to contents

Import a source from Google Documents

Usage

import_source_from_gDocs(x, localFile = NULL)

Arguments

x

The URL to the source: has to be viewable publicly!

localFile

A local file (where to store a local backup).

Value

The source contents.

Examples

### Note that this will require an active
### internet connection! This if statement
### checks for that.
# \donttest{
if (tryCatch({readLines("https://google.com",n=1); TRUE}, error=function(x) FALSE)) {

  gDocs_url <-
    paste0(
      "https://docs.google.com/document/d/",
      "1iACYjV7DdCjOmfgX6KEMtCcCjuuXD3iuikTSGWtsK84",
      "/edit?usp=sharing"
    );

  ### Import the source
  exampleSource <-
    import_source_from_gDocs(
      gDocs_url
    );

  ### Show the downloaded file:
  exampleSource;

  ### Parse the source:
  parsedExampleSource <-
    rock::parse_source(
      exampleSource
    );

  ### Imported; the comments are gone:
  parsedExampleSource$qdt$utterances_raw;
}
#> [1] "[[uid=7s9lhsqj]] [[cid:case_1]]"                                                            
#> [2] "[[uid=7s9lhsqk]] This is an example source for you to code, for example with a [[treeCode]]"
#> [3] "[[uid=7s9lhsql]]"                                                                           
#> [4] "[[uid=7s9lhsqn]] It just contains these sentences. [[contains||these sentences]]"           
#> [5] "[[uid=7s9lhsqp]] It's not much, but you'll have to make do with it."                        
#> [6] "[[uid=7s9lhsqq]] Life is not easy. [[not_easy->life||property]]"                            
#> [7] "[[uid=7s9lhsqr]] Sometimes, you don't get what you want, but what you need."                
# }