@@ -33,13 +33,14 @@ import { resolveParams } from "../../command/render/flags.ts";
3333import { RenderContext , RenderFlags } from "../../command/render/types.ts" ;
3434import { JupyterAssets , JupyterCellOutput } from "../jupyter/types.ts" ;
3535
36- import { dirname , extname } from "path/mod.ts" ;
36+ import { dirname , extname , join } from "path/mod.ts" ;
3737import { languages } from "../handlers/base.ts" ;
3838import {
3939 extractJupyterWidgetDependencies ,
4040 includesForJupyterWidgetDependencies ,
4141} from "./widgets.ts" ;
4242import { globalTempContext } from "../temp.ts" ;
43+ import { isAbsolute } from "https://deno.land/[email protected] /path/win32.ts" ; 4344
4445export interface JupyterNotebookAddress {
4546 path : string ;
@@ -158,7 +159,7 @@ export async function replaceNotebookPlaceholders(
158159 ) ;
159160
160161 const notebookIncludes = ( ) => {
161- const notebook = jupyterFromFile ( nbAddress . path ) ;
162+ const notebook = jupyterFromFile ( resolveNbPath ( input , nbAddress . path ) ) ;
162163 const dependencies = isHtmlOutput ( context . format . pandoc )
163164 ? extractJupyterWidgetDependencies ( notebook )
164165 : undefined ;
@@ -196,6 +197,14 @@ export async function replaceNotebookPlaceholders(
196197 } ;
197198}
198199
200+ function resolveNbPath ( input : string , path : string ) {
201+ if ( isAbsolute ( path ) ) {
202+ return path ;
203+ } else {
204+ return join ( dirname ( input ) , path ) ;
205+ }
206+ }
207+
199208async function notebookMarkdown (
200209 nbAddress : JupyterNotebookAddress ,
201210 assets : JupyterAssets ,
@@ -282,7 +291,9 @@ async function getCellOutputs(
282291 if ( ! nbCache . cache [ cacheKey ] ) {
283292 // Render the notebook and place it in the cache
284293 // Read and filter notebook
285- const notebook = jupyterFromFile ( nbAddress . path ) ;
294+ const notebook = jupyterFromFile (
295+ resolveNbPath ( context . target . input , nbAddress . path ) ,
296+ ) ;
286297 if ( options ) {
287298 notebook . cells = notebook . cells . map ( ( cell ) => {
288299 if ( options . echo !== undefined ) {
0 commit comments