Skip to content

Reorder Table Tokens properties  #2165

Closed
@calculuschild

Description

@calculuschild

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    RR - refactor & re-engineerResults in an improvement to developers using Marked, or end-users, or both.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions