Show HN: TeXMe Demo – Self-Rendering Markdown and LaTeX Documents
opendocs.github.io
opendocs.github.io
Btw, VSCode added native support for Jupyter notebooks recently.
Can you link the the recent support you talk about so I can compare it to what I’ve already tried in vscode?
It is exactly as you mentioned, you click the notebook, it renders and opens a Kernel on the background.
The plots have a default dark theme, but can be changed in the same way as if it was inside a normal Jupyter instance.
It's pretty convenient, but a bit buggy still for larger notebooks (I have to constantly save or some actions cause the cells to rollback in time).
(Disclaimer: Not my project, but I've developed several Markdeep-adjacent tools [2][3].)
[1]: https://casual-effects.com/markdeep/
[2]: https://github.com/doersino/markdeep-slides
[3]: https://github.com/doersino/markdeep-diagram-drafting-board
There are some fundamental differences between the two tools. For example, in Markdeep, the user input goes into the <body> element whereas in TeXMe the user input goes into the <textarea> element. The choice of <textarea> element was made in TeXMe to make Markdown rendering more robust. Copy-pasting a valid Markdown code into Markdeep may not always render correctly without further editing. By the way, TeXMe also supports content in <body> as an optional feature.
Further, Markdeep does not care about conforming to the CommonMark spec whereas TeXMe does. If you care about CommonMark spec, TeXMe is a good choice. However, if you need additional features like tables, diagrams, etc., Markdeep is a good choice.
For a detailed comparison of the two tools, please see this thread: https://news.ycombinator.com/item?id=18314175.
The main issue is that things like LaTeX theorem environments don't translate exactly markdown (plus the theorem numbering/referencing), but there should be some choice of convention. Seems like there was a focus on features that map directly between different formats.
How is that different from any of the existing JS libs? The fact that it is one line of code vs. a couple extra?
What’s your proposed solution?
FWIW the main goal of CommonMark is to fix the ambiguity of Markdown.pl and provide a common subset of features for all parsers to target, instead of trying to include everyone’s pet feature.
I'm aware. Equations aren't exactly a "pet feature" though, unless things like code blocks are also pet features.
There's an easy solution - have syntax that turns off parsing (a nowiki type syntax).
Commonmark accomplishes very little if it can't be used to produce the documents people are creating. If you want to add equations, you need an extension. And if you use two extensions, you need to make sure they interact correctly. And you have to be sure that all the extensions that might possibly be used interact nicely together. At that point, you have your own version of markdown, and you need to preprocess all your commonmark documents.
But yeah, it's nice that all commonmark implementations use the same syntax for bold and italics. Unfortunately writing involves a lot more than that.
Okay, that's fair, but CommonMark standardized de facto standards -- it was born as Standard Markdown after all -- and AFAIK there's no de facto standard here, so it would be pretty dangerous for jgm to pull something out of thin air. I can see why there's reluctance here.
(IIRC fenced code blocks were pretty widespread before CommonMark, and even if not, being part of GFM would almost make it a de facto standard. Note that CommonMark was a joint effort among GitHub, Stack Exchange, Reddit, etc.; SE's <!-- lang --> solution was atrocious, so GFM fenced code block was an obvious win.)
Also, code blocks with language specification is apparently of way higher importance to programmers than typeset math, so comparing the two isn't that useful. (I say this as a physicist who breathe typeset math.)
Now, going back to
> you can't use this together with code blocks containing $ (meaning it doesn't work for languages like PHP and R).
Why do you need to typeset math within code blocks or code spans? Code blocks and code spans are verbatim by definition. Interpret $ inside code blocks and code spans as verbatim; interpret $ outside as LaTeX delimiters. Problem solved. Maybe I'm missing something.
The problem is that commonmark doesn't recognize math at all. If you want to use texme, you can't have code blocks that containing $. For it to work properly, you'd need a preprocessor to parse the whole file, convert equations in the text as needed but ignore text in code, output to a format that doesn't cause problems with commonmark (for instance, protecting underscores outside code blocks). At that point you are way beyond just "using commonmark". It's simply not suited for even moderately complicated documents.
The tool, as is, works for me and my friends. I don't intend to make any major changes to this tool except for occasional bug fixes, so the number of commits is going to be less in future.
I know there are a few outstanding bugs. I have a full-time job and I am contributing to a few other open source projects too, so I don't have a lot of spare time to investigate and fix these issues right now but I may get to it later.
If there are others who might want to help the project by investigating the bugs and/or fixing them, they are very welcome. For any fixes merged to the project, I will be grateful to the contributors and as a token of gratitude, I will mention their names in the README and thank them.
Your claim doesn't match your intent really. Some of your repos have long(many months) old issues with zero interaction from you yet I see activity in commit history.
For small projects like yours, there might be first-time contributors who look up to an author. If you don't interact, they'll get demotivated. If you don't want to interact, leave a comment on your README that "hey am super busy, send a PR with proper tests and may be I'll look when am free, no promises!". :) A little kindness goes a long way.
Thank you for this!
Edit: If any @Amazon Kindle devs read this, can you please reskin your technical texts to adopt this?
All we need now is a way for it to fall back to pre-rendered static html for cases where there is no JS, and to be indexed.
Providing an interactive editor was not the goal of this project. The goal of this project was to write a text file using a mix of LaTeX and Markdown (while conforming to CommonMark specification as much as possible) and then share this file with my friends in such a way that they can render it easily by just opening it in a web browser. As a result, it completely replaces the textarea element with the rendered HTML.
If someone wants to take this project and create an interactive editor with it, please feel free to fork this project and do so. If you face any problems, please let me know by filing issues on the GitHub project: https://github.com/susam/texme.
Or is there much more to it?
+ save some network bandwidth in case of a sufficiently large/complex document
- burn some extra energy client-side in case of a sufficiently large/complex document
+ allow some kind of interactive manipulation/modification by the reader
It's better than PDF. Text in PDF is not reflowable. This demo is by virtue of being HTML under the hood. Looks good even after resizing the browser.
I wish PDFs had a reflowable mode. What would it take to add such a mode to the PDF spec without breaking backward compatibility?
PDF's fixed layout is a real problem when we try to convert PDF books containing math to EPUB or MOBI with Calibre. It really messes up the beautifully typeset math in the PDF during the conversion. What's a good solution for this?
Edit.
I think the reason you lose quality during conversion is because without the original LaTeX code, you’re just importing copied images of math. If you have access to the original content, then you can maintain quality regardless of window size. One example is arxivvanity which uses the original TeX files on arxiv to rerender in HTML. What do you do without the source code? You can either try vectorizing the images to get scalable SVGs, which depends on heuristics and doesn’t recover typeset perfectly. Or perhaps reverse engineer the formulas with OpenCV or another ML method; this one is pretty hard to do and I’ve only seen mathpix, a paid service, which does this.
Either case it’s a strong argument that content should be separate from content rendering which is why I like TeXMe as a concept and why people should avoid PDFs.
Not necessarily. See MathML.
PDF has everything including the kitchen sink. There’s a fairly esoteric feature called “tagged PDFs” which contain extra markup commands within the page description that map it to a logical structure and alternative textual presentations (e.g. MathML). The problem is that nobody uses it as it’s extremely hard to generate (most software which does text layout discards high level semantic details fairly early on, making it hard to retrofit - pdfTeX for example only recently started inserting space characters between words!). Likewise PDF viewers don’t bother to support it.
Reflowing a tagged pdf is fairly easy... once you have the pdf, which of course you don’t.
It’s a hard problem.
This is relative. Many people dislike reflowable text, and often it is not very convenient. Book typesetting is hard, and once it is done, reflowing the text changes the book, usually for worse. Maybe not for plain text, but definitely for math and poetry, were the "flow" is a crucial part of the work, and it was carefully set up by the author. You do not ever want to "reflow" math or poetry. For these two subjects (my favorite ones, incidentally) pdf seems to be the best option.