News for hackers. Stuff that matters.
Re:Show HN: TeXMe – Self-Rendering Markdown and LaTeX Documents by susam on Friday October 26, 2018 @06:22AM (#18308033)
Yes, TeXMe does it. Here is a minimal example:

    <!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.
Re:Show HN: TeXMe – Self-Rendering Markdown and LaTeX Documents by tomer_shalev on Friday October 26, 2018 @06:59AM (#18308165)
Doesn't this solution also loads all the code for rendering math? Maybe a separate, smaller, library would be a better solution.
Re:Show HN: TeXMe – Self-Rendering Markdown and LaTeX Documents by susam on Friday October 26, 2018 @08:27AM (#18308582)
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/[email protected]"></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.

I hope you like this.

Re:Show HN: TeXMe – Self-Rendering Markdown and LaTeX Documents by akavel on Friday October 26, 2018 @09:08AM (#18308806)
Maybe you could do it the other way round now? Adding a ?withmath to url would add math rendering :)
Re:Show HN: TeXMe – Self-Rendering Markdown and LaTeX Documents by SagelyGuru on Friday October 26, 2018 @12:01PM (#18310444)
I tried and it does not work with the custom formatting. Could we have that too?
Re:Show HN: TeXMe – Self-Rendering Markdown and LaTeX Documents by susam on Friday October 26, 2018 @01:00PM (#18311029)
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.

[1]: https://opendocs.github.io/mdme/examples/e04-style-custom.ht...

Re:Show HN: TeXMe – Self-Rendering Markdown and LaTeX Documents by SagelyGuru on Friday October 26, 2018 @01:59PM (#18311481)
What I have done is to take you at your word that even valid html does not need <body></body> and combined your examples of "valid html5" and "style=none" but it then failed to apply my own style to <body>.

I am kind of surprised that the styling does work in your minimalist html (style=none) example because there the <body> is missing too and yet the style is applied to it.

You might wish to take this pitfall into account in your exposition, probably by putting <head> and <body> sections into your "valid html5" example nonetheless.

Though I acknowledge that, strictly speaking, you had done nothing wrong in your individual examples.

Re:Show HN: TeXMe – Self-Rendering Markdown and LaTeX Documents by susam on Friday October 26, 2018 @02:35PM (#18311726)
Thank you for your reply.

The <body> element's start and end tags can indeed be omitted under certain conditions (which are being met in the "Valid HTML5" example). Here is the actual specification quoted from https://www.w3.org/TR/html52/syntax.html#optional-tags:

"A body element's start tag may be omitted if the element is empty, or if the first thing inside the body element is not a space character or a comment, except if the first thing inside the body element is a meta, link, script, style, or template element."

Then in "Example 6", it provides the following as an example of a valid HTML5 document:

    <!DOCTYPE HTML>
    <title>Hello</title>
    <p>Welcome to this example.</p>
Now coming back to your issue, perhaps the selectors in your style do not match the actual elements that TeXMe is setting in the page? I am just guessing here because I need the actual code to be able to nail down the cause of the issue.

If you can share the complete code you have either here or at https://github.com/susam/texme/issues/new, it would really help in determining the cause of the issue.

Re:Show HN: TeXMe – Self-Rendering Markdown and LaTeX Documents by SagelyGuru on Friday October 26, 2018 @03:10PM (#18311969)
Bug solved, sorry, ignore all my previous comments. I had done a stupid thing: I forgot to change the command window.texme = { style:'none'} to window.mdme = { style:'none'} when I started using mdme. That is why it was not applying the correct styling.
Re:Show HN: TeXMe – Self-Rendering Markdown and LaTeX Documents by susam on Friday October 26, 2018 @03:24PM (#18312075)
Thank you for sharing the cause of the issue. Good to know that the styling is working as expected after setting window.mdme = { style: 'none'}.