Skip to content

Commit

Permalink
Improved and separated ledger and beancount syntaxes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaJack authored and Efreak committed Sep 28, 2023
1 parent 1d09d01 commit 1b0fcbf
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
20 changes: 20 additions & 0 deletions beancount.nanorc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax "Beancount" "(^|\.|/)beancount|bnct|bc$"

# directives
color red "^([0-9]{4}-[0-9]{2}-[0-9]{2} | )?[a-z-]+( |: )"
# dates
color blue "^[0-9]{4}-[0-9]{2}-[0-9]{2}"
# tags
color green "#\S+"
# links
color blue "\^\S+"
# accounts
color cyan "(\t| )\b\w*-?\w*(:\w*-?\w*){1,}\b"
# currencies and stocks
color cyan "\b[A-Z]+\b"
# double quotes and transaction flags
color red "[*!@\"]"
# text within double quotes
color pink "\"(.*?)\""
# comments
color brightblack "(^|\s);.*"
19 changes: 13 additions & 6 deletions ledger.nanorc
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
syntax "Ledger" "((^|\.|/)ledger|ldgr|beancount|bnct)$"

color brightmagenta "^([0-9]{4}(/|-)[0-9]{2}(/|-)[0-9]{2}|[=~]) .*"
color blue "^[0-9]{4}(/|-)[0-9]{2}(/|-)[0-9]{2}"
# descriptions
color brightmagenta "^(([0-9]{4}(/|-|.))?[0-9]{2}(/|-|.)[0-9]{2}|[=~]) .*"
# dates
color blue "^([0-9]{4}(\/|-|.))?[0-9]{2}(\/|-|.)[0-9]{2}"
# balance
color brightyellow "^~ .*"
color brightblue "^= .*"
color cyan "^[[:space:]]+(![[:space:]]+)?\(?[A-Za-z ]+(:[A-Za-z ]+)*\)?"
color cyan "^[[:space:]]+(![[:space:]]+)?\(?[A-Za-z_-]+(:[A-Za-z_-]+)*\)?"
color red "[*!]"
color brightblack "^[[:space:]]*;.*"
# accounts
color cyan "(\t| )\b\w*\ ?\w*(:\w*\ ?\w*\w*){1,}\b"
# double quotes and transaction flags
color red "[*!@\"]"
# text within double quotes
color pink "\"(.*?)\""
# comments
color brightblack "(^|\s)(;|#|%|\|).*"

0 comments on commit 1b0fcbf

Please sign in to comment.