No clue how to do this for a (printed) page (I'm looking for that myself), but for footnotes by section, couldn't you just break the input document into the sections before you pass them to pandoc, and then reassemble the parts afterwards?
E.g. suppose your markdown file looks like this (myfile.md):
Some text with a footnote.^[First note.]
----
Some more text with a footnote.^[Second note.]
----
And a third passage.^[Third note.]
Then you could use, e.g., the following PHP script (though I'm sure there a million ways to do this), i.e., pandoc-sections.php
.
<?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);
}
}
?>
Then run
php pandoc-sections.php myfile.md
And you get:
<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>
Adapt as needed.