File tree Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ import {
3030 contextPdfOutputRecipe ,
3131 useContextPdfOutputRecipe ,
3232} from "./output-tex.ts" ;
33+ import { formatOutputFile } from "../../core/render.ts" ;
3334
3435// render commands imply the --output argument for pandoc and the final
3536// output file to create for the user, but we need a 'recipe' to go from
@@ -50,11 +51,8 @@ export function outputRecipe(
5051 // could be within metadata)
5152 let output = options . flags ?. output ;
5253 if ( ! output ) {
53- let outputFile = format . pandoc [ kOutputFile ] ;
54+ const outputFile = formatOutputFile ( format ) ;
5455 if ( outputFile ) {
55- if ( ! outputFile . match ( / \. .+ $ / ) && format . render [ kOutputExt ] ) {
56- outputFile = `${ outputFile } .${ format . render [ kOutputExt ] } ` ;
57- }
5856 if ( isAbsolute ( outputFile ) ) {
5957 output = outputFile ;
6058 } else {
Original file line number Diff line number Diff line change 55*
66*/
77
8+ import { kOutputExt , kOutputFile } from "../config/constants.ts" ;
9+ import { Format } from "../config/types.ts" ;
810import { dirAndStem } from "./path.ts" ;
911
1012export function inputFilesDir ( input : string ) {
@@ -21,3 +23,13 @@ export function figuresDir(pandocTo?: string) {
2123 pandocTo = ( pandocTo || "html" ) . replace ( / [ \+ \- ] .* $ / , "" ) ;
2224 return "figure-" + pandocTo ;
2325}
26+
27+ export function formatOutputFile ( format : Format ) {
28+ let outputFile = format . pandoc [ kOutputFile ] ;
29+ if ( outputFile ) {
30+ if ( ! outputFile . match ( / \. .+ $ / ) && format . render [ kOutputExt ] ) {
31+ outputFile = `${ outputFile } .${ format . render [ kOutputExt ] } ` ;
32+ }
33+ }
34+ return outputFile ;
35+ }
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ import {
3434 normalizeWebsiteFormat ,
3535} from "./types/website/website-config.ts" ;
3636import { kDefaultProjectFileContents } from "./types/project-default.ts" ;
37+ import { formatOutputFile } from "../core/render.ts" ;
3738
3839export interface InputTargetIndex extends Metadata {
3940 title ?: string ;
@@ -167,7 +168,7 @@ export async function resolveInputTarget(
167168 const formats = formatsPreferHtml ( index . formats ) as Record < string , Format > ;
168169 const format = Object . values ( formats ) [ 0 ] ;
169170 const [ hrefDir , hrefStem ] = dirAndStem ( href ) ;
170- const outputFile = format . pandoc [ kOutputFile ] || `${ hrefStem } .html` ;
171+ const outputFile = formatOutputFile ( format ) || `${ hrefStem } .html` ;
171172 const outputHref = pathWithForwardSlashes (
172173 ( absolute ? "/" : "" ) + join ( hrefDir , outputFile ) ,
173174 ) ;
You can’t perform that action at this time.
0 commit comments