Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task support #68

Open
1 of 3 tasks
tommyengstrom opened this issue Feb 19, 2020 · 1 comment
Open
1 of 3 tasks

Task support #68

tommyengstrom opened this issue Feb 19, 2020 · 1 comment

Comments

@tommyengstrom
Copy link

I would like to support tasks, just as we have available here in github:

  • Like this
  • and this

I was hoping to be able to do this using the extension module but as far as I understand it that can't be done. - [ ] ends up being parsed as a broken link. Is is possible to do this as an extension?

If not, and if you're interested in having this feature, can you give me some hint on how to add it?

in GFMD it seems there is (somewhat shaky) support for task in numbered lists, e.g.

1. [ ] Numbered task
2. not numbered
3 [x] completed 

renders as

  1. Numbered task
  2. not numbered
    3 [x] completed

I never tried that before right now, I wouldn't implement it unless I had to.

However, the Block constructor for Unordered lists is UnorderedList (NonEmpty [Block a]), but tasks are only really supported in lists. The natural way seem to be wrapping the Block a ref in something that can tell if it a normal block, unfinished task, or finished task. Is there a better solution? Would that solution be accepted?

@alexjercan
Copy link

To be fair I would implement this directly into Parser.hs. My only problem is should tasks be nodes or just inlines (i.e should tasks just be unordered lists and then have another constructor Task for Inline, or should we have a completely separate node, TaskList).

If going for inlines I would say to have a pTask parser like this

-- | Parse a Task.
pTask :: IParser Inline
pTask = do
  void (char '[')
  checked <- (True <$ char 'x') <|> (False <$ char ' ')
  void (char ']')
  sc'
  txt <- disallowEmpty pInlines
  Task checked txt <$ lastChar OtherChar

and adding the Task into the Inline data type like this

data Inlines =
  ...
  | -- | Task with status and description
    Task Bool (NonEmpty Inline)

then in the pInlines :: IParser (NonEmpty Inline) function on the [ case should have a call to it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants