Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: No3371/obsidian-regex-pipeline
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.4.0
Choose a base ref
...
head repository: No3371/obsidian-regex-pipeline
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 3 commits
  • 1 file changed
  • 1 contributor

Commits on Feb 13, 2023

  1. 📝 Readme

    No3371 committed Feb 13, 2023
    Copy the full SHA
    1a9cd35 View commit details

Commits on Feb 28, 2023

  1. Update README.md

    No3371 authored Feb 28, 2023
    Copy the full SHA
    10e2122 View commit details

Commits on Mar 11, 2023

  1. Update README.md

    No3371 authored Mar 11, 2023
    Copy the full SHA
    b4815ec View commit details
Showing with 27 additions and 33 deletions.
  1. +27 −33 README.md
60 changes: 27 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -8,17 +8,25 @@ Regex Pipeline is an [Obsidian](https://obsidian.md/) plugin that allows users t

![](https://raw.githubusercontent.com/No3371/obsidian-regex-pipeline/master/assets/regex-pipeline-newmenu.gif)

## Latest Update: v1.3
## Usage

> [Mr. Partan](www.lpartan.com) provided a nice [writeup](https://gist.github.com/No3371/f1750b178376f0659df6650ccaf57c12) about how to use the plugin, I recommend it if you are not familiar with regex or software usage. (September 2021, v1.0.9)
First, enable the plugin, a file named index.txt should be created at `.obsidian/regex-rulesets/`. Due to how Obsidian protects your disks, you have to specify what ruleset files are there to be read, that's why we need a index file.

Starting from version 1.0.8, you can add rulesets through the + button in the menu, but you still have to go to `.obsidian/regex-rulesets/` and modify the files you want to edit/remove, because it's hard to provide good editing experience that rivals common editors like VSCode.

1. `x` is no longer needed to replace with nothing (Previous rules won't break, `x` still works).
Starting from version 1.1.0, you can apply rulesets via the right-click menu. The available option count can be adjusted in the settings.

Starting from version 1.2.0, quick rulesets (mentioned right above) can be invoked through Obsidian's command system when "Quick Commands" are set to above 0 in the settings.

#### Writing Rulesets
A ruleset contains one or more rule, the format looks like:
```
:: Any "SEARCH" becomes ""
"SEARCH"->""
:: Any "SEARCH" becomes "REPLACE"
"SEARCH"->"REPLACE"
```

2. Now supports flexier formats. Readibility++

✅ These work:
```
"SEARCH"->"REPLACE"
@@ -62,26 +70,6 @@ Regex Pipeline is an [Obsidian](https://obsidian.md/) plugin that allows users t
"REPLACE"
```

## Usage

> [Mr. Partan](www.lpartan.com) provided a nice [writeup](https://gist.github.com/No3371/f1750b178376f0659df6650ccaf57c12) about how to use the plugin, I recommend it if you are not familiar with regex or software usage. (September 2021, v1.0.9)
First of all, enable the plugin, a file named index.txt should be created at `.obsidian/regex-rulesets/`. Due to how Obsidian protects your disks, you have to specify what ruleset files are there to be read, that's why we need a index file.

Starting from 1.0.8, a in-app "add ruleset" funtionality is included. you can add rulesets through the + button in the menu, but you still have to go to `.obsidian/regex-rulesets/` and modify the files you want to edit/remove, mainly because any UI to change what's already on your disk is not safe, also because it's hard to provide good editing experience as common editors(ex: VSCode).

Starting from 1.1.0, you can apply rulesets through right-click menu. The available option count can be adjusted in settings.

Starting from 1.2.0, the quick rulesets (mentioned right above) can be invoked through Obsidian's command system after **Quick Commands** is toggled on in settings.

#### Writing Rulesets
Now you can start editing your own rule sets.
A ruleset contains one or more rule, the format looks like:
```
:: Any "SEARCH" becomes "REPLACE"
"SEARCH"->"REPLACE"
```

#### Multi-line replacement string:
```
"SEARCH"->"REP
@@ -99,23 +87,22 @@ By default, `gm` (multiline) flag is appended to the **SEARCH** regex, you can o
Noted that `gm` flags are bascially neccessary for this plugin to be useful, you seldom wants to replace only 1 occurances or operate on a note only contains 1 line.

#### Replace With Nothing
Due to how the plugin parse rules, the replacement string can not be a length zero string, if you want to delete with regex (replace with ""), you have to add a custom `x` flag:
```
"SEARCH"->"REPLACE"x
"SEARCH"->""
:: Any "SEARCH" becomes ""
```
In this case, whatever REPLACE is, the plugin treat it as "".
Basically this is how we remove matched content.


#### Indexing
Rulesets must be saved in `.obsidian/regex-rulesets/`, and have to be included in the `index.txt`, one file per line. The order also decides the displaying order in-app.
Rulesets must be saved in `.obsidian/regex-rulesets/`, and must be included in the `index.txt`, one file per line. The order of the lines determines the displaying order of the rulesets in the menu.

#### Applying Rulesets
Press the sidebar button of this plugin to show the rulesets menu, select your ruleset then it'll apply.
Press the sidebar button of this plugin to show the rulesets menu, select your ruleset, and it'll be applied.

The menu is a command so you can also bind it to a shortcut.
The menu is available as a command so you can also bind it to a shortcut.

**Note**: The plugin support applying rules to selection only, if anything is selected, only selection is modified!
**Note**: The plugin support applying rules to selection, if anything is selected, only selection is modified!

## Examples

@@ -141,6 +128,13 @@ This ruleset help you transform selected content into a table of 2 columns! Ever
"^(.+)$\n\n^(.+)$"->"| $1 | $2 |"
```

**Linebreak with br tag**
This ruleset replace all newline with `<br>`.

```
"^(.+)\s+?\n(?=^.+)"->"$1<br>"
```

Take a look in [samples folder](https://github.com/No3371/obsidian-regex-pipeline/tree/master/samples) for more examples, including a very complex one like the above gif!

## Recommendations