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

Reorder Table Tokens properties #2165

Closed
calculuschild opened this issue Aug 6, 2021 · 3 comments
Closed

Reorder Table Tokens properties #2165

calculuschild opened this issue Aug 6, 2021 · 3 comments
Labels
RR - refactor & re-engineer Results in an improvement to developers using Marked, or end-users, or both.

Comments

@calculuschild
Copy link
Contributor

calculuschild commented Aug 6, 2021

Working on some custome extensions, I've noticed that Tables seem to be the only token with an odd use of it's tokens parameter. Instead of being an array of tokens, it's instead an object which then contains two token arrays (header and cells). This means we have an odd special case that we have to handle in walktokens for example, and becomes confusing when writing an extension.

I think it would make sense to reorder these properties to follow the format of other tokens to change

tokens = {
  header : [ ],
  cells : [ ]
}

into

header.tokens = [ ];
cells.tokens = [ ];

This better follows the convention of other similar tokens with "sub-tokens" (e.g. Lists contain list items, which then contain tokens, rather than the list having a tokens object containing all the items). Lists are also a weird special case, but we might as well handle both special cases in the same way, and enforce that at least in our implementation, tokens always means an array of tokens.

This wouldn't change functionality, but just provide consistency between tokens.

Changes the token signature of Tables so maybe we can squeeze into version 3.0?

@calculuschild calculuschild added the RR - refactor & re-engineer Results in an improvement to developers using Marked, or end-users, or both. label Aug 6, 2021
@UziTech
Copy link
Member

UziTech commented Aug 7, 2021

I think I would be ok with it. So tokens is always just an array of tokens.

@calculuschild
Copy link
Contributor Author

Right. We are on the same page then. 👍

@calculuschild
Copy link
Contributor Author

Fixed by #2166

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RR - refactor & re-engineer Results in an improvement to developers using Marked, or end-users, or both.
Projects
None yet
Development

No branches or pull requests

2 participants