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

there's no loose_item_end token #469

Closed
notslang opened this issue Aug 9, 2014 · 3 comments
Closed

there's no loose_item_end token #469

notslang opened this issue Aug 9, 2014 · 3 comments

Comments

@notslang
Copy link

notslang commented Aug 9, 2014

Just wanted to mention that I found this pretty odd since we have a loose_item_start. Any particular reason for this?

@notslang
Copy link
Author

Actually, it's probably more accurate to say that loose_item_start is terminated by list_item_end, which is equally weird. Right now I'm using this code as a workaround:

  # there is no `loose_item_end` token, so we need to make it. thankfully, it's
  # pretty easy to determine where they go, by finding `list_item_end` wherever
  # there's an unclosed `loose_item`
  openLooseItem = false
  ast = ast.map (token) ->
    if token.type is 'loose_item_start'
      openLooseItem = true
    else if token.type is 'list_item_end' and openLooseItem
      openLooseItem = false
      # replace the list_item_end with loose_item_end
      token = type: 'loose_item_end'
    return token

@UziTech
Copy link
Member

UziTech commented Jun 28, 2018

@slang800 Is there any reason there needs to be a loose_item_end? Can you give an example of where it would be helpful to know at the end of a list item whether it was loose or not?

@notslang
Copy link
Author

It's been awhile since I worked with marked, so I don't remember exactly what I was doing, but I'm pretty sure I had a function that looked for every token that was a *_start or *_end and matched them together to form a simple syntax tree.

The fact that loose_item_start isn't terminated by a loose_item_end adds extra complexity to those types of functions. Rather than just looking for tokenType + "_start" or tokenType + "_end", I need to add a special case that handles loose_item_* tokens differently.

zhenalexfan pushed a commit to zhenalexfan/MarkdownHan that referenced this issue Nov 8, 2021
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