UNPKG

@citation-js/plugin-pubmed

Version:

Citation.js plugin for PubMed and PubMed Central.

40 lines (39 loc) 954 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ref = exports.formats = void 0; var _core = require("@citation-js/core"); const ref = '@pubmed'; exports.ref = ref; const formats = { '@pubmed/id': { parseAsync(id) { id = id.replace('pmid:', ''); const url = `https://api.ncbi.nlm.nih.gov/lit/ctxp/v1/pubmed/?format=csl&id=${id}`; const headers = {}; return _core.util.fetchFileAsync(url, { headers }); }, parseType: { dataType: 'String', predicate: /^pmid:\d+$/ } }, '@pubmed/pmcid': { parseAsync(id) { id = id.replace('PMC', ''); const url = `https://api.ncbi.nlm.nih.gov/lit/ctxp/v1/pmc/?format=csl&id=${id}`; const headers = {}; return _core.util.fetchFileAsync(url, { headers }); }, parseType: { dataType: 'String', predicate: /^PMC\d+$/ } } }; exports.formats = formats;