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

Mathematical absolute value symbol (|) is interpreted as end of cell (cell separator) in a table #318

Closed
ram6ler opened this issue Nov 10, 2018 · 4 comments
Labels
Area: Math Area: Table GitHub Flavored Markdown table. Issue: Question Res: As expected The existing behavior is by design or as expected.

Comments

@ram6ler
Copy link

ram6ler commented Nov 10, 2018

What is the problem?

When an absolute value symbol (|) is used in a mathematical expression in a table, the markdown parser appears to trigger the closing of a cell rather than recognise the character as part of the math expression. (Markdown appears to be parsed before an expression bound by $ characters.)

(I notice that this is similar to the already closed Formatting - Wrong formatting when Table contains | issue.)

How can I reproduce it?

A simple example:

|Operation|`isEdge`|`listEdges`|`listVertices`|
|--:|:--:|:--:|:--:|
|Adjacency matrix|$\Theta(1)$|$\Theta(|V|^2)$|$\Theta(|V|)$|
                                      ^
                            (This | character triggers table 
                            cell completion - it is not
                            recognized as part of the math
                            expression.)

Is there any error message in the console?

No.

@yzhang-gh
Copy link
Owner

Thank you for pointing it out. It is kind of complex to tackle. For now, you can use \vert in place of | as a workaround.

@Lemmingh
Copy link
Collaborator

I'm sorry to say this behavior is required by the Spec.

The parsing strategy in CommonMark Spec says:

  • Parse block structures first, then inline structures.

The Tables in GFM Spec says:

  • A table is a leaf block.
  • A table cell can only contains inline elements.
  • Block-level elements cannot be inserted in a table.

Thus,

Table cell parsing must take higher precedence than inline math area parsing.


Sorry for the inconvenience. Please use \vert as described above.

@Lemmingh
Copy link
Collaborator

@yzhang-gh
There should be something wrong with our TM grammar, which leads to this misunderstanding. Would you please take a look?

@yzhang-gh
Copy link
Owner

Thanks.

But there doesn't seem to be an easy fix. The | doesn't have a specific color on its own (besides the general math highlight).

And it may not be worth it to create a special set of TM grammar for inline math inside a table cell.

image

@Lemmingh Lemmingh added Res: As expected The existing behavior is by design or as expected. and removed Res: Out of scope labels Aug 22, 2021
@Lemmingh Lemmingh changed the title Mathematics absolute values in a table: | interpreted as end of cell Mathematical absolute value symbol (|) is interpreted as end of cell (cell separator) in a table Aug 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Math Area: Table GitHub Flavored Markdown table. Issue: Question Res: As expected The existing behavior is by design or as expected.
Projects
None yet
Development

No branches or pull requests

3 participants