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

Support vertical lines in arrays #127

Open
jgm opened this issue Dec 12, 2018 · 12 comments
Open

Support vertical lines in arrays #127

jgm opened this issue Dec 12, 2018 · 12 comments

Comments

@jgm
Copy link
Owner

jgm commented Dec 12, 2018

\begin{array}{rrr|r}
1 & 0 & 0 & x\\
0&1&0&b\\
0&0&1&c
\end{array}

Currently we get

\begin{array}{rrr|r}
                 ^
unexpected "|"
expecting letter, white space or "}"

It would be nice if we could represent these vertical lines. (This would require changing the EArray type.) Second best, perhaps the | could just be skipped?

@jgm
Copy link
Owner Author

jgm commented Dec 12, 2018

MathJax produces this MathML, which works:

        <mtable columnalign="right right right right" rowspacing="4pt" 
columnspacing="1em" columnlines="none none solid"> 
          <mtr> 
...
          </mtr> 
        </mtable> 

@jgm
Copy link
Owner Author

jgm commented Dec 12, 2018

Without the |, pandoc produces:

<math display="block" xmlns="http://www.w3.org/1998/Math/MathML">
  <mtable>
    <mtr>
      <mtd columnalign="right">
        <mn>1</mn>
      </mtd>
      <mtd columnalign="right">
        <mn>0</mn>
      </mtd>
      <mtd columnalign="right">
        <mn>0</mn>
      </mtd>
      <mtd columnalign="right">
        <mi>x</mi>
      </mtd>
    </mtr>
    <mtr>
      <mtd columnalign="right">
        <mn>0</mn>
      </mtd>
      <mtd columnalign="right">
        <mn>1</mn>
      </mtd>
      <mtd columnalign="right">
        <mn>0</mn>
      </mtd>
      <mtd columnalign="right">
        <mi>b</mi>
      </mtd>
    </mtr>
    <mtr>
      <mtd columnalign="right">
        <mn>0</mn>
      </mtd>
      <mtd columnalign="right">
        <mn>0</mn>
      </mtd>
      <mtd columnalign="right">
        <mn>1</mn>
      </mtd>
      <mtd columnalign="right">
        <mi>c</mi>
      </mtd>
    </mtr>
  </mtable>
</math>

Obviously using the columnalign attribute on mtable is better. And if we represented the column lines, we could use columnlines as well.

@jgm
Copy link
Owner Author

jgm commented Dec 12, 2018

I don't see anything corresponding to columnlines in OMML.

jgm added a commit that referenced this issue Dec 12, 2018
We have no way to represent this in EArray, currently.
Ignoring them seems better than failing altogether.  See #127.
aweinstock314 added a commit to aweinstock314/texmath that referenced this issue Dec 29, 2020
- Add [ColumnSeparator] to EArray.
- Readers.MathML can generate any of {CSNone, CSDashed, CSSolid}, which should round-trip through Writers.MathML
- {Readers,Writers}.TeX only support {CSNone, CSSolid}
- Readers.OMML currently generates CSNone, and Writers.OMML doesn't emit ColumnSeparator information
@aweinstock314
Copy link

I've written preliminary support for this at aweinstock314@15a2192 .

This currently fails most of the tests because it adds additional information to Text.TeXMath.Types.EArray; what's the procedure for updating the tests/ensuring that the additions are the only change?

@jgm
Copy link
Owner Author

jgm commented Dec 29, 2020

make TESTARGS=--accept will update the tests with the current output.
We don't have a good system in place for ensuring that these changes are all sound, other than manual inspection -- sorry!

@aweinstock314
Copy link

I've updated the tests (and fixed a few bugs that looking at the ASTs revealed) in aweinstock314@c51c3fa .

Some of the tests already contain dashed/solid lines (e.g. mtableAlines1.mml, mlabeledtr1.mml), and the ASTs look right. They don't fully round trip because:

  1. They use some additional MathML features (e.g. frame, rowlines) that aren't supported yet (which is orthogonal to this issue).
  2. I expand the column separators to be equal to the number of columns minus one, and MathML treats a single-element columnlines as if it were repeated across the rows.

Should Writers.MathML re-compress columnlines (if they're all the same) to canonicalize?

@jgm
Copy link
Owner Author

jgm commented Dec 29, 2020

MathML treats a single-element columnlines as if it were repeated across the rows.

Where is that documented? I couldn't find it on quick search.

@aweinstock314
Copy link

I manually opened tests/src/mlabeledtr1.mml (which uses columnlines="solid" despite having 3 columns) in firefox, and the output was consistent with that interpretation.

It's not explicitly spelled out by https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mtable#attr-columnlines (though the phrasing "Multiple values separated by space are allowed" seems a bit odd otherwise).

@aweinstock314
Copy link

Found the phrasing in the spec: "In this context, a single value specifies the value to be used for all rows (resp., columns or gaps)."

https://www.w3.org/TR/MathML3/chapter3.html#presm.mtable

@jgm
Copy link
Owner Author

jgm commented Dec 29, 2020

Thanks. Yes, I think it would be best to collapse to the single value when they're all the same, if it's not too complicated to do it.

@aweinstock314
Copy link

aweinstock314@ed7259d

It emits compressed attributes (including emitting no attribute if the entire list is a copy of the default), and emits both "columnlines" and "columnalign" on the mtable instead of on the mtds.

Should I rebase this onto master and then submit it as a PR?

@jgm
Copy link
Owner Author

jgm commented Jan 10, 2021

Should I rebase this onto master and then submit it as a PR?

Yes, please.

aweinstock314 added a commit to aweinstock314/texmath that referenced this issue Jan 10, 2021
- Add [ColumnSeparator] to EArray.
- Readers.MathML can generate any of {CSNone, CSDashed, CSSolid}, which should round-trip through Writers.MathML
- {Readers,Writers}.TeX only support {CSNone, CSSolid}
- Readers.OMML currently generates CSNone, and Writers.OMML doesn't emit ColumnSeparator information
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants