blacksmithgu / obsidian-dataview

A data index and query language over Markdown files, for https://obsidian.md/.
https://blacksmithgu.github.io/obsidian-dataview/
MIT License
6.96k stars 410 forks source link

Section link normalisation does not follow Obsidian's built-in normalisation behaviour #2218

Open indianakernick opened 8 months ago

indianakernick commented 8 months ago

What happened?

I'm finding that when certain characters are used in headings, the links are broken only when they are parsed by Dataview. In my case, I have a heading that contains a (that's U+2019). Linking to this heading works fine with Obsidian's built-in features but Dataview replaces that character with a space during parsing which produces a broken link. More experimentation revealed that all punctuation seems to cause the problem but Obsidian's native functionality works correctly.

The problem seems to be with the way that headers are normalised. It's stripping out more characters than Obsidian does. This normalisation needs to be relaxed.

I can sort of work around this by doing the parsing myself but there are some situations where it's not possible to get back the original string such as with CSVs for example. At that point, it becomes necessary to do the CSV parsing yourself just so that links can be parsed correctly. Of course, the other workaround is to avoid punctuation in headers.

DQL

No response

JS

No response

Dataview Version

0.5.64

Obsidian Version

1.5.3

OS

MacOS

PabloEscodebar commented 8 months ago

On Windows I get the same problem. If there are multiple headers that only differ by punctuation, the link doesnt break but it will link to the wrong section (the first one).

With file "test.md" containing:

## Heading!!
- [ ] task A
## Heading
- [ ] task B

Then a dataviewjs block:

let result = await dv.query("TASK FROM \"test\"");
let task = result.value.values[1];
dv.taskList([task], false);
dv.paragraph(task.section);

renders task B, but a link to the section of task A. using Head'ing and Heading would still break but not Head'ing and Head ing since the punctuation is replaced with a space (same for Head!ing and Head?ing)

Hope this helps

Dataview Version

0.5.64

Obsidian Version

1.5.3

OS

Windows