Skip to content

Commit

Permalink
Merge pull request #47 from krassowski/links-in-biblio
Browse files Browse the repository at this point in the history
Make links and DOI in bibliography clickable
  • Loading branch information
krassowski authored Mar 23, 2022
2 parents 819a2e2 + f53af0b commit e58dd87
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
6 changes: 6 additions & 0 deletions schema/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
"default": true,
"description": "Should citations link to the bibliography? Only available for HTML output format."
},
"hyperlinksInBibliography": {
"title": "Hyperlinks in bibliography",
"type": "boolean",
"default": true,
"description": "Whether links and DOIs in bibliography should be clickable (if the output format supports it)."
},
"outputFormat": {
"title": "The default format of citations and bibliography",
"type": "string",
Expand Down
9 changes: 7 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ class UnifiedCitationManager implements ICitationManager {
private currentAdapter: IDocumentAdapter<any> | null = null;
private formattingOptions: ICitationFormattingOptions = {
defaultFormat: 'html',
linkToBibliography: true
linkToBibliography: true,
hyperlinksInBibliography: true
};

protected createAllReadyPromiseWrapper(): ICancellablePromise<any> {
Expand Down Expand Up @@ -537,6 +538,9 @@ class UnifiedCitationManager implements ICitationManager {
this.formattingOptions.linkToBibliography = settings.get(
'linkToBibliography'
).composite as boolean;
this.formattingOptions.hyperlinksInBibliography = settings.get(
'hyperlinksInBibliography'
).composite as boolean;
// refresh if needed
const currentPanel = this.notebookTracker.currentWidget;
if (currentPanel) {
Expand Down Expand Up @@ -886,7 +890,8 @@ class UnifiedCitationManager implements ICitationManager {
.then((engine: CiteProc.IEngine) => {
monkeyPatchCiteProc();
engine.setOutputFormat(formatID as OutputMode);
// engine.opt.development_extensions.apply_citation_wrapper = true;
engine.opt.development_extensions.wrap_url_and_doi =
this.formattingOptions.hyperlinksInBibliography;
return engine;
});
}
Expand Down
7 changes: 7 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ export type CitationToInsert = {

export interface ICitationFormattingOptions {
defaultFormat: OutputMode;
/**
* Whether citations should link to bibliography (if output mode supports it)
*/
linkToBibliography: boolean;
/**
* Whether links and DOIs in bibliography should be clickable (if the output mode supports it)
*/
hyperlinksInBibliography: boolean;
}

/**
Expand Down

0 comments on commit e58dd87

Please sign in to comment.