Skip to content

Commit

Permalink
Fix #13
Browse files Browse the repository at this point in the history
  • Loading branch information
scottwillmoore committed Aug 11, 2023
1 parent b096c11 commit 5c6193d
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 57 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.4] - 2023-08-11

### Changed

- Revert changes from 1.1.3.

## [1.1.3] - 2023-06-23

### Changed
Expand Down Expand Up @@ -84,6 +90,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Project settings for Visual Studio Code.
- A [`README.md`](./README.md) and a [`LICENSE`](./LICENSE).

[1.1.4]: https://github.com/scottwillmoore/obsidian-short-internal-links-to-headings/releases/tag/v1.1.4
[1.1.3]: https://github.com/scottwillmoore/obsidian-short-internal-links-to-headings/releases/tag/v1.1.3
[1.1.2]: https://github.com/scottwillmoore/obsidian-short-internal-links-to-headings/releases/tag/v1.1.2
[1.1.1]: https://github.com/scottwillmoore/obsidian-short-internal-links-to-headings/releases/tag/v1.1.1
[1.1.0]: https://github.com/scottwillmoore/obsidian-short-internal-links-to-headings/releases/tag/v1.1.0
[1.0.2]: https://github.com/scottwillmoore/obsidian-short-internal-links-to-headings/releases/tag/v1.0.2
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Expand Up @@ -3,7 +3,7 @@
"name": "Short links",
"description": "An Obsidian plugin to display short internal links.",
"author": "Scott Moore",
"version": "1.1.3",
"version": "1.1.4",
"minAppVersion": "1.1.1",
"isDesktopOnly": false
}
21 changes: 0 additions & 21 deletions notes/Dataview.md

This file was deleted.

3 changes: 3 additions & 0 deletions notes/Issue 13.md
@@ -0,0 +1,3 @@
# Heading 1

[[Issue 13#Heading 1]]
19 changes: 0 additions & 19 deletions notes/Tables.md

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -4,7 +4,7 @@
"description": "An Obsidian plugin to display short internal links.",
"author": "Scott Moore",
"license": "MIT",
"version": "1.1.3",
"version": "1.1.4",
"scripts": {
"build": "node --require esbuild-register scripts/build.ts",
"format": "prettier --write .",
Expand Down
17 changes: 3 additions & 14 deletions sources/markdownPostProcessor.ts
Expand Up @@ -33,24 +33,13 @@ export const createMarkdownPostProcessor: CreateMarkdownPostProcessor = (plugin)
const link = linkElement.getAttribute("href");
if (link === null) continue;

// NOTE: There is no easy way to detect whether a link is an alias or
// not. At the moment, the only way to detect whether a link is an
// alias is to check whether the `aria-label` attribute exists.
// However, this does not work in rare cases, for example in the
// Dataview plugin. Therefore, we also must check whether the
// attribute is different from the link text and also strip any file
// names! At the moment we just remove all instances of `.md`, however
// this is not a perfect solution.

const ariaLabel = linkElement.getAttribute("aria-label");
const expectedText = ariaLabel?.replace(".md", "");
const isAlias = expectedText !== linkElement.getText();
const isAlias = linkElement.hasAttribute("aria-label");

const internalLink = parseInternalLink(link);

if (configuration.shortLinksToFiles && !isAlias) {
const fileBaseText = sliceText(link, internalLink.fileBase);
linkElement.setText(fileBaseText);
const fileNameText = sliceText(link, internalLink.fileName);
linkElement.setText(fileNameText);
}

switch (internalLink.type) {
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Expand Up @@ -5,5 +5,6 @@
"1.1.0": "1.1.1",
"1.1.1": "1.1.1",
"1.1.2": "1.1.1",
"1.1.3": "1.1.1"
"1.1.3": "1.1.1",
"1.1.4": "1.1.1"
}

0 comments on commit 5c6193d

Please sign in to comment.