KristopherGBaker / Maaku

The Maaku framework provides a Swift wrapper around cmark with the addition of a Swift friendly representation of the AST
MIT License
52 stars 12 forks source link

ListItem.attributedText: is this the desired behavior? #32

Open NightFlyer opened 5 years ago

NightFlyer commented 5 years ago

If there are nested lists, then the attributedText() for the ListItem includes all the sub-lists as well.

For example, with this document:

- list 1
  a paragraph inside list one, followed by:
  - embedded list
  - another embedded item
    1. ordered list inside
    1. another ordered item
  - third embedded item
- second item in top list

The first ListItem has a attributedText value of list 1 a paragraph inside list one, followed by:• embedded list• another embedded item1. ordered list inside2. another ordered item• third embedded item because it includes all blocks under the list item.

I'm not sure if that is what you really want, but I wonder how useful that is.

I'm not sure what you really had in mind for the use of attributedText(), so maybe this fits with what you had in mind.

For my usage, however, it would be more useful to have some version of attributedText() that didn't descend into sublists.

So, this issue is mostly a placeholder for you to either state that this is your desired behavior, or to open the issue of what other behavior might be desired.

KristopherGBaker commented 5 years ago

I think this is related to #18. I see the default behavior of attributedText() to fully render the lists and sublists recursively with appropriate new lines and indentation (which it does not currently do correctly), with some type of options or rendering/behavior protocol parameter that can be passed to it if different behavior is desired (such as in lists/sublists in your case). Please let me know if you have any ideas on how best to achieve this, and I will think about it as well.

NightFlyer commented 5 years ago

It's good to know that you see attributedText() as rendering the entire Block element, including anything included in it. I'll have to think about what would be the best solution for people who only want partial rendering (for example, if you are displaying a document "collapsed" and expand each element as the user chooses). It might be to have different version of attributedText() with parameters, or it might just be that the desired rendering would just be too different for each case, and so the best thing to do would be to have some examples of how people could extend things to make it work out.

KristopherGBaker commented 5 years ago

Yeah, my personal use of the framework didn't call attributedText() on block elements, but if a user wanted to call attributedText() on a block element, then that's how I see it working; rendering the entire block element including anything in it.