2013-04-25 59 views
3

我試圖使用pandoc生成一個帶有一些乳膠的降價文件的html幻燈片。獲取與pandoc和mathjax的一些問題

該文件是here at github

如果我運行下面的命令pandoc:

pandoc -s -t s5 --mathjax apresentacao.md -o index.html 

數學是完全由MathJax顯示出來,但我只得到一個網頁的所有幻燈片,也沒有幻燈片功能。

如果我運行follwing命令:

pandoc -s --self-contained -t s5 --mathjax apresentacao.md -o index.html 

我得到一個完全沒有問題的介紹,但MathJax加載失敗。生成的html文件(難以忍受)充滿了二進制文件,用於加載的圖像和JavaScript庫。但它似乎沒有正確納入MathJax。

你們有這個問題嗎?有沒有簡單的方法來解決這個問題?

我使用以下pandoc版本:

$ pandoc --version 
pandoc 1.11.1 
Compiled with citeproc-hs 0.3.8, texmath 0.6.1.3, highlighting-kate 0.5.3.8. 
Syntax highlighting is supported for the following languages: 
    actionscript, ada, apache, asn1, asp, awk, bash, bibtex, boo, c, changelog, 
    clojure, cmake, coffee, coldfusion, commonlisp, cpp, cs, css, curry, d, 
    diff, djangotemplate, doxygen, doxygenlua, dtd, eiffel, email, erlang, 
    fortran, fsharp, gnuassembler, go, haskell, haxe, html, ini, java, javadoc, 
    javascript, json, jsp, julia, latex, lex, literatecurry, literatehaskell, 
    lua, makefile, mandoc, matlab, maxima, metafont, mips, modula2, modula3, 
    monobasic, nasm, noweb, objectivec, objectivecpp, ocaml, octave, pascal, 
    perl, php, pike, postscript, prolog, python, r, relaxngcompact, rhtml, ruby, 
    rust, scala, scheme, sci, sed, sgml, sql, sqlmysql, sqlpostgresql, tcl, 
    texinfo, verilog, vhdl, xml, xorg, xslt, xul, yacc, yaml 
Default user data directory: /home/calsaverini/.pandoc 
Copyright (C) 2006-2013 John MacFarlane 
Web: http://johnmacfarlane.net/pandoc 
This is free software; see the source for copying conditions. There is no 
warranty, not even for merchantability or fitness for a particular purpose. 
+0

我假設你打算在第二個命令行中加入'--self-contained'。見https://github.com/jgm/pandoc/issues/682 – 2013-04-25 05:45:49

+0

好的指出,我會解決它。 – 2013-04-25 17:27:55

回答

8

這是一個known issue--mathjax--self-contained很好地工作。我還沒有研究它足以提出一個修復,但建議表示歡迎。

+0

哇!由John MacFarlane親自制作的一款水管! :D感謝您指出。任何想法爲什麼第一個命令不能產生工作演示文稿?我用s5,slim和其他一些後端嘗試了它們,所有這些只是簡單的網頁,並且沒有任何內容。 – 2013-04-25 17:31:42

+1

引用自述文件:「對於Slidy,Slideous,reveal.js和S5,pandoc使用'-s/- standalone'選項生成的文件嵌入了一個鏈接到javascript和CSS文件,這些文件假定可以在相對路徑's5/default'(對於S5),...「我假設你沒有s5文件。 – 2013-04-25 21:28:01

0

我只是寫了一個python腳本編譯降價文件轉換成一個獨立的(需要互聯網連接)與mathjax支持HTML文件:

#!/usr/bin/env python 
''' 
pandoc_compile.py 

Usage: 
pandoc_compile.py markdown_file template_file 
''' 
import subprocess, re, sys, os 

print("Compiling Markdown file: "+sys.argv[1]) 
print("Using template: "+sys.argv[2]) 
print("Output file: "+sys.argv[1]+".html") 
pandoc_result = subprocess.Popen(['pandoc','--mathjax',sys.argv[1]], stdout=subprocess.PIPE).stdout.read() 
with open(sys.argv[2]) as f: template = f.read() 
final_result = re.sub('{{pandoc_output}}', pandoc_result, template) 
with open(sys.argv[1]+".html", "w") as f: f.write(final_result) 

它編譯降價與pandoc,然後把結果放在下面的HTML模板。

<html> 

<head> 
<script type="text/javascript" 
    src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> 
</script> 
</head> 

<body> 

{{pandoc_output}} 

</body> 
</html> 
+0

未來的注意事項:cdn.mathjax.org即將到期,請查看https://mathjax.org/cdn-shutting-down獲取遷移提示。 – 2017-04-13 13:18:24