-
Notifications
You must be signed in to change notification settings - Fork 14
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 for multiline math formulas #54
Comments
It looks like I made a mistake in the CI script that releases the user's guide when I added the HTML rendering. Fixing that is tracked in #57 - in the meantime, running Verso inherits the sharp distinction between inline and block elements from Markdown. Right now, both forms of math are inline elements, while multiline code blocks are block elements. Would you expect a multiline math formula to be inline or block? That is, does
mean the same thing as
? I would tend to think that it should not, and that multiline math should still be an inline element. In other words, this would extend the concrete syntax, but not the abstract syntax. Do you agree? Another alternative would be to relax the parser for the existing math syntax to allow newlines within the backticks, so long as there's no completely blank lines. That is, I could write:
Would that be sufficient for your needs? |
IIUC, one can't make an inline math formula with mutiple lines in the source in Markdown, so this question doesn't really make sense to me. I tried it here:
renders to: $
It took me a while to notice the empty line. If I recall and interpret correctly, most markdown flavors will consider the first case invalid (renders verbatim), and consider the second case a block, here I tried it again with Github's flavor:
renders to:
renders to
|
Probably, yes. I would like to add some context though. These are what I would expect from writing math formulas in Markdown or Verso or a mark up in general:
Markdown itself breaks expectation 1, consider the following:
renders (correctly) to
but it requires extra escaping for The syntax in Verso seems to break expectation 2: I would expect similar things like a
not a mixture that mix everything together, like
which I believe would cause much more trouble in the future, parser-wise or cognition-wise. And I would only use
so I wouldn't confuse myself if the final syntax is mixing P.S. I wonder what would happen if someone writes:
Does the backtick between |
Replies cut up by topic :-)
This makes sense. Part of the reason for using ` around math in Verso is in order to not require extra escapes - this is consistent with how code literals work.
Yes. The way to work around this is to use more backticks to start and end the formula, just as with code literals. So
The difficulty here is that Verso, like Markdown and HTML, has a distinction between "block-level" and "inline-level" content. Block-level content is things like paragraphs, lists, and headers; inline content is things like text, hyperlinks, and boldface. Paragraphs cannot contain blocks. Math is an inline element, whether it's in display mode or not (that is, whether it's In Verso and Markdown, multiline code blocks are blocks; they are logically distinct from the paragraphs that surround them. Should there be a block-level math element? Or should a math element standing alone be a paragraph that contains a single inline bit of math? I think the latter makes sense, probably, as it's more flexible. Really, it's a problem that a high degree of Markdown compatibility has made it impossible for Verso to have a single logical paragraph that contains some text, then a bulleted list, then more text, then a formula, then some text. I've got a workaround planned for this, for when it really matters. Web typography typically hides this because paragraphs don't get indented, but it's not great for other output forms that we want to support. |
Sorry that I didn't reply months ago, as I was quite confused by the block level discussion, then distracted by other things. I've used some other authoring tools in the last few months including Hugo, Quarto, Typst and Forester, with this issue in mind, and somehow rereading this issue makes sense to me now. It seems very reasonable that Verso regards math as an inline element, regardless of whether it's multiple line math. But there is a detail in one of your early questions I didn't notice before:
Months ago I would say this subtle behavior (not allowing blank lines in multiple line math) is unintuitive and error-prone, but taking how Verso has to process Lean and other syntax into account, now I would say this is also reasonable, as long as if a user makes such a mistake unintentionally, the error message is clear on how to fix it. B.T.W. I wonder if there's any progress or some other thoughts on this topic lately. I'm aware that this might not be a high priority issue. Thanks! |
Hi @david-christiansen , I just tried the latest Verso, it seems that something like
is still not working? (which allows multiline input for display math) I can see @lecopivo has tried to work around this limitation in lecopivo/scientific-computing-lean 's Meta.Latex, but it's ideal to have built-in support for this. |
Inspired by the workaround (which use less Verso-native plain text for the math block), my workaround mimics one variant of GFM math syntax:
so one can write ```math
f'(x) = \lim_{h → 0} \frac{f(x+h) - f(x)}{h}
``` |
For now, Verso supports inline math and display math but the latter can only use inline code block:
It doesn't seem possible to use a multiline code block after
$$
per my tests.B.T.W. Previously I learned this syntax from Verso manual in the README but now it's 404, so I found it again in
UsersGuide.Markup
.The text was updated successfully, but these errors were encountered: