11# ' Schema org writer
2- # '
2+ # '
33# ' @export
44# ' @param z an object of class `handl`; see [handl] for more
5- # ' @param auto_unbox (logical) automatically "unbox" all atomic
5+ # ' @param auto_unbox (logical) automatically "unbox" all atomic
66# ' vectors of length 1 (default: `TRUE`). passed to [jsonlite::toJSON()]
7- # ' @param pretty (logical) adds indentation whitespace to JSON output
7+ # ' @param pretty (logical) adds indentation whitespace to JSON output
88# ' (default: `TRUE`), passed to [jsonlite::toJSON()]
99# ' @param ... further params passed to [jsonlite::toJSON()]
1010# ' @return an object of class `json`
1717# ' schema_org_writer(tmp)
1818# ' schema_org_writer(tmp, pretty = FALSE)
1919# ' }
20- # '
21- # ' # many citeproc to schema
20+ # '
21+ # ' # many citeproc to schema
2222# ' z <- system.file('extdata/citeproc-many.json', package = "handlr")
2323# ' w <- citeproc_reader(x = z)
2424# ' schema_org_writer(w)
@@ -32,23 +32,23 @@ schema_org_writer <- function(z, auto_unbox = TRUE, pretty = TRUE, ...) {
3232
3333schema_hsh <- function (x ) {
3434 ccp(list (
35- " @context" = if (! is.null(x $ id )) " http ://schema.org" else NULL ,
35+ " @context" = if (! is.null(x $ id )) " https ://schema.org" else NULL ,
3636 " @type" = x $ type ,
3737 " @id" = x $ id ,
38- " identifier" = to_schema_org_identifier(x $ id ,
38+ " identifier" = to_schema_org_identifier(x $ id ,
3939 ccp(list (alternate_identifier = x $ alternate_identifier %|| % NULL ))),
4040 " url" = x $ b_url ,
4141 " additionalType" = x $ additional_type ,
4242 " name" = parse_attributes(x $ title , content = " text" , first = TRUE ),
4343 " author" = to_schema_org(x $ author ),
4444 " editor" = to_schema_org(x $ editor ),
45- " description" =
45+ " description" =
4646 parse_attributes(x $ description , content = " text" , first = TRUE ),
4747 " license" = unlist(ccp(lapply(x $ license , function (l ) l $ id ))),
4848 " version" = x $ software_version ,
49- " keywords" = if (! is.null(x $ keywords ))
50- paste0(lapply(x $ keywords , function (k )
51- parse_attributes(k , content = " text" , first = TRUE )),
49+ " keywords" = if (! is.null(x $ keywords ))
50+ paste0(lapply(x $ keywords , function (k )
51+ parse_attributes(k , content = " text" , first = TRUE )),
5252 collapse = " , " ) else NULL ,
5353 " inLanguage" = x $ language %|| % NULL ,
5454 " contentSize" = x $ content_size %|| % NULL ,
@@ -60,7 +60,7 @@ schema_hsh <- function(x) {
6060 " pageEnd" = x $ last_page %|| % NULL ,
6161 " spatialCoverage" = x $ spatial_coverage %|| % NULL ,
6262 " sameAs" = to_schema_org(x $ is_identical_to ),
63- " isPartOf" = if (x $ type == " Dataset" ) NULL else
63+ " isPartOf" = if (x $ type == " Dataset" ) NULL else
6464 to_schema_org_container(x $ is_part_of , list (
6565 container_title = x $ container_title , type = x $ type )),
6666 " hasPart" = to_schema_org(x $ has_part ),
@@ -70,13 +70,13 @@ schema_hsh <- function(x) {
7070 " @reverse" = x $ reverse.presence ,
7171 " contentUrl" = x $ content_url %|| % NULL ,
7272 " schemaVersion" = x $ schema_version %|| % NULL ,
73- " includedInDataCatalog" = if (x $ type == " Dataset" )
74- to_schema_org_container(x $ is_part_of ,
73+ " includedInDataCatalog" = if (x $ type == " Dataset" )
74+ to_schema_org_container(x $ is_part_of ,
7575 list (container_title = x $ container_title , type = x $ type )) else NULL ,
76- " publisher" = if (! is.null(x $ publisher ))
76+ " publisher" = if (! is.null(x $ publisher ))
7777 list (" @type" = " Organization" , " name" = x $ publisher ) else NULL ,
7878 " funding" = to_schema_org(x $ funding ),
79- " provider" = if (! is.null(x $ service_provider ))
79+ " provider" = if (! is.null(x $ service_provider ))
8080 list (" @type" = " Organization" , " name" = x $ service_provider ) else NULL
8181 ))
8282}
@@ -109,7 +109,7 @@ wrap_list <- function(m) {
109109}
110110
111111to_schema_org_identifier <- function (element , options = list ()) {
112- ident <- list (
112+ ident <- list (
113113 " @type" = " PropertyValue" ,
114114 propertyID = if (! is.null(normalize_doi(element ))) " doi" else " url" ,
115115 value = element
0 commit comments