2016-03-31 10 views
3

私はMarkdown記法でインライン脚注の使用を開始しました:HTMLのページまたはセクションの下部にパンドルク脚注がありますか?

Some text^[an aside here]. More text. 

私は、彼らが全体の文書の最後に表示されますが、PDFで、彼らはページの最後に表示されるHTMLにエクスポートするpandocを使用する場合。私はページの終わりにそれらを好む、私はHTMLでそれらをそれらの方法で得る方法があるかどうか疑問に思っていますか?

私はページの最後がHTMLで複雑になることを認識しています。セクションの終わりは私のためだけにうまくいくでしょう。実際には、ページの最後ではなく、PDFのセクションの最後に配置すると便利な場合もあります。 (私は、セクション区切りとして---を入れて試してみたが、脚注は、まだ文書の最後に終わる。)

(私も作品の種類を、pdf2htmlそして、PDFを作ってみましたが、本当にありましたハード目にPandocはHTMLにPDFファイルをサポートしていないようだ、私は「バイト 『\ XD0』を...解読することはできません」を取得)


(これは、の重複ではありません:Generate inline rather than list-style footnotes in Pandoc Markdown output?その質問ですのマークダウン形式を別の形式から移動するときの脚注の処理方法について)

+0

[Pandoc Markdownの出力ではリストスタイルの脚注ではなくインラインを生成しますか?](http://stackoverflow.com/questions/33984689/generate-inline-rather-than-list-style-footnotes-in- – Waylan

答えて

0

私はそれを自分で探していますが、セクション別の脚注では、入力文書をセクションに分割してからの前にpandocに渡すことはできませんでした。後で部品を再組み立てしますか?

など。

Some text with a footnote.^[First note.] 
---- 
Some more text with a footnote.^[Second note.] 
---- 
And a third passage.^[Third note.] 

次にあなたがpandoc-sections.php、すなわち、(私はこれを行うにはそこに百万の方法確信しているが)、例えば、以下のPHPスクリプトを使用することができますあなたの値下げファイルがこの(myfile.md)のように見えたとします。

<?php 

$input_file = $argv[1]; 

if (!file_exists($input_file)) { 
    exit('File not found.'); 
} 

$chunks = preg_split('/\n-----*\n/',file_get_contents($input_file)); 

for ($i=0; $i<count($chunks); $i++) { 
    $chunk = $chunks[$i]; 
    $idprefix = "section" . ($i+1); 

    $descriptorspec = array(
     0 => array("pipe", "r"), // stdin 
     1 => array("pipe", "w"), // stdout 
     2 => array("pipe", "w") // stderr 
    ); 

    $pandoc_process = proc_open('pandoc --id-prefix=' . 
     $idprefix, $descriptorspec, $pipes); 

    if (is_resource($pandoc_process)) { 
     fwrite($pipes[0], $chunk); 
     fclose($pipes[0]); 
     echo stream_get_contents($pipes[1]); 
     fclose($pipes[1]); 
     fclose($pipes[2]); 
     proc_close($pandoc_process); 
    } 

}  

?> 

はその後

php pandoc-sections.php myfile.md

を実行して、あなたが得る:必要に応じて

<p>Some text with a footnote.<a href="#section1fn1" class="footnote-ref" id="section1fnref1"><sup>1</sup></a></p> 
<section class="footnotes"> 
<hr /> 
<ol> 
<li id="section1fn1"><p>First note.<a href="#section1section1fnref1" class="footnote-back">↩</a></p></li> 
</ol> 
</section> 
<p>Some more text with a footnote.<a href="#section2fn1" class="footnote-ref" id="section2fnref1"><sup>1</sup></a></p> 
<section class="footnotes"> 
<hr /> 
<ol> 
<li id="section2fn1"><p>Second note.<a href="#section2section2fnref1" class="footnote-back">↩</a></p></li> 
</ol> 
</section> 
<p>And a third passage.<a href="#section3fn1" class="footnote-ref" id="section3fnref1"><sup>1</sup></a></p> 
<section class="footnotes"> 
<hr /> 
<ol> 
<li id="section3fn1"><p>Third note.<a href="#section3section3fnref1" class="footnote-back">↩</a></p></li> 
</ol> 
</section> 

は適応します。

+0

ちょっと、 "--id-prefix"オプションが使われているときに、pandocがバックリンクをどのように処理するかのバグを公開しました。私はバグレポートを提出します。彼らは物事を修正するのに非常に迅速です。 – frabjous

関連する問題