1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
//
// Footnote module v.1.1
//
// (c) Karl Stevens <karl@maxim.ca>
// suggestions and improvements by GPL (Gilles.Perez-Lambert@univ-montp3.fr)
//
//
// This file may be distributed freely under the provisions of the
// GNU Public License (GPL).
//
// This module adds footnotes (which are embedded in the RXML document) to
// the bottom of the page.
//
// Usage: <footnote> ... </footnote>
// .... <footnotes>
//
// The <footnote> container defines the footnote, this is removed from the
// document, and replaced with a link to the appropriate anchor.
// The <footnotes> tag inserts all footnotes and anchors
//
#include <module.h>
#include <process.h>
inherit "module";
inherit "roxenlib";
array register_module()
{
return ({ MODULE_PARSER,
"Footnotes tags",
"Allows the insertion of footnotes to the body of a document. "
"Adds the container <footnote> and the tag <footnotes>.<br>"
"<footnote> adds a footnote to a document,"
"<footnotes> displays all footnotes.", ({}), 1
});
}
void create()
{
defvar("tagtext", "footnote", "Default text to add to the footnote link text",
TYPE_STRING,
"This will be added to the names of the links Footnote creates."
" This can be overridden by the page author by using the "
"argument NAME inside the <footnote> tag.");
defvar("linebreak", "<BR>", "HTML inserted after each footnote",
TYPE_STRING|VAR_MORE,
"You should make this something that will cause a line break");
defvar("linkpre","<SUP>", "Footnote link pre-HTML",
TYPE_STRING|VAR_MORE,
"This is the HTML that will be inserted before the footnote link, "
"to change the style. This should really be a single HTML tag, "
"additional style info should be changed with a Style Sheet.");
defvar("linkpost","</SUP>", "Footnote link post-HTML",
TYPE_STRING|VAR_MORE,
"This is the HTML that will be inserted after the footnote link, "
"to change the style. This should really be a single HTML tag, "
"additional style info should be changed with a Style Sheet.");
// GPL - Two more variables added to control footnote appearance.
defvar("linkprel"," ", "Footnote reference pre-HTML",
TYPE_STRING|VAR_MORE,
"This is the HTML that will be inserted before the footnote reference.");
defvar("linkpostl",". ", "Footnote reference post-HTML",
TYPE_STRING|VAR_MORE,
"This is the HTML that will be inserted after the footnote reference.");
}
string container_footnote(string tag, mapping m, string q, object request_id )
{
string footnotes;
int fncount=request_id->misc->KS_FNMod_footnotecount;
if (fncount > 0)
footnotes=request_id->misc->KS_FNMod_footnotes;
else footnotes="";
fncount++;
string t;
if (m->name)
t=(string)m->name;
else
t=QUERY(tagtext)+fncount;
// GPL - added reverse anchor and pre/post HTML for link
footnotes=footnotes+QUERY(linkprel)+"<a name=\""+t+"\" href=\"#r"+t+"\">"+fncount+"</a>"+QUERY(linkpostl)+q+QUERY(linebreak)+"\n";
request_id->misc->KS_FNMod_footnotecount=fncount;
request_id->misc->KS_FNMod_footnotes=footnotes;
// GPL - added name to be able to be referencef by the footnote itself
return QUERY(linkpre)+"<a href=\"#"+t+"\" name=\"r"+t+"\">"+fncount+"</a>"+QUERY(linkpost);
}
string tag_footnotes( string tag, mapping m, object request_id, object f,mapping d )
{
return request_id->misc->KS_FNMod_footnotes;
}
mapping query_container_callers()
{ return (["footnote":container_footnote,]); }
mapping query_tag_callers()
{ return (["footnotes":tag_footnotes,]); }
|