>>919502 (OP)
TL;DR: Use reStructedText (reST), convert it to LaTeX or PDF
http://docutils.sourceforge.net/rst.html
https://pandoc.org/
Markdown is a shitty hack made by a guy who wanted to generate some HTML. It's OK for what it was meant to be, but (as usual) people came in and started stretching it beyond its limits. It's lacking in features, ambiguous, has no formal standard and every implementation adds its own extensions.
reStructuredText is pretty much Markdown, except without those problems and with the features missing in Markdown. Furthermore, reST is a very regular language, its main features are inline roles and blockwise directives. A role looks like
Euler's identity says that :math:`e^{2πi} = 1`, which we can implement as :code:`e ** (2 * pi * i)`.
As you see it's always the name of the role, followed by the content. You can also set a default role so you don't have to type its name, only the content. A directive is a blockwise element:
We can also wrap it up in a function.
.. code-block:: python
def euler(i):
return e ** (2 * pi * i)
The result of the plot can be seen in this image:
.. image:: plot.png
:alt: Plot of a graph
Directives can take any number of arguments and a block of content. What makes it cool is that this is all a uniform system and you can implement your own roles or directives.
You can convert reST to LaTeX (and thus PDF), HTML, or whatever it is you want to publish your work as.
However, if you really need control over the typesetting there is really not much of an alternative to LaTeX. I guess you could write a custom LaTeX template for use with Pandoc or something like that. The same goes if you want to use a lot of math, there just is no alternative.