September 15, 2016
On 09/15/2016 11:43 AM, Johan Engelen wrote:
> On Thursday, 15 September 2016 at 14:42:37 UTC, Andrei Alexandrescu wrote:
>> On 09/15/2016 10:37 AM, Johan Engelen wrote:
> Btw, Ddoc is perhaps a little more than a macro system, and that's why
> using parameter names in equations is broken. Parameter names are
> replaced by (wait for it) a macro, so disabling that macro "fixes" the
> issue. See the stackoverflow example.
> http://stackoverflow.com/a/39514239/3215806

Thanks for making that point. Does the underscore prefix work? (I'll note that DDOC_PARAM is one of those things in the vein that many clamor for - do things automatically without a macro in sight...)

> So indeed, the DDoc system does provide a simple way to end up with
> nice-looking equations: "import" MathJax, and just write \(...\).
> Excellent.
>
> - Is there a way to "import" MathJax without having to redefine the DDOC
> macro?(seems a little brittle)

Yah, I think it's suboptimal to have to redefine DDOC (which in serious apps has a bunch of stuff) just for a few pages that need certain stuff in the html head. (This is a similar issue with various entities adding headers to http requests.)

What an application can do is this:

CUSTOM_DDOC =
<!DOCTYPE html>
<html lang="en-US">
<head>
$0
<title>$(TITLE)</title>
</head>
<body><h1>$(TITLE)</h1>$(BODY)</body>
</html>
DDOC = $(CUSTOM_DDOC)

Then, the pages that want mathjax go:

Macros:
DDOC = $(CUSTOM_DDOC <script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"></script>)

In fact I think it would be a great idea to do this right now for Phobos and mathspecial.

Another solution is to define and use some macro a la DDOC_EXTRA_HEADER (and probably DDOC_EXTRA_FOOTER) but probably the one above is simpler and better.

> - Perhaps we can "standardize" the MathJax thing for Phobos docs? Would
> be nice for Manu's color lib and for Mir too. (where are the Mir guys
> anyway in this discussion? ;)

Johan, do you think I could impose on you to try your hand? The solution would redefine DDOC as above and involve dlang.org and (then) std.mathspecial.

> - Also, how about that parameter name problem? Any good fix for that?

Let's see how the underscore does.


Andrei

September 15, 2016
On Thursday, 15 September 2016 at 14:40:24 UTC, Andrei Alexandrescu wrote:
> Wait, but I just showed how with vanilla ddoc you can immediately use mathjax to do better than adrdox. No need for any pre/postprocessing or scripting, just one line of import.

mathjax IS postprocessing via scripting. And better is extremely dubious as it is unreliable and slow for the end user...

My method of automatic server-side image replacement gives fast, consistent results to the reader, while being equally simple to write for the author. It also has the advantage of working offline, which is a major point for my docs because I like to use them while on airplanes and such.

I'm aware of these other options. I also considered generating MathML or SVG and decided on png because it gives the best balance of benefits - a small image file that works everywhere (including offline), though doesn't scale font sizes or respond to other css instructions as well as the others, I deemed those to be less important overall than actually displaying correctly by default on a wide variety of devices without a massive download.
September 15, 2016
On Thursday, 15 September 2016 at 16:35:53 UTC, Andrei Alexandrescu wrote:
>>
>> - Also, how about that parameter name problem? Any good fix for that?
>
> Let's see how the underscore does.

Underscore works, updating SO example.
September 15, 2016
On Thursday, 15 September 2016 at 16:35:53 UTC, Andrei Alexandrescu wrote:
> On 09/15/2016 11:43 AM, Johan Engelen wrote:
>>
>> - Perhaps we can "standardize" the MathJax thing for Phobos docs?
>
> Johan, do you think I could impose on you to try your hand? The solution would redefine DDOC as above and involve dlang.org and (then) std.mathspecial.

I don't want to get involved in this further, as I am not going to be the one using it.
September 16, 2016
On 15 September 2016 at 23:48, Andrei Alexandrescu via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> On 09/15/2016 09:12 AM, Manu via Digitalmars-d wrote:
>>
>> On 15 September 2016 at 22:40, Adam D. Ruppe via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
>>>
>>> On Wednesday, 14 September 2016 at 15:49:27 UTC, bachmeier wrote:
>>>>
>>>>
>>>> I agree. That's why I quickly gave up on ddoc.
>>>
>>>
>>>
>>> My doc generator just pipes special input text through the latex program
>>> to
>>> generate an image, which is then inlined in the html:
>>>
>>> http://dpldocs.info/experimental-docs/test.html
>>
>>
>> Now we're talking!
>
>
> That strikes me as an inferior solution to what's available today, which is used at http://erdani.com/d/DIP1000-typing-baseline.html.

I'm guessing that's mathjax? Strangely, it renders really badly on my
system. I can barely read it.
I'd still rather use latex to produce images for my own docs.
September 16, 2016
On Thursday, 15 September 2016 at 13:23:36 UTC, Andrei Alexandrescu wrote:
> On 09/15/2016 08:40 AM, Adam D. Ruppe wrote:
>> On Wednesday, 14 September 2016 at 15:49:27 UTC, bachmeier wrote:
>>> I agree. That's why I quickly gave up on ddoc.
>>
>> My doc generator just pipes special input text through the latex program
>> to generate an image, which is then inlined in the html:
>>
>> http://dpldocs.info/experimental-docs/test.html
>
> Nice. I recall that was the standard solution until a few years ago. It seems the newfangled way to do so uses javascript rendering, see http://tex.stackexchange.com/questions/23804/how-to-incorporate-tex-into-a-website. -- Andrei

Wikipedia render to svg serverside and have dropped mathjax support.
September 16, 2016
On Friday, 16 September 2016 at 02:30:37 UTC, Manu wrote:
> On 15 September 2016 at 23:48, Andrei Alexandrescu:
>>
>> That strikes me as an inferior solution to what's available today, which is used at http://erdani.com/d/DIP1000-typing-baseline.html.
>
> I'm guessing that's mathjax? Strangely, it renders really badly on my
> system. I can barely read it.
> I'd still rather use latex to produce images for my own docs.

I believe at least the syntax for the stuff is LaTeX:
http://docs.mathjax.org/en/latest/start.html#putting-mathematics-in-a-web-page
September 16, 2016
On 9/15/16 10:30 PM, Manu via Digitalmars-d wrote:
> I'm guessing that's mathjax? Strangely, it renders really badly on my
> system. I can barely read it.
> I'd still rather use latex to produce images for my own docs.

You may want to check the options discussed at http://tex.stackexchange.com/questions/23804/how-to-incorporate-tex-into-a-website. -- Andrei

September 16, 2016
On 9/16/16 4:20 AM, John Colvin wrote:
> On Thursday, 15 September 2016 at 13:23:36 UTC, Andrei Alexandrescu wrote:
>> On 09/15/2016 08:40 AM, Adam D. Ruppe wrote:
>>> On Wednesday, 14 September 2016 at 15:49:27 UTC, bachmeier wrote:
>>>> I agree. That's why I quickly gave up on ddoc.
>>>
>>> My doc generator just pipes special input text through the latex program
>>> to generate an image, which is then inlined in the html:
>>>
>>> http://dpldocs.info/experimental-docs/test.html
>>
>> Nice. I recall that was the standard solution until a few years ago.
>> It seems the newfangled way to do so uses javascript rendering, see
>> http://tex.stackexchange.com/questions/23804/how-to-incorporate-tex-into-a-website.
>> -- Andrei
>
> Wikipedia render to svg serverside and have dropped mathjax support.

Didn't know that. Did they open-source their solution? Thanks! -- Andrei
September 16, 2016
On Friday, 16 September 2016 at 11:22:59 UTC, Andrei Alexandrescu wrote:
> Didn't know that. Did they open-source their solution? Thanks!


They did, and I looked at it for my adrdox too and based my solution on their concepts, though I didn't use their code (because it was too heavyweight with dependencies for my purposes).

The Wikipedia version does a *lot* of validation (as you can expect for a publicly editable site!) then pipes it out the latex program, server side, to generate the image files.