No description
Find a file
2025-04-16 13:44:50 +03:00
.github/workflows Add release workflow 2025-04-16 13:44:50 +03:00
src fix: use singular word in notification when there is only one match 2025-04-13 21:13:13 +03:00
.eslintignore Initial commit, main functionality 2025-04-12 22:33:38 +03:00
.eslintrc chore: add new rules for eslint errors 2025-04-13 00:17:05 +03:00
.gitignore Initial commit, main functionality 2025-04-12 22:33:38 +03:00
LICENSE Initial commit, main functionality 2025-04-12 22:33:38 +03:00
manifest.json chore: update description and name 2025-04-13 07:45:05 +03:00
package-lock.json chore: update description and name 2025-04-13 07:45:05 +03:00
package.json chore: update description and name 2025-04-13 07:45:05 +03:00
README.md docs: update README.md, add demos 2025-04-15 04:49:26 +03:00
styles.css Initial commit, main functionality 2025-04-12 22:33:38 +03:00
tsconfig.json Initial commit, main functionality 2025-04-12 22:33:38 +03:00
version-bump.mjs Initial commit, main functionality 2025-04-12 22:33:38 +03:00
versions.json Initial commit, main functionality 2025-04-12 22:33:38 +03:00
vite.config.ts chore: update outDir 2025-04-13 11:12:22 +03:00

MatchSyntax for Obsidian

A flexible, "regex-like" lookups for your notes, using the compromise match syntax.

MatchSyntax will highlight the parts of the text in your active note that match your "match-syntax" query.

Examples

Part-of-speech tags can be used for searches of grammatical parts in a note. The syntax for looking for all the adjectives followed by plural words can look like this:

https://github.com/user-attachments/assets/ff264c14-853b-473a-8b8d-c3d76994bd9a

You can do regex searches with // syntax. Let's say we want to look for any word that starts with natur and is followed by either e or al:

https://github.com/user-attachments/assets/f10bc077-7240-44c4-8aa0-0d332e20dcb6

It's always advised to be careful with regex. This will also be slower than other types of lookups.

MatchSyntax is flexible, so you can combine different types of matches. Let's say we first searched for all nouns that are followed after the word "spiritual." Then, we might realize we don't want the plural nouns. So instead, we can use an AND syntax (&&) and negative matching (!) to indicate we want to exclude plural nouns:

https://github.com/user-attachments/assets/89b3b70b-a7f9-47c8-b542-c88d7200d301

Note

MatchSyntax heavily depends on the compromise library. The matching works only with English grammar; although compromise has some "work-in-progress" for other languages, there is only English support for this plugin at the moment.

Types of matches

MatchSyntax supports most types of compromise matches that are listed below, you can also check out its documentation.

Word-matches

Direct lookups.

Tag-matches (#)

Lookups using part-of-speech tagging.

Supported tags:

#Noun
    #Singular
        #Person
            #FirstName
                #MaleName
                #FemaleName
            #LastName
    #Place
        #Country
        #City
        #Region
        #Address
    #Organization
        #SportsTeam
        #Company
        #School
    #ProperNoun
    #Honorific
    #Plural
    #Uncountable
    #Pronoun
    #Actor
    #Activity
    #Unit
    #Demonym
    #Possessive
#Verb
    #PresentTense
        #Infinitive
        #Gerund
    #PastTense
    #PerfectTense
    #FuturePerfect
    #Pluperfect
    #Copula
    #Modal
    #Participle
    #Particle
    #PhrasalVerb
#Value
    #Ordinal
    #Cardinal
        #RomanNumeral
    #Multiple
    #Fraction
    #TextValue
    #NumericValue
    #Percent
    #Money
#Date
    #Month
    #WeekDay
    #RelativeDay
    #Year
    #Duration
    #Time
    #Holiday
#Adjective
    #Comparable
    #Comparative
    #Superlative
#Contraction
#Adverb
#Currency
#Determiner
#Conjunction
#Preposition
#QuestionWord
#Pronoun
#Expression
#Abbreviation
#Url
#HashTag
#PhoneNumber
#AtMention
#Emoji
#Emoticon
#Email
#Auxiliary
#Negative
#Acronym

See more in the compromise documentation.

Wildcard-matches (./*)

The . character means any one term.

The * character means zero or more terms.

Greedy-match (+)

The+ character at the end of a tag (or .) implies the match will continue with repeated consecutive matches, as far as it can.

Optional matching (?)

The ? character at the end of a word means it is nice to have, but not necessary.

Options list (OR logic)

(word1|word2) parentheses allow listing possible matches for the word (OR logic).

RegEx-match (/<reg>/)

JavaScript regular-expressions using the /myregex/ syntax.

Note: RegEx matches should be carefully used as they can be slower than other types of lookups.

First/Last (^/$)

Something should be in the start, or end of a match.

Negative (!)

Something not-match with a leading ! character.

Range ({min,max})

A maximum, minimum number of wildcard terms.

Prefix, suffix, infix

Sub-word matches, with the regex / / characters.

AND logic (&&)

AND logic using two match statements.

@ methods

  • @hasQuote
  • @hasComma
  • @hasPeriod
  • @hasExclamation
  • @hasQuestionMark
  • @hasEllipses
  • @hasSemicolon
  • @hasColon
  • @hasSlash
  • @hasHyphen
  • @hasDash
  • @hasContraction
  • @isAcronym
  • @isKnown
  • @isUpperCase
  • @isTitleCase

Fuzzy-matches (~)

Text-matching using ~ characters. DamerauLevenshtein distance is used to compute approximate string matches.

See more in the compromise documentation.

Installation

In Obsidian, you can go to SettingsCommunity pluginsBrowse. Then, search for "MatchSyntax" and click Install.

Or, alternatively, you can clone this repository, and move it to your vault's .obsidian/plugins directory. From there, run:

npm run build

Then, go to SettingsCommunity plugins, and activate MatchSyntax under Installed Plugins.

Usage

MatchSyntax provides two commands: "Enter match syntax" and "Clear match highlights." You can choose "Enter match syntax" to write your syntax and click "Find matches" to see the matched parts of the active note.

You can bind hotkeys for the commands by going to Community plugins, find MatchSyntax in Installed Plugins, and choosing "Hotkeys" button.

At the moment, highlights will stay until you explicitly clear them.

TODO and Ideas

  • Custom tags
  • Add setting to display the number of matches in the status bar
  • Add a widget to the editor for input and clearing highlights

License

GPLv3