11import type FNote from "../entities/fnote.js" ;
2+ import { applyReferenceLinks } from "../widgets/type_widgets/text/read_only_helper.js" ;
23import { getCurrentLanguage } from "./i18n.js" ;
34import { formatCodeBlocks } from "./syntax_highlight.js" ;
45
@@ -10,18 +11,18 @@ export default function renderDoc(note: FNote) {
1011 if ( docName ) {
1112 // find doc based on language
1213 const url = getUrl ( docName , getCurrentLanguage ( ) ) ;
13- $content . load ( url , ( response , status ) => {
14+ $content . load ( url , async ( response , status ) => {
1415 // fallback to english doc if no translation available
1516 if ( status === "error" ) {
1617 const fallbackUrl = getUrl ( docName , "en" ) ;
17- $content . load ( fallbackUrl , ( ) => {
18- processContent ( fallbackUrl , $content )
18+ $content . load ( fallbackUrl , async ( ) => {
19+ await processContent ( fallbackUrl , $content )
1920 resolve ( $content ) ;
2021 } ) ;
2122 return ;
2223 }
2324
24- processContent ( url , $content ) ;
25+ await processContent ( url , $content ) ;
2526 resolve ( $content ) ;
2627 } ) ;
2728 } else {
@@ -32,7 +33,7 @@ export default function renderDoc(note: FNote) {
3233 } ) ;
3334}
3435
35- function processContent ( url : string , $content : JQuery < HTMLElement > ) {
36+ async function processContent ( url : string , $content : JQuery < HTMLElement > ) {
3637 const dir = url . substring ( 0 , url . lastIndexOf ( "/" ) ) ;
3738
3839 // Images are relative to the docnote but that will not work when rendered in the application since the path breaks.
@@ -42,6 +43,9 @@ function processContent(url: string, $content: JQuery<HTMLElement>) {
4243 } ) ;
4344
4445 formatCodeBlocks ( $content ) ;
46+
47+ // Apply reference links.
48+ await applyReferenceLinks ( $content [ 0 ] ) ;
4549}
4650
4751function getUrl ( docNameValue : string , language : string ) {
0 commit comments