neorg-utils

Scripts

Parse neorg TODO's

Parent: neorg.

TODO

Code

#tangle todos.nu

def todos [path: path = ./.] {
  rg '\(.\)' --json $path
  | lines
  | each {|| from json}
  | filter {|e| $e.type == 'match'}
  | each {||
    get data
    | reject absolute_offset
    | update lines {||
      get text
      | str replace --regex '^.*\(.\)\s+' ""
    }
    | update submatches {|| get 0.match.text}
    | update path {|| get text}
  }
  | rename file text line status
  | move text --after status
}

Parse neorg graph

TODO

Code

#tangle graph.nu

def graph [where: path = .] {
  rg '\{./[a-z\-]*.html}[[a-z\-]*]' --json
  | lines
  | each {|| from json}
  | filter {|e| $e.type == 'match' }
  | each {||
    get data
    | update path {|| get text}
    | reject lines line_number absolute_offset
    | update submatches {||
      get 0.match.text
      | str replace -r '\{./(.*).html}[(.*)]' '$1'
    }
  }
  | rename from to
  | update from {|| str replace '.norg' '' }
  | reduce --fold '' {|it, acc| $acc + $'"($it.from)" -> "($it.to)"' + "\n"}
  | $"digraph G {\n($in)}"
  | dot -Tpng
  | feh -
}