It's probably my favorite as well, I remember learning it in school, the way it brings together e, i and pi, which seemed to live in separate worlds until then, amazed me, it was like discovering the keystone of math.
<!DOCTYPE html>
<script>window.texme = { useMathJax: false, protectMath: false }</script>
<script src="https://cdn.jsdelivr.net/npm/texme"></script><textarea>
### Atomic Theory
Atomic theory is a scientific theory of the nature of matter, which
states that matter is composed of discrete units called atoms. It began
as a philosophical concept in ancient Greece and entered the scientific
mainstream in the early 19th century when discoveries in the field of
chemistry showed that matter did indeed behave as if it were made up of
atoms.
Right now, it requires a few more lines of HTML code to disable MathJax related processing. I am planning to add a simpler mechanism later, so that something like merely appending "?markme" to the TeXMe URL in the <script> tag is enough to set it to Markdown-only mode. If anyone has a better idea regarding this, please let me know or send a pull request.
Thanks to your suggestion, I have now created a separate, smaller, library named MdMe: https://github.com/susam/mdme.
This is a stripped down fork of TeXMe that does not contain any code for MathJax related processing.
Here is a minimal example:
<!DOCTYPE html><script src="https://cdn.jsdelivr.net/npm/mdme@0.1.0"></script><textarea>
# Atomic Theory
**Atomic theory** is a scientific theory of the nature of matter, which
states that matter is composed of discrete units called *atoms*.
This is absolutely fresh--published only a few minutes ago. If you find any issues, please report it.
The example[1] I have linked to under the section titled "Styles" in README seems to show that custom style is working. Or do you mean something else by "custom format"?
If you can provide a reproducible example of the issue, it would help me to understand the issue and fix it. I suggest filing a new issue with the details.
This looks nice; I'll have a play when I have some time.
One thing that's not immediate clear from the examples: how (if at all) are you avoiding Flash-Of-Unstyled-Content on initial load? Might it be better to put the markdown in a <noscript> block rather than (or as well as) a <textarea> when editing isn't required?
Often one use case for markdown is reuse. The same text with markdown might go in code comments or a readme file (staying as plain text with markdown), presented with HTML markup in a browser, converted to a page description format (for instance PDF) for read-only distribution, etc.
If you write the document with HTML markup you then lose this flexibility.
As someone who has written a few of LaTeX documents over the years, I'd like to point out that rendering TeX math does not constitute a TeX document at all.
What LaTeX truly shines at, is typography. Yet a bunch of people seem to think that it's only a way to write math.
This is an interesting project. It just bums me out because I thought it was a TeX distribution for the web. I'd remove "TeX" from the name to avoid confusion.
That's 552 pages worth of typography that only considers page layouting. It doesn't deal with fonts or kerning at all. It's actually a fun read even if just for the author's occasional frustration with how often laymen confidently ignore centuries-old typography rules that exists for a reason.
The context for the discussion is browser rendering for variable sized screens and user interaction in mind. Centuries-old typography rules can't be applied directly for screens.
For paper documents you can already do Markup -> LatTeX -> pdf for good quality documents.
> Centuries-old typography rules can't be applied directly for screens.
Some of it, certainly not.
A (larger IMHO) part of typography wisdom has really been distilled from experience making text easier and prettier to read over generations, and should not be thrown away lightheartedly because "screen is different from paper". Yes it is, but human eyes and brain are the same ;-)
Does it say anywhere in that manual why the right margin is supposed to be so narrow? I find it very uncomfortable to read texts with very narrow margins.
"Here, good boy, I know you can't be expected to know how to zoom your PDF file, so I'll just prepare a version for you without the margins and with some colors or something. Here, take a cookie. Good boy."
A) LaTeX is a library for laying out papers and common text memes. It’s not actually necessary at all. You would want to use TeX, which refers to the actual rendering engine.
B) converting layout with css to Tex sounds like an absolute nightmare compared to just implementing proper word, line, paragraph, and page flowing/breaking in the browser. In fact, HTML is pretty opposed to page breaking at all, which is arguably a forte of TeX.
It’s opposite from what i feel. On one hand hand I suffer from seeing all the PDFs or papers with poor MS Office type set.
But when it comes to the web I feel like people spend too much time (and waste my resources) to arrive at a perfect layout. There I would prefer a simple robust layout that renders well on all devices and resolutions.
I write a lot of LaTeX documents and use the TeX Live distribution to typeset them, so I understand why the name TeXMe could cause some confusion.
This project only cares about protecting the LaTeX content (the MathJax supported LaTeX, not the "real" LaTeX) by hiding it from the Markdown processor, so that the Markdown processor cannot mangle the LaTeX code before it is fed to MathJax.
I could have named it MathMe, JaxMe, or something similar that would have eliminated this confusion between MathJax supported TeX/LaTeX[1] and the "real" TeX/LaTeX. However, unfortunately I did not spend sufficient time thinking about a good name for this project, thus the name TeXMe.
It’s based on LaTeXML, which does the heavy lifting of converting LaTeX to HTML. I’m more interested in the CSS applied on top of that. I want to make web output of the same calibre as the PDF output. (Or, near to it at least. :)
> I want to make web output of the same calibre as the PDF output.
This to me is the unsolved problem. Interpreting a LaTeX file on the web is probably not a crazy problem -- heck, worst case scenario recompile the entire LaTeX compiler into WASM or something.
But, typesetting on the web is really hard and browser capabilities that I know of are just not up to snuff, to the point that conventional wisdom is you pretty much never justify text on the web, ever, because it won't ever look good. So generic solutions to that problem are something I'd be interested in.
The secondary problem past that is to make justified text look good while still being responsive :) But even just for fixed column widths it's something that I'd love to see.
I respectfully disagree. I think people use LaTeX to write scientific documents because there is no better alternatives, not because LaTeX is good.
I find the typesetting system in LaTeX is extremely verbose and over-complicated, as compared to something like HTML+CSS or Markdown.
If someone comes up with a good enough typesetting system with some inspiration from Markdown, HTML and CSS, LaTeX will lose its popularity. HTML and CSS are more expressive than LaTeX, so it should be theoretically possible.
One possible explanation for the lack of better alternatives is that the people who really need the alternatives and people who are capable of coming up with better alternatives are somewhat mutually exclusive. Former is more research-heavily and latter is more coding and user experience heavy.
I mean, CSS/HTML is technically a Turing complete language given enough caveats[0]. ;)
But I'm obviously just being a pedantic jerk when I say that. I get what you're getting at and you're not wrong. The real question to ask is, "is a programming language a good place to put a typesetter?"
Making things more powerful doesn't always make them better, if that extra power forces you to introduce extra complexity.
Why is that the real question to ask? The dogmatic separation of view and control is probably among the chief reasons of code bloat and bad decisions I've ever been close to.
An example of good separation of model/view/control is Markdown.
Markdown is ubiquitous because it's easy to learn and does one thing well. It's a very Unix-y idea. Markdown is a document markup language, not a Model-View-Controller framework. It's not trying to be the front end for your SPA, it's trying to allow you to type Reddit comments and blog posts.
That comes with advantages, the big one being that here's the entire documentation you need to look at if you want to start using Markdown[0] and here's one section of LaTeX's documentation[1]. I could have an entire office (programmers and non-programmers) using Markdown in about a week to a month, I couldn't do the same with LaTeX.
Of course LaTeX is more powerful that Markdown. Markdown isn't really a tool for typesetting tbh. But the point is that because extra functionality nearly always comes at the cost of extra complexity, you always need to take a step back and ask how important that extra functionality is. If someone says, "Okay, but I really need to meta-program my blog post", even at that stage I'm not sure that I push them towards LaTeX or its equivalents, because maybe it's better at that point to just jump to a full featured language like Python or Javascript.
That separation of concerns also means that I can have different people handling different things. If my office is all writing Markdown, maybe I only have one or two people who are handling the CSS for how it renders. Nobody else in the office needs to know about the CSS side of things.
Markdown it's essentially ASCII art for simple documents. Nothing wrong with that, but it is not seperation of concerns. Rather, it is simplicity of some concerns.
And to make it hugely amusing, the rules in markdown for just content are not much different than TeX.
I think Markdown is a good argument for potentially being too simple. It's good for what it's meant for, but it stumbles for stuff like blog authoring.
I am somewhat happy with AsciiDoctor[0], although I honestly feel like AsciiDoctor goes farther in the other direction than it needs to and ends up overcomplicating itself. I spend more time reading the AsciiDoctor documentation than I want to.
Would you be willing to expand more on what you mean about a separation of concerns vs a simplicity of concerns? I was using the term in the sense that Markdown not only doesn't embed logic, it also doesn't embed style. It's literally just content, and you use other technologies to get at the other parts.
In contrast, LaTeX embeds logic, style, and content. When I work with Markdown I don't stop thinking about style -- I just use other tools for that. That separation allows me to then give other people content access without asking them to worry about CSS.
I guess I could see that it's a flat-out dropping of meta-programming from my document generation (although Markdown is a very easy compilation target for templates). But that just kind of gets back to my original point -- do you really need to meta-program blog posts and books, given that it greatly increases the complexity of LaTeX? Would it be better to have a simpler version of LaTeX that got rid of that functionality and said, "I'm just gonna do text layout really well, and nothing else"?
The typograghy of TeX is hard to sneer at. Even more, it's stability. Knuth's insistence on stability of feature and focus on core requirements is definitely a lost art in the modern world.
Could someone make something that was more aesthetically pleasing for the typist? Likely. Though, most of the added structures of LaTeX are often not needed for casual documents. Which is why it was oddly refreshing to read some of the core source of Knuth's books.
If a bunch of people use LaTeX only to write math and this contains that functionality, why wouldn't the author want to advertise it? Is there a specific short-hand name for the LaTeX math functionality?
The one thing I would wish for is a build tool where I could insert my CSS (or a choose from available themes) and build my version of TeXMe (I have a CSS file already which I use to convert Markdown files to PDF).
I mean, yes it is not that complicated, and I might just do it manually, but for wider adoption, it would be cool to have themed versions which do not clutter the Markdown files.
I have a script which converts Markdown to HTML (using Discount; referencing my CSS file and highlight.js for syntax highlighting in code sections) and starts a headless chromium which in turn converts the rendered HTML to a PDF file.
It consists of multiple files (entry point is markdown2pdf.sh) and also supports a flag '-w' to watch the markdown file so you can use an editor to modify it while your PDF viewer (in my case okular) keeps updating the changes.
I built it solely for my purpose, so it might not fit your needs (or taste). ;-)
Legal: I have no special requirements, so think of it as MIT license, but I included some other files (everything in the directory 'Markdown-Styling' except 'css/app.css' which is my CSS theme) which are available free of charge somewhere on the internet but might have their own licenses and terms of use.
Pandoc, commonmark.js, and many other tools and libraries can already do that. This project is not trying to address that use case. Instead, this project is attempting to make a Markdown + LaTeX (MathJax) file render itself with minimal additional HTML.
A cool advantage is that one should be able to just write the file by hand in any Markdown (or text) editor on any random PC, and then with this fairly easy to remember one-liner insta-convert it to a pretty document for viewing in a browser. I'd go this far as positing that this could become somewhat of a "standard preamble" for .md files... or at least that it could be an interesting thought experiment to imagine that :)
I'm very grateful you created this. It is going to be a tool #1 in my workflow. The best thing I like is that the resulting document can be printed or saved as a PDF file with web browser printing dialog.
Impressive. A sweet spot between HTML, Markdown and LaTeX.
This is a godsend to anyone who just wants to publish markdown blogs (with some maths) etc in the simplest possible way on a static website.
I know, the proper way is supposed to be to use Jekyll or Hugo or something like that, to compile to raw html on the server side but this is much simpler for the publisher. No configuration and compilation and updating on the server involved.
I do not think that the user will notice or begrudge the few milliseconds of processing in his browser. Especially if this could be converted to a WASM module. Any takers?
66 comments
[ 2.6 ms ] story [ 109 ms ] threadThank you for reporting this. I have fixed it now.
That'd be a neat way to quickly create documentation websites for open source projects!
> Render Markdown Without MathJax > To render Markdown-only content without any mathematical content at all ...
This is a stripped down fork of TeXMe that does not contain any code for MathJax related processing.
Here is a minimal example:
This is absolutely fresh--published only a few minutes ago. If you find any issues, please report it.I hope you like this.
If you can provide a reproducible example of the issue, it would help me to understand the issue and fix it. I suggest filing a new issue with the details.
[1]: https://opendocs.github.io/mdme/examples/e04-style-custom.ht...
https://news.ycombinator.com/item?id=17321599
One thing that's not immediate clear from the examples: how (if at all) are you avoiding Flash-Of-Unstyled-Content on initial load? Might it be better to put the markdown in a <noscript> block rather than (or as well as) a <textarea> when editing isn't required?
If you write the document with HTML markup you then lose this flexibility.
[1]https://facebook.github.io/react-native/docs/text
What LaTeX truly shines at, is typography. Yet a bunch of people seem to think that it's only a way to write math.
This is an interesting project. It just bums me out because I thought it was a TeX distribution for the web. I'd remove "TeX" from the name to avoid confusion.
For your consideration, this is the manual for KOMA-Script: https://mirror.las.iastate.edu/tex-archive/macros/latex/cont...
That's 552 pages worth of typography that only considers page layouting. It doesn't deal with fonts or kerning at all. It's actually a fun read even if just for the author's occasional frustration with how often laymen confidently ignore centuries-old typography rules that exists for a reason.
For paper documents you can already do Markup -> LatTeX -> pdf for good quality documents.
Some of it, certainly not.
A (larger IMHO) part of typography wisdom has really been distilled from experience making text easier and prettier to read over generations, and should not be thrown away lightheartedly because "screen is different from paper". Yes it is, but human eyes and brain are the same ;-)
- no margin on the binding side
- silly colors everywhere
- mixes normal and reverse text for no reason
- uses german typographical conventions but the text is in english
- extreme abuse of monospace italics
- mixed serif/sans/monospace/boldface on every page
- nonstandard paper size (18x21 cm)
All of this could be expected, and not too worrying, for a text about any subject, except a fucking document about page layout!
The online version highlights everything you can click and has tiny margins to avoid on-screen whitespace.
This is ridiculously condescending... everybody is able to zoom-in with their pdf viewer.
https://www.amazon.de/KOMA-Script-Sammlung-Klassen-Paketen-L...
B) converting layout with css to Tex sounds like an absolute nightmare compared to just implementing proper word, line, paragraph, and page flowing/breaking in the browser. In fact, HTML is pretty opposed to page breaking at all, which is arguably a forte of TeX.
But when it comes to the web I feel like people spend too much time (and waste my resources) to arrive at a perfect layout. There I would prefer a simple robust layout that renders well on all devices and resolutions.
I write a lot of LaTeX documents and use the TeX Live distribution to typeset them, so I understand why the name TeXMe could cause some confusion.
This project only cares about protecting the LaTeX content (the MathJax supported LaTeX, not the "real" LaTeX) by hiding it from the Markdown processor, so that the Markdown processor cannot mangle the LaTeX code before it is fed to MathJax.
I could have named it MathMe, JaxMe, or something similar that would have eliminated this confusion between MathJax supported TeX/LaTeX[1] and the "real" TeX/LaTeX. However, unfortunately I did not spend sufficient time thinking about a good name for this project, thus the name TeXMe.
[1]: http://docs.mathjax.org/en/latest/tex.html
It’s based on LaTeXML, which does the heavy lifting of converting LaTeX to HTML. I’m more interested in the CSS applied on top of that. I want to make web output of the same calibre as the PDF output. (Or, near to it at least. :)
This to me is the unsolved problem. Interpreting a LaTeX file on the web is probably not a crazy problem -- heck, worst case scenario recompile the entire LaTeX compiler into WASM or something.
But, typesetting on the web is really hard and browser capabilities that I know of are just not up to snuff, to the point that conventional wisdom is you pretty much never justify text on the web, ever, because it won't ever look good. So generic solutions to that problem are something I'd be interested in.
The secondary problem past that is to make justified text look good while still being responsive :) But even just for fixed column widths it's something that I'd love to see.
Props, it looks like a very cool project.
I respectfully disagree. I think people use LaTeX to write scientific documents because there is no better alternatives, not because LaTeX is good.
I find the typesetting system in LaTeX is extremely verbose and over-complicated, as compared to something like HTML+CSS or Markdown.
If someone comes up with a good enough typesetting system with some inspiration from Markdown, HTML and CSS, LaTeX will lose its popularity. HTML and CSS are more expressive than LaTeX, so it should be theoretically possible.
One possible explanation for the lack of better alternatives is that the people who really need the alternatives and people who are capable of coming up with better alternatives are somewhat mutually exclusive. Former is more research-heavily and latter is more coding and user experience heavy.
But I'm obviously just being a pedantic jerk when I say that. I get what you're getting at and you're not wrong. The real question to ask is, "is a programming language a good place to put a typesetter?"
Making things more powerful doesn't always make them better, if that extra power forces you to introduce extra complexity.
[0]: https://my-codeworks.com/blog/2015/css3-proven-to-be-turing-...
Markdown is ubiquitous because it's easy to learn and does one thing well. It's a very Unix-y idea. Markdown is a document markup language, not a Model-View-Controller framework. It's not trying to be the front end for your SPA, it's trying to allow you to type Reddit comments and blog posts.
That comes with advantages, the big one being that here's the entire documentation you need to look at if you want to start using Markdown[0] and here's one section of LaTeX's documentation[1]. I could have an entire office (programmers and non-programmers) using Markdown in about a week to a month, I couldn't do the same with LaTeX.
Of course LaTeX is more powerful that Markdown. Markdown isn't really a tool for typesetting tbh. But the point is that because extra functionality nearly always comes at the cost of extra complexity, you always need to take a step back and ask how important that extra functionality is. If someone says, "Okay, but I really need to meta-program my blog post", even at that stage I'm not sure that I push them towards LaTeX or its equivalents, because maybe it's better at that point to just jump to a full featured language like Python or Javascript.
That separation of concerns also means that I can have different people handling different things. If my office is all writing Markdown, maybe I only have one or two people who are handling the CSS for how it renders. Nobody else in the office needs to know about the CSS side of things.
[0]: https://daringfireball.net/projects/markdown/syntax
[1]: https://www.latex-project.org/help/documentation/fntguide.pd...
Markdown it's essentially ASCII art for simple documents. Nothing wrong with that, but it is not seperation of concerns. Rather, it is simplicity of some concerns.
And to make it hugely amusing, the rules in markdown for just content are not much different than TeX.
I am somewhat happy with AsciiDoctor[0], although I honestly feel like AsciiDoctor goes farther in the other direction than it needs to and ends up overcomplicating itself. I spend more time reading the AsciiDoctor documentation than I want to.
Would you be willing to expand more on what you mean about a separation of concerns vs a simplicity of concerns? I was using the term in the sense that Markdown not only doesn't embed logic, it also doesn't embed style. It's literally just content, and you use other technologies to get at the other parts.
In contrast, LaTeX embeds logic, style, and content. When I work with Markdown I don't stop thinking about style -- I just use other tools for that. That separation allows me to then give other people content access without asking them to worry about CSS.
I guess I could see that it's a flat-out dropping of meta-programming from my document generation (although Markdown is a very easy compilation target for templates). But that just kind of gets back to my original point -- do you really need to meta-program blog posts and books, given that it greatly increases the complexity of LaTeX? Would it be better to have a simpler version of LaTeX that got rid of that functionality and said, "I'm just gonna do text layout really well, and nothing else"?
[0]: https://asciidoctor.org/
Could someone make something that was more aesthetically pleasing for the typist? Likely. Though, most of the added structures of LaTeX are often not needed for casual documents. Which is why it was oddly refreshing to read some of the core source of Knuth's books.
The one thing I would wish for is a build tool where I could insert my CSS (or a choose from available themes) and build my version of TeXMe (I have a CSS file already which I use to convert Markdown files to PDF).
I mean, yes it is not that complicated, and I might just do it manually, but for wider adoption, it would be cool to have themed versions which do not clutter the Markdown files.
I have a script which converts Markdown to HTML (using Discount; referencing my CSS file and highlight.js for syntax highlighting in code sections) and starts a headless chromium which in turn converts the rendered HTML to a PDF file.
Care to share your script?
I built it solely for my purpose, so it might not fit your needs (or taste). ;-)
Legal: I have no special requirements, so think of it as MIT license, but I included some other files (everything in the directory 'Markdown-Styling' except 'css/app.css' which is my CSS theme) which are available free of charge somewhere on the internet but might have their own licenses and terms of use.
It also demonstrates documents created this way require code from two different third-party origins to work at all.
Well done!
Impressive. A sweet spot between HTML, Markdown and LaTeX.
I know, the proper way is supposed to be to use Jekyll or Hugo or something like that, to compile to raw html on the server side but this is much simpler for the publisher. No configuration and compilation and updating on the server involved.
I do not think that the user will notice or begrudge the few milliseconds of processing in his browser. Especially if this could be converted to a WASM module. Any takers?