Skip to content

Commit

Permalink
Merge branch 'uroybd-main'
Browse files Browse the repository at this point in the history
  • Loading branch information
oleeskild committed Jan 16, 2024
2 parents 7b30eb2 + c30f89f commit 287c002
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/compiler/DataviewCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ export class DataviewCompiler {
const query = inlineQuery[1];

const dataviewResult = dvApi.tryEvaluate(query.trim(), {
this: dvApi.page(file.getPath()),
this: dvApi.page(file.getPath()) ?? {},
});

if (dataviewResult) {
replacedText = replacedText.replace(
code,
dataviewResult.toString(),
dataviewResult.toString() ?? "",
);
}
} catch (e) {
Expand Down Expand Up @@ -226,7 +226,7 @@ function tryDVEvaluate(

try {
const dataviewResult = dvApi.tryEvaluate(query.trim(), {
this: dvApi.page(file.getPath()),
this: dvApi.page(file.getPath()) ?? {},
});
result = dataviewResult?.toString() ?? "";
} catch (e) {
Expand Down
9 changes: 7 additions & 2 deletions src/compiler/GardenPageCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,13 @@ export class GardenPageCompiler {
const refHeader =
transclusionFileName.split("#")[1];

// This is to mitigate the issue where the header matching doesn't work properly with headers with special characters (e.g. :)
// Obsidian's autocomplete for transclusion omits such charcters which leads to full page transclusion instead of just the heading
const headerSlug = slugify(refHeader);

const headerInFile = metadata?.headings?.find(
(header) => header.heading === refHeader,
(header) =>
slugify(header.heading) === headerSlug,
);

sectionID = `#${slugify(refHeader)}`;
Expand Down Expand Up @@ -434,7 +439,7 @@ export class GardenPageCompiler {
);

const headerSection = header
? `$<div class="markdown-embed-title">\n\n${header}\n\n</div>\n`
? `<div class="markdown-embed-title">\n\n${header}\n\n</div>\n`
: "";
let embedded_link = "";

Expand Down
2 changes: 1 addition & 1 deletion src/dg-testVault/0 QA hell/Break links + transclusions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This is a header ref which doesn't exist:
![[0 File with headers#whodis]]


This is a header transclusion that is slightly wrong in a way that obsidian fixes it but DG doesn't #known-issue
This is a header transclusion that is slightly that uses a special character in the header

![[0 File with headers#Header?]]

9 changes: 9 additions & 0 deletions src/dg-testVault/L Languages/Chinese.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

Here is a header with only Chinese
# 解决

This should be visible when transcluding the header above


# 使用
This should not be visible in transclusions
5 changes: 5 additions & 0 deletions src/dg-testVault/L Languages/Transclude Headers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
dg-publish: true
---

![[Chinese#解决]]
5 changes: 4 additions & 1 deletion src/dg-testVault/L Links/01 Link to header.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
dg-publish: true
---
Link to header should keep header link info
[[000 Home#Welcome]]
[[000 Home#Welcome]]

Link to header with special characters should work
![[02 Header with special character#A header With a colon]]
5 changes: 5 additions & 0 deletions src/dg-testVault/L Links/02 Header with special character.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# A header: With a colon
Body under header

# Another Header
Not expected to be part of transclusion
58 changes: 43 additions & 15 deletions src/test/snapshot/snapshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Whitespace and bar in name:

<div class="transclusion internal-embed is-loaded"><div class="markdown-embed">

$<div class="markdown-embed-title">
<div class="markdown-embed-title">

# whitespace.

Expand All @@ -32,7 +32,7 @@ Random hashes in transclusion title:

<div class="transclusion internal-embed is-loaded"><div class="markdown-embed">

$<div class="markdown-embed-title">
<div class="markdown-embed-title">

## ## i think i fixed this one ## earlier #lol

Expand Down Expand Up @@ -69,27 +69,17 @@ Cheese



This is a header transclusion that is slightly wrong in a way that obsidian fixes it but DG doesn't #known-issue
This is a header transclusion that is slightly that uses a special character in the header


<div class="transclusion internal-embed is-loaded"><div class="markdown-embed">





This is above the header
## Header

This should be in this header block

## Another header

This shouldn't be under a header transclusion



Cheese

</div></div>

Expand Down Expand Up @@ -410,7 +400,7 @@ How deep can you go?

<div class="transclusion internal-embed is-loaded"><div class="markdown-embed">

$<div class="markdown-embed-title">
<div class="markdown-embed-title">

# Spice it up

Expand Down Expand Up @@ -608,6 +598,31 @@ this plugin has custom filter that turns 🌞 (snow emoji) into 🌞 (THE SUN).
</div></div>
```
/img/user/A Assets/travolta.png
,/img/user/A Assets/unused_image.png
,/img/user/A Assets/travolta.webp
==========
L Languages/Transclude Headers.md
==========
---
{"dg-publish":true,"permalink":"/l-languages/transclude-headers/"}
---



<div class="transclusion internal-embed is-loaded"><div class="markdown-embed">



# 解决

This should be visible when transcluding the header above



</div></div>


/img/user/A Assets/travolta.png
,/img/user/A Assets/unused_image.png
,/img/user/A Assets/travolta.webp
Expand All @@ -620,6 +635,19 @@ L Links/01 Link to header.md

Link to header should keep header link info
[[000 Home#Welcome\|000 Home#Welcome]]

Link to header with special characters should work

<div class="transclusion internal-embed is-loaded"><div class="markdown-embed">



# A header: With a colon
Body under header


</div></div>

/img/user/A Assets/travolta.png
,/img/user/A Assets/unused_image.png
,/img/user/A Assets/travolta.webp
Expand Down Expand Up @@ -670,7 +698,7 @@ P Plugins/PD Dataview/PD3 Inline JS queries.md


3
96
102
<p><span>A paragraph</span></p>

/img/user/A Assets/travolta.png
Expand Down
2 changes: 1 addition & 1 deletion src/views/SettingsView/SettingView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ export default class SettingView {
new Setting(themeModal.contentEl)
.setName("Favicon")
.setDesc(
"Path to an svg in your vault you wish to use as a favicon. Leave blank to use default.",
"Path to an svg in your vault you wish to use as a favicon. Leave blank to use default. Must be square! (eg. 16x16)",
)
.addText((tc) => {
tc.setPlaceholder("myfavicon.svg");
Expand Down

0 comments on commit 287c002

Please sign in to comment.