jmhobbs / jsTodoTxt

JavaScript parser for todo.txt formatted text files.
https://jstodotxt.velvetcache.org
MIT License
67 stars 14 forks source link

Priority not parsed correctly? #39

Open tokyovigilante opened 1 year ago

tokyovigilante commented 1 year ago

Using jsTodoTxt in a server-based todo project, and noting that priorities do not seem to be correctly parsed, for example:

(A) Get 12mm M4 screws +Sling @online

[
    "(A) Get 12mm M4 screws +Sling @online",
    null,
    null,
    null,
    null,
    null,
    null,
    null,
    null,
    null,
    "(A) Get 12mm M4 screws +Sling @online"
]

I would expect priority A to be in match[4] but it is null.

jmhobbs commented 1 year ago

Hello, sorry for the delay in getting to your issue.

What version of the library are you using? I just pulled down 0.10.0 and it seems to parse OK:

> const { TodoTxt, TodoTxtItem } = require('./jsTodoTxt.js');
undefined
> t = new TodoTxtItem('(A) Get 12mm M4 screws +Sling @online')
TodoTxtItem {
  reset: [Function (anonymous)],
  dateString: [Function (anonymous)],
  completedString: [Function (anonymous)],
  toString: [Function (anonymous)],
  extensionStrings: [Function (anonymous)],
  parse: [Function (anonymous)],
  _getNumOfNulls: [Function (anonymous)],
  _arraysAreEqual: [Function (anonymous)],
  _datesAreEqual: [Function (anonymous)],
  equals: [Function (anonymous)],
  extensions: null,
  text: 'Get 12mm M4 screws',
  priority: 'A',
  complete: false,
  completed: null,
  date: null,
  contexts: [ 'online' ],
  projects: [ 'Sling' ]
}
> t.toString()
'(A) Get 12mm M4 screws +Sling @online'
>

Likewise with the current build on next

> const { Item } = require('./lib/index.js')
undefined
> i = new Item('(A) Get 12mm M4 screws +Sling @online')
Item {}
> i.priority()
'A'
> i.toString()
'(A) Get 12mm M4 screws +Sling @online'
>

Any more details would be helpful to find the issue.

Thanks!