Theorem Environments

Implement amsthm-like Theorem environments with Maruku.
Support is based on Maruku "div"s with special class-names.
Classes
    num_*
produce numbered environments, and

    un_*

produce un-numbered environments, where * is one of

   theorem     (for Theorem)
   lemma       (for Lemma)
   prop        (for Proposition)
   cor         (for Corollary)
   def         (for Definition)
   example     (for Example)
   remark      (for Remark)
   note        (for Note)

In addition, the class

   proof

produces a Proof environment.

The LaTeX export works as expected, and these also work in the S5 view.

Bumped version number.
This commit is contained in:
Jacques Distler 2008-10-17 16:26:17 -05:00
parent 6f3e9a9e17
commit 34082fbf94
12 changed files with 175 additions and 16 deletions

View file

@ -809,6 +809,29 @@ function windowChange() {
fontScale();
}
function fixRunIn() {
// work around lack of gecko support for display:run-in
var re = /^num_|\s+num_|^un_|\s+un_|proof/;
$$('div > h6').each(function(element) {
if(re.test($(element.parentNode).className)) {
var new_span = new Element('span').update(element.textContent);
new_span.addClassName('theorem_label');
var next_el = element.next().firstChild;
next_el.parentNode.insertBefore(new_span, next_el);
var period = new Element('span').update('. ');
next_el.parentNode.insertBefore(period, next_el);
element.remove();
}
});
// add tombstone to proof, since gecko doesn't support :last-child properly
$$('div.proof').each(function(element) {
var l = element.childElements().length -1;
var span = new Element('span').update('\u00a0\u00a0\u25ae');
element.childElements()[l].insert(span);
})
}
function startup() {
defaultCheck();
createControls(); // hallvord
@ -819,6 +842,7 @@ function startup() {
fixLinks();
externalLinks();
fontScale();
fixRunIn();
if (!isOp) notOperaFix();
slideJump();
if (defaultView == 'outline') {