File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -172,12 +172,29 @@ export async function processNotebookEmbeds(
172172 if ( inline ) {
173173 const id = "nblink-" + count ++ ;
174174
175+ // If the first element of the notebook cell is a cell div with an id
176+ // then use that as the hash
177+ let firstCellId ;
178+ if (
179+ nbDivEl . firstElementChild &&
180+ nbDivEl . firstElementChild . classList . contains ( "cell" )
181+ ) {
182+ firstCellId = nbDivEl . firstElementChild . getAttribute ( "id" ) ;
183+ }
184+
175185 const nbLinkEl = doc . createElement ( "a" ) ;
176186 nbLinkEl . classList . add ( "quarto-notebook-link" ) ;
177187 nbLinkEl . setAttribute ( "id" , `${ id } ` ) ;
178- nbLinkEl . setAttribute ( "href" , nbPath . href ) ;
188+
179189 if ( nbPath . filename ) {
180190 nbLinkEl . setAttribute ( "download" , nbPath . filename ) ;
191+ nbLinkEl . setAttribute ( "href" , nbPath . href ) ;
192+ } else {
193+ if ( firstCellId ) {
194+ nbLinkEl . setAttribute ( "href" , `${ nbPath . href } #${ firstCellId } ` ) ;
195+ } else {
196+ nbLinkEl . setAttribute ( "href" , `${ nbPath . href } ` ) ;
197+ }
181198 }
182199 nbLinkEl . appendChild (
183200 doc . createTextNode (
You can’t perform that action at this time.
0 commit comments