From 01737f3a422f6d3da87d704807251ca3d69b97db Mon Sep 17 00:00:00 2001 From: Mayuran Visakan Date: Sun, 26 Nov 2023 22:15:24 +0000 Subject: [PATCH] Update Readme --- README.md | 8 ++++++++ src/Parsing/CodeblockParsing.ts | 9 +++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c91b242..ad9dba8 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,8 @@ Example: - ` ```cpp title=example_title fold` (same effect as above line) - ` ``` fold title:example_title` (if no language set) +The plugin can also parse rmarkdown style codeblock parameters so ` ```{r title, hl=5}` is a recognised opening codeblock line. + ### Line Numbers Line numbers can be enabled/disabled within a specific theme in the settings of that theme. In addition to this, whether line numbering is applied can be additionally specified in a codeblock itself using the `ln` parameter. @@ -98,6 +100,12 @@ Example: ![Title Long](images/TitleLong.png) +### References + +To display the title as a link to another page which can be clicked or hovered over, add the `ref:` or `reference:` parameter followed by a wikilink. The title will then show as a link to the referenced note. If no `title:` parameter is given, then the wikilink note name (or alias if given) will be used as the title. + +Note that these links will not show up on the Graph or in Backlinks - this is an upstream issue with Obsidian. + ### Folding To specify an initial fold state when the document is opened, use the `fold` parameter. If `fold` is set in a codeblock, then when you open the document, the codeblock will be automatically collapsed, and only the header will be displayed. You can unfold the codeblock by clicking on the header. diff --git a/src/Parsing/CodeblockParsing.ts b/src/Parsing/CodeblockParsing.ts index 06e5ba9..76386ca 100644 --- a/src/Parsing/CodeblockParsing.ts +++ b/src/Parsing/CodeblockParsing.ts @@ -206,7 +206,7 @@ function parseCodeblockParameterString(parameterString: string, codeblockParamet codeblockParameters.ignore = true; else if (/^title[:=]/.test(parameterString)) manageTitle(parameterString,codeblockParameters); - else if (/^ref[:=]/.test(parameterString)) + else if (/^ref[:=]/.test(parameterString) || /^reference[:=]/.test(parameterString)) manageReference(parameterString,codeblockParameters); else if (/^fold[:=]?/.test(parameterString)) manageFolding(parameterString,codeblockParameters); @@ -233,7 +233,12 @@ function manageTitle(parameterString: string, codeblockParameters: CodeblockPara } } function manageReference(parameterString: string, codeblockParameters: CodeblockParameters) { - const refMatch = /\[\[([^|]*?)(?:\|[^|]*?)?\]\]/.exec(parameterString.slice("ref:".length)); + if (/^ref[:=]/.test(parameterString)) + parameterString.slice("ref:".length); + else + parameterString.slice("reference:".length); + + const refMatch = /\[\[([^|]*?)(?:\|[^|]*?)?\]\]/.exec(parameterString); if (refMatch) { codeblockParameters.reference = refMatch[1].trim(); if (codeblockParameters.title === "")