3

John MacFarlane hereによる Haskell ソリューションを実装しようとしています。これにより、数学を維持しながら、MathJax (ラテックス) 入力を含む HTML ファイルを .tex に変換できるようになります。スクリプトは次のとおりです。

import Text.Pandoc

main = toJsonFilter fixmath

fixmath :: Block -> Block
fixmath = bottomUp fixmathBlock . bottomUp fixmathInline

fixmathInline :: Inline -> Inline
fixmathInline (RawInline "html" ('<':'!':'-':'-':'M':'A':'T':'H':xs)) =
  RawInline "tex" $ take (length xs - 3) xs
fixmathInline x = x

fixmathBlock :: Block -> Block
fixmathBlock (RawBlock "html" ('<':'!':'-':'-':'M':'A':'T':'H':xs)) =
  RawBlock "tex" $ take (length xs - 3) xs
fixmathBlock x = x

Haskell の 64 ビット OSX バージョンをインストールしcabal install pandoc、pandoc 関数を取得するコマンドも指定しました。ただし、実行すると

ghc --make fixmath.hs

次のエラーが表示されます。

[1 of 1] Compiling Main             ( fixmath.hs, fixmath.o )

fixmath.hs:9:26:
    Couldn't match expected type `Format' with actual type `[Char]'
    In the pattern: "html"
    In the pattern:
      RawInline "html"
                ('<' : '!' : '-' : '-' : 'M' : 'A' : 'T' : 'H' : xs)
    In an equation for `fixmathInline':
        fixmathInline
          (RawInline "html"
                     ('<' : '!' : '-' : '-' : 'M' : 'A' : 'T' : 'H' : xs))
          = RawInline "tex" $ take (length xs - 3) xs

fixmath.hs:10:13:
    Couldn't match expected type `Format' with actual type `[Char]'
    In the first argument of `RawInline', namely `"tex"'
    In the expression: RawInline "tex"
    In the expression: RawInline "tex" $ take (length xs - 3) xs

fixmath.hs:14:24:
    Couldn't match expected type `Format' with actual type `[Char]'
    In the pattern: "html"
    In the pattern:
      RawBlock "html"
               ('<' : '!' : '-' : '-' : 'M' : 'A' : 'T' : 'H' : xs)
    In an equation for `fixmathBlock':
        fixmathBlock
          (RawBlock "html"
                    ('<' : '!' : '-' : '-' : 'M' : 'A' : 'T' : 'H' : xs))
          = RawBlock "tex" $ take (length xs - 3) xs

fixmath.hs:15:12:
    Couldn't match expected type `Format' with actual type `[Char]'
    In the first argument of `RawBlock', namely `"tex"'
    In the expression: RawBlock "tex"
    In the expression: RawBlock "tex" $ take (length xs - 3) xs

何が問題で、どうすればよいですか?

4

1 に答える 1