Path: blob/main/src/command/render/pandoc-dependencies.ts
3583 views
/*1* pandoc-dependencies.ts2*3* Copyright (C) 2020-2022 Posit Software, PBC4*/56import { DependencyFile, FormatDependency } from "../../config/types.ts";7import { appendTextFile } from "../../core/file.ts";89export interface HtmlFormatDependency {10type: "html";11content: FormatDependency;12}1314export interface HtmlAttachmentDependency {15type: "html-attachment";16content: {17name: string;18file: DependencyFile;19};20}2122export interface FormatResourceDependency {23type: "format-resources";24content: {25file: string;26};27}2829export interface TextDependency {30type: "text";31content: {32text: string;33location: "before-body" | "after-body" | "in-header";34};35}3637export interface FileDependency {38type: "file";39content: {40path: string;41};42}4344export interface UsePackageDependency {45type: "usepackage";46content: {47package: string;48options: string;49};50}5152export async function appendDependencies(53dependenciesFile: string,54dependencies: Array<55| HtmlFormatDependency56| HtmlAttachmentDependency57| FormatResourceDependency58| TextDependency59| FileDependency60| UsePackageDependency61>,62) {63const dependencyLines: string[] = [];64for (const dependency of dependencies) {65dependencyLines.push(66JSON.stringify(dependency),67);68}69if (dependencyLines.length > 0) {70await appendTextFile(71dependenciesFile,72`${dependencyLines.join("\n")}\n`,73);74}75}767778