3
Vote

Error running Madoko locally

description

I get this error when I try to compile using Madoko locally:
 ❯ madoko -v test.md                                                                                                                                                   [10:07:13 pm]
process: test.md -> out/test.html

  test: rendering math.
  test: running xelatex on math... (plain -> xdv -> svg)
  error while running:
  > "xelatex"  --no-pdf --output-directory="out" --interaction=batchmode "out/t
  est-math-plain.tex"
  error: source line: 6
  ! Missing number, treated as zero.
  <to be read again>
                     \stockwidth
  l.10 \begin{document}

  A number should have been here; I inserted `0'.
  (If you can't figure out why I needed to see a number,
  look up `weird error' in the index to The TeXbook.)
  log written at: out/test-math-plain.log
This is the test document that I am using:
Title         : Welcome
Author        : You
Logo          : True

[TITLE]

# Madoko 

Madoko is a fast markdown processor for writing professional articles
with a focus on simplicity and plain text readability.

* Read the [reference manual].
* Explore the upper-right toolbox menu to discover how Markdown works. 
* `Alt-Q` reformats the current paragraph.

Enjoy!

In Equation [#euler] we define [Euler]'s number $e$: 

~ Equation { #euler; caption:"Euler's formula" }
e = \lim_{n\to\infty} \left( 1 + \frac{1}{n} \right)^n
~

[Euler]: http://en.wikipedia.org/wiki/Euler's_number

[reference manual]: http://research.microsoft.com/en-us/um/people/daan/madoko/doc/reference.html  "Madoko reference manual"
What am I doing wrong?

Many thanks

Paul

comments

pdoak wrote Feb 28 at 6:20 PM

I have reinstalled MacTex and now when I run Madoko locally, I get the following error:
 ❯ madoko -vv test.md                                                                                                                                                   [6:55:21 pm]
process: test.md -> out/test.html

  test: rendering math.
  test: running xelatex on math... (plain -> xdv -> svg)
  test: rerun to resolve references...
  test: create image directory: out/math
  test: generating math images...  (plain) (1-2)
  test: analyse and embed math images.
  error: cannot read: out/math/test-math-plain-1.svg
fs.js:774
  return binding.rename(pathModule._makeLong(oldPath),
                 ^

Error: ENOENT: no such file or directory, rename 'out/math/test-math-plain-1.svg' -> 'out/math/math-e1671797c52e15f763380b45e841ec32.svg'
    at Object.fs.renameSync (fs.js:774:18)
    at $renameSync (/usr/local/lib/node_modules/madoko/lib/storage.js:41:55)
    at xrename (/usr/local/lib/node_modules/madoko/lib/storage.js:250:10)
    at Object.rename (/usr/local/lib/node_modules/madoko/lib/storage.js:255:10)
    at dimLine (/usr/local/lib/node_modules/madoko/lib/mathStaticRun.js:171:26)
    at /usr/local/lib/node_modules/madoko/lib/mathStaticRun.js:188:137
    at /usr/local/lib/node_modules/madoko/lib/std_core.js:1266:102
    at mapIter (/usr/local/lib/node_modules/madoko/lib/std_core.js:1173:21)
    at mapIter (/usr/local/lib/node_modules/madoko/lib/std_core.js:1173:49)
    at mapIndexedPeek (/usr/local/lib/node_modules/madoko/lib/std_core.js:1180:10)
I have tested the MacTex installation with a test file and it seems to work. How can I get Madoko working locally?

daan wrote Feb 28 at 7:02 PM

Strange.. can you run with "-vvv" or even "-vvvv"? Also, can you try manually creating a "out/math" sub folder. Perhaps there is a mac issue that the folder is not created? If that fails, perhaps set the metadata key to "Math Render: png" to see if it is an issue with dvisvgm on the Mac.
Thanks!

pdoak wrote Feb 28 at 7:49 PM

The out/math folder does get produced. Below is the output using -vvv
 ❯ Madoko -vvv test.md                                                                                                                                                  [8:39:16 pm]
zsh: correct Madoko to madoko [nyae]? y
process: test.md -> out/test.html
parse inline
generate output
done
  warning: 0;/usr/local/lib/node_modules/madoko/lib/../styles/prelude.mdk:310: undefined variable: csl-style
  warning: 0;/usr/local/lib/node_modules/madoko/lib/../styles/prelude.mdk:332: undefined variable: cite-style
  warning: 19: reference to missing id: #euler

  test: rendering math.
  test: running xelatex on math... (plain -> xdv -> svg)
  test: > "xelatex"  --no-pdf --output-directory="out" --interaction=batchmode
  "out/test-math-plain.tex"
  test: rerun to resolve references...
  test: > "xelatex"  --no-pdf --output-directory="out" --interaction=batchmode
  "out/test-math-plain.tex"
  test: create image directory: out/math
  test: generating math images...  (plain) (1)
  test: > "dvisvgm" -n -b0.2pt -e -j -v3 -d3 -p1 -o "math/test-math-plain-%1p.s
  vg" "test-math-plain.xdv"
  test: analyse and embed math images.
  error: cannot read: out/math/test-math-plain-1.svg
fs.js:774
  return binding.rename(pathModule._makeLong(oldPath),
                 ^

Error: ENOENT: no such file or directory, rename 'out/math/test-math-plain-1.svg' -> 'out/math/math-e1671797c52e15f763380b45e841ec32.svg'
    at Object.fs.renameSync (fs.js:774:18)
    at $renameSync (/usr/local/lib/node_modules/madoko/lib/storage.js:41:55)
    at xrename (/usr/local/lib/node_modules/madoko/lib/storage.js:250:10)
    at Object.rename (/usr/local/lib/node_modules/madoko/lib/storage.js:255:10)
    at dimLine (/usr/local/lib/node_modules/madoko/lib/mathStaticRun.js:171:26)
    at /usr/local/lib/node_modules/madoko/lib/mathStaticRun.js:188:137
    at /usr/local/lib/node_modules/madoko/lib/std_core.js:1266:102
    at mapIter (/usr/local/lib/node_modules/madoko/lib/std_core.js:1173:21)
    at mapIter (/usr/local/lib/node_modules/madoko/lib/std_core.js:1173:49)
    at mapIndexedPeek (/usr/local/lib/node_modules/madoko/lib/std_core.js:1180:10)
This is the error using -vvvv
 warning: 0;/usr/local/lib/node_modules/madoko/lib/../styles/prelude.mdk:310: undefined variable: csl-style
  warning: 0;/usr/local/lib/node_modules/madoko/lib/../styles/prelude.mdk:332: undefined variable: cite-style

  test: rendering math.
  test: running xelatex on math... (plain -> xdv -> svg)
  test: > "xelatex"  --no-pdf --output-directory="out" --interaction=batchmode
  "out/test-math-plain.tex"
  test: rerun to resolve references...
  test: > "xelatex"  --no-pdf --output-directory="out" --interaction=batchmode
  "out/test-math-plain.tex"
  test: create image directory: out/math
  test: generating math images...  (plain) (1-2)
  test: > "dvisvgm" -n -b0.2pt -e -j -v3 -d3 -p1-2 -o "math/test-math-plain-%1p
  .svg" "test-math-plain.xdv"
  test: DVI error: DVI format 7 not supported

  test: analyse and embed math images.
  error: cannot read: out/math/test-math-plain-1.svg
fs.js:774
  return binding.rename(pathModule._makeLong(oldPath),
                 ^

Error: ENOENT: no such file or directory, rename 'out/math/test-math-plain-1.svg' -> 'out/math/math-e1671797c52e15f763380b45e841ec32.svg'
    at Object.fs.renameSync (fs.js:774:18)
    at $renameSync (/usr/local/lib/node_modules/madoko/lib/storage.js:41:55)
    at xrename (/usr/local/lib/node_modules/madoko/lib/storage.js:250:10)
    at Object.rename (/usr/local/lib/node_modules/madoko/lib/storage.js:255:10)
    at dimLine (/usr/local/lib/node_modules/madoko/lib/mathStaticRun.js:171:26)
    at /usr/local/lib/node_modules/madoko/lib/mathStaticRun.js:188:137
    at /usr/local/lib/node_modules/madoko/lib/std_core.js:1266:102
    at mapIter (/usr/local/lib/node_modules/madoko/lib/std_core.js:1173:21)
    at mapIter (/usr/local/lib/node_modules/madoko/lib/std_core.js:1173:49)
    at mapIndexedPeek (/usr/local/lib/node_modules/madoko/lib/std_core.js:1180:10)
Putting Math Render: png as metadata gives this error:
done
  warning: 0;/usr/local/lib/node_modules/madoko/lib/../styles/prelude.mdk:310: undefined variable: csl-style
  warning: 0;/usr/local/lib/node_modules/madoko/lib/../styles/prelude.mdk:332: undefined variable: cite-style

  test: rendering math.
  test: running latex on math...   (plain -> dvi -> png)
  test: > "latex" --output-directory="out" --interaction=batchmode "out/test-ma
  th-plain.tex"
  test: generating math images...  (plain) (1-2)
  test: > "dvipng" -T tight -z9 -bg Transparent -D300 -pp 1-2 -o "math/test-mat
  h-plain-%d.png" "test-math-plain"
  test: This is dvipng (dvipng (TeX Live)) 1.15 Copyright 2002-2015 Jan-Ake Lar
  sson
  [1] [2]
  dvipng warning: at (4294967295,17) unimplemented \special{dvisvgm:bbox 0.01 0
  .01} dvipng warning: at (18,17) unimplemented \special{dvisvgm:bbox 0.01 0.01}
  test: analyse and embed math images.
  test:  math images  :    0 in  0.0 kb
  test:  math embedded:    2 in  5.9 kb
  test:  math total   :    2 in  5.9 kb
  test: re-aligning math in HTML.
Let me know if you need anything else.

Many Thanks

Paul

pdoak wrote Mar 1 at 7:18 AM

I have noticed that the dvisvgm that is installed on my system cannot process specials. The output of dvisvgm -l is:
 ❯ dvisvgm -l                                                                                                                                                           [8:10:00 am]
bgcolor    background color special
color      complete support of color specials
dvisvgm    special set for embedding raw SVG snippets
em         line drawing statements of the emTeX special set
html       hyperref specials
pdf        pdfTeX font map specials
tpic       TPIC specials
 ❯ dvisvgm -V1                                                                                                                                                          [8:13:09 am]
dvisvgm (TeX Live) 1.15.1 (x86_64-apple-darwin10.8.0)
-----------------------------------------------------
clipper:     6.2.1
freetype:    2.6.3
kpathsea:    6.2.2
potrace:     1.13
xxhash:      0.5.0
zlib:        1.2.8
Is this the problem?

daan wrote Mar 8 at 5:54 PM

Hi Paul,

Sorry for the late replies :(
Can you also run dvisvgm -V for me? I got 1.14 on my system.
Anyway, the main problem is I think here:
 test: > "dvisvgm" -n -b0.2pt -e -j -v3 -d3 -p1-2 -o "math/test-math-plain-%1p
  .svg" "test-math-plain.xdv"
  test: DVI error: DVI format 7 not supported
I am not sure what that exactly means, but it might have to do with using XeLaTeX. Perhaps things will work with pdf latex. Set the meta data key Pdf Latex: pdflatex to generate math using pdflatex instead. Let me know if that works.
Best,
-- Daan

pdoak wrote Mar 9 at 9:37 AM

Hi Daan

Thanks for getting back to me.

In answer to your questions:
 ❯ dvisvgm -V                                                                                                                                                          
dvisvgm (TeX Live) 1.15.1
Adding the meta data key worked!!

Two further questions:
  1. Is there a way to force math using pdflatex without using the meta data key on each document; and
  2. I am using a great program, called Marked 2, to preview my documents. The program allows for a custom processing engine to be used and I would like to use Madoko. It needs the processing engine to accept stdin and output on stdout. Is it possible to use Madoko like that?
Many Thanks

Paul

daan wrote Mar 9 at 4:39 PM

Ah glad to hear this! On my other system I am using dvisvgm version 1.15 too without problems so I am not sure where the XDV format error comes from. Perhaps it is a newer version of XeLaTex? Can you check the version too? Or perhaps it is OSX related?

You can pass the math option by using -mpdf-latex:pdflatex as a command line option. (-m followed by a semi-colon separated list of meta data keys).

I will try Marked 2 soon -- it would be great to support such programs. However, as of now, Madoko doesn't have a pure stdin/stdout mechanism; in general that does not work great as often you need things like images, included files, bibliography files, latex style files, cached math images, etc etc. Madoko is much more powerful than most other engines because it takes care of all those things for you which you quickly need for non-trivial documents. I wonder how Marked 2 does with that -- as long as you can run Madoko at some specific directory where it can read and write files this may work; usually Madoko takes the main document file and reads/writes in the directory under it; writing output to <dir>/out and reading from directories like <dir>/images for examples.

If I get some time this weekend I'll try to install Marked 2 and see if it can deal with this. I'll also add an option to Madoko to read from stdin and write to stdout -- perhaps with an extra option to specify a 'scratch' directory where it can read/write/cache files.

ps. you may hack up a little wrapper shell script around Madoko to do this; i.e. just write stdin to a temporary file, run Madoko, and echo /out/<file>.html back.

pdoak wrote Mar 9 at 6:36 PM

Daan

Thanks for the response.

The XeLaTex version is This is XeTeX, Version 3.14159265-2.6-0.99996 (TeX Live 2016).

It would be great if you could add an option to read from stdin and write to stdout.

In the meantime, I will try and write a wrapper shell script around Madoko and see if I can get it to work.

Many Thanks

Paul

pdoak wrote Mar 12 at 10:14 PM

Update:

If I add the meta data pdf Latex: pdflatex, and use the following code in a file:
* This is a 'mylist' 
* in italics
{ .mylist; font-family: Consolas }
I get this error when trying to generate a pdf:

resolved font stack 'Consolas' to: Consolas

! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...ror: Something's wrong--perhaps a missing \protect \item .

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help\@err@                                                                   
                                                                                                                                                                                                                                      
l.98 \item\mdline
                 {64}This is a \mdline{64}\textquoteleft{}mylist\textquoteright{}\mdline{64}%mdk
Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.
I think this is happening because it is not possible to use a system font with pdflatex. It seems that I need to resolve the error with dvisvgm so that I can output with xelatex.

Regards

Paul

daan wrote Mar 17 at 10:30 PM

Hi Paul,

Ah, sorry to hear you have so many hurdles to overcome :-)
You can use XeLatex for generating a PDF, and only use PDF latex for math fragments that are included in the final HTML. Use the keys:
Math Latex: pdflatex
Math Latex Full: pdflatex
to do this (and don't set Pdf Latex anymore so xelatex is used for that. On the command line you can do this through: -mmath-latex:pdflatex -mmath-latex-full:pdflatex

Let me know how it goes.
Best,
-- Daan