Skip to content

Commit

Permalink
Merge pull request #1020 from pjkaufman/master
Browse files Browse the repository at this point in the history
Release Prep with Docs
  • Loading branch information
pjkaufman authored Feb 25, 2024
2 parents 0e704c5 + 69dce69 commit b0e4884
Show file tree
Hide file tree
Showing 5 changed files with 255 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ Each rule is its own set of logic and is designed to be run independently. This
### YAML rules

- [add-blank-line-after-yaml](https://platers.github.io/obsidian-linter/settings/yaml-rules/#add-blank-line-after-yaml)
- [dedupe-yaml-array-values](https://platers.github.io/obsidian-linter/settings/yaml-rules/#dedupe-yaml-array-values)
- [escape-yaml-special-characters](https://platers.github.io/obsidian-linter/settings/yaml-rules/#escape-yaml-special-characters)
- [force-yaml-escape](https://platers.github.io/obsidian-linter/settings/yaml-rules/#force-yaml-escape)
- [format-tags-in-yaml](https://platers.github.io/obsidian-linter/settings/yaml-rules/#format-tags-in-yaml)
- [format-yaml-array](https://platers.github.io/obsidian-linter/settings/yaml-rules/#format-yaml-array)
- [insert-yaml-attributes](https://platers.github.io/obsidian-linter/settings/yaml-rules/#insert-yaml-attributes)
- [move-tags-to-yaml](https://platers.github.io/obsidian-linter/settings/yaml-rules/#move-tags-to-yaml)
- [remove-yaml-keys](https://platers.github.io/obsidian-linter/settings/yaml-rules/#remove-yaml-keys)
- [sort-yaml-array-values](https://platers.github.io/obsidian-linter/settings/yaml-rules/#sort-yaml-array-values)
- [yaml-key-sort](https://platers.github.io/obsidian-linter/settings/yaml-rules/#yaml-key-sort)
- [yaml-timestamp](https://platers.github.io/obsidian-linter/settings/yaml-rules/#yaml-timestamp)
- [yaml-title](https://platers.github.io/obsidian-linter/settings/yaml-rules/#yaml-title)
Expand Down
250 changes: 250 additions & 0 deletions docs/docs/settings/yaml-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,153 @@ Here is some text
``````
</details>

## Dedupe YAML Array Values

Alias: `dedupe-yaml-array-values`

Removes duplicate array values in a case sensitive manner.

### Options

| Name | Description | List Items | Default Value |
| ---- | ----------- | ---------- | ------------- |
| `Dedupe YAML aliases section` | Turns on removing duplicate aliases. | N/A | `true` |
| `Dedupe YAML tags section` | Turns on removing duplicate tags. | N/A | `true` |
| `Dedupe YAML array sections` | Turns on removing duplicate values for regular YAML arrays | N/A | `true` |
| `YAML Keys to Ignore` | A list of YAML keys without the ending colon on their own lines that are not meant to have duplicate values removed from them. | N/A | |



### Examples

<details><summary>Dedupe YAML tags is case sensitive and will use your default format for tags.</summary>

Before:

`````` markdown
---
tags: [computer, research, computer, Computer]
aliases:
- Title 1
- Title2
---
``````

After:

`````` markdown
---
tags: [computer, research, Computer]
aliases:
- Title 1
- Title2
---
``````
</details>
<details><summary>Dedupe YAML aliases is case sensitive and will use your default format for aliases.</summary>

Before:

`````` markdown
---
tags: [computer, research]
aliases:
- Title 1
- Title2
- Title 1
- Title2
- Title 3
---
``````

After:

`````` markdown
---
tags: [computer, research]
aliases:
- Title 1
- Title2
- Title 3
---
``````
</details>
<details><summary>Dedupe YAML array keys is case sensitive and will try to preserve the original array format.</summary>

Before:

`````` markdown
---
tags: [computer, research]
aliases:
- Title 1
- Title2
arr1: [val, val1, val, val2, Val]
arr2:
- Val
- Val
- val
- val2
- Val2
---
``````

After:

`````` markdown
---
tags: [computer, research]
aliases:
- Title 1
- Title2
arr1: [val, val1, val2, Val]
arr2:
- Val
- val
- val2
- Val2
---
``````
</details>
<details><summary>Dedupe YAML respects list of keys to not remove duplicates of for normal arrays (keys to ignore is just `arr2` for this example)</summary>

Before:

`````` markdown
---
tags: [computer, research]
aliases:
- Title 1
- Title2
arr1: [val, val1, val, val2, Val]
arr2:
- Val
- Val
- val
- val2
- Val2
---
``````

After:

`````` markdown
---
tags: [computer, research]
aliases:
- Title 1
- Title2
arr1: [val, val1, val2, Val]
arr2:
- Val
- Val
- val
- val2
- Val2
---
``````
</details>

## Escape YAML Special Characters

Alias: `escape-yaml-special-characters`
Expand Down Expand Up @@ -685,6 +832,109 @@ Text
``````
</details>

## Sort YAML Array Values

Alias: `sort-yaml-array-values`

Sorts YAML array values based on the specified sort order.

### Options

| Name | Description | List Items | Default Value |
| ---- | ----------- | ---------- | ------------- |
| `Sort YAML aliases section` | Turns on sorting aliases. | N/A | `true` |
| `Sort YAML tags section` | Turns on sorting tags. | N/A | `true` |
| `Sort YAML array sections` | Turns on sorting values for regular YAML arrays | N/A | `true` |
| `YAML Keys to Ignore` | A list of YAML keys without the ending colon on their own lines that are not meant to have their values sorted. | N/A | |
| `Sort Order` | The way to sort the YAML array values. | `Ascending Alphabetical`: Sorts the array values from a to z<br/><br/>`Descending Alphabetical`: Sorts the array values from z to a | `Ascending Alphabetical` |



### Examples

<details><summary>Sorting YAML array values alphabetically</summary>

Before:

`````` markdown
---
tags: [computer, research, androids, Computer]
aliases:
- Title 1
- Title 2
---
``````

After:

`````` markdown
---
tags: [androids, computer, Computer, research]
aliases:
- Title 1
- Title 2
---
``````
</details>
<details><summary>Sorting YAML array values to be alphabetically descending</summary>

Before:

`````` markdown
---
tags: [computer, research, androids, Computer]
aliases:
- Title 1
- Title 2
---
``````

After:

`````` markdown
---
tags: [research, Computer, computer, androids]
aliases:
- Title 2
- Title 1
---
``````
</details>
<details><summary>Sort YAML Arrays respects list of keys to not sort values of for normal arrays (keys to ignore is just `arr2` for this example)</summary>

Before:

`````` markdown
---
tags: [computer, research]
aliases:
- Title 1
- Title 2
arr1: [val, val2, val1]
arr2:
- val
- val2
- val1
---
``````

After:

`````` markdown
---
tags: [computer, research]
aliases:
- Title 1
- Title 2
arr1: [val, val1, val2]
arr2:
- val
- val2
- val1
---
``````
</details>

## YAML Key Sort

Alias: `yaml-key-sort`
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-linter",
"name": "Linter",
"version": "1.22.0",
"version": "1.23.0",
"minAppVersion": "1.4.16",
"description": "Formats and styles your notes. It can be used to format YAML tags, aliases, arrays, and metadata; footnotes; headings; spacing; math blocks; regular markdown contents like list, italics, and bold styles; and more with the use of custom rule options as well.",
"author": "Victor Tao",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-linter",
"version": "1.22.0",
"version": "1.23.0",
"description": "Enforces consistent markdown styling for Obsidian (https://obsidian.md). It can be used to format YAML tags, aliases, arrays, and metadata; footnotes; headings; spacing; math blocks; regular markdown contents like list, italics, and bold styles; and more with the use of custom rule options as well.",
"main": "main.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"1.23.0": "1.4.16",
"1.22.0": "1.4.16",
"1.21.0": "1.4.16",
"1.20.1": "1.4.16",
Expand Down

0 comments on commit b0e4884

Please sign in to comment.