[sword-devel] Html filter questions

Troy A. Griffitts scribe at crosswire.org
Sun Feb 18 20:52:14 MST 2007


A couple comments below:

Ben Morgan wrote:
> Hi.
> I have some questions with the FMT_HTMLHREF filter. Let's say I do the 
> following in python:
> from Sword import *
> mgr = SWMgr(MarkupFilterMgr(FMT_HTMLHREF, ENC_HTML))
> mgr.setGlobalOption("Footnotes", "On")
> mod=mgr.getModule("ESV")
> mod.RenderText(VerseKey("John 3:1"))
> What I get out is this (breaking it up for legibility):
>     Now there was a man of the Pharisees named
>     <a
>     href="passagestudy.jsp?action=showNote&type=x&value=1&module=ESV&passage=John+3%3A1"><small><sup>*x</sup></small></a>

You shouldn't get cross-references out when you turn on "Footnotes". 
But I still think I understand your request.  The current HTMLHREF 
filter set renders href links for most attributes of a verse (HTML 
HREF).  This is the purpose of the filter set.  You are requesting 
cross-reference type footnotes to show the verse references inline 
instead of the superscripted *x.  This seems a reasonable request and is 
doable, but will require a little work on your part on the C++ side.  I 
don't think the python bindings will allow extending C++ classes, but I 
could be wrong.  You will need to:

inherit the OSISHTMLHREF class
override handleToken and handle note tags specially with code like:

bool MyOSISRenderFilter::handleToken(SWBuf &buf, const char *token, 
BasicFilterUserData *userData) {
	XMLTag tag(token);
	if (!strcmp(tag.getName(), "note")) {
		buf += /* Your markup here */
	else {
		return OSISHTMLHREF::handleToken(buf, token, userData);
	return true;

(You can copy OSISWEBIF as an example)

Then inject your render filter into the engine:

inherit SWMgr and override AddRenderFilters with a code like:

void MySWMgr::AddRenderFilters(SWModule *module, ConfigEntMap &section) {
	static MyOSISRenderFilter myOSISRenderFilter;
         switch (module->Markup()) {
         case FMT_OSIS:
	        SWMgr::AddRenderFilters(module, section);

Once this is all in place, it will give you the ability to override any 
tag you desire when the default behaviour of OSISHTMLHREF is not 
sufficient for you.

Hope this is helpful.


>     Nicodemus,
>     <a
>     href="passagestudy.jsp?action=showNote&type=x&value=2&module=ESV&passage=John+3%3A1"><small><sup>*x</sup></small></a>
>      a ruler of the Jews.' 
> Is there any way to get the third cross reference so that instead of:
> <a 
> href="passagestudy.jsp?action=showNote&type=x&value=1&module=ESV&passage=John+3%3A16"><small><sup>*x</sup></small></a> 
> we have something like:
> <a 
> href="passagestudy.jsp?action=openRef&module=ESV&passage=John+7%3A50"><small><sup>John 
> 7:50</sup></small></a>
> <a 
> href="passagestudy.jsp?action=openRef&module=ESV&passage=John+19%3A39"><small><sup>John 
> 19:39</sup></small></a>
> I do not want a solution where I manually look up the entry attributes 
> to get each one, as this will add lots of overhead.
> Also, look at John 3:2 and the first note.
> Its entry attributes are the following
> ('body', 'Greek <hi type="i">him</hi>'),
> ('n', '1'),
> ('osisID', ' John.3.2.note_1'),
> ('type', 'explanation')
> For a start, shouldn't it be <i>him</i>?
> Also, I would like to have the note number displayed, maybe, instead of 
> "*n". Is this possible?
> Without more flexibility, I do not particularly think one html filter is 
> a good idea. What I would really like is to have a callback or virtual 
> function that will be called everytime a certain thing comes up - but 
> this cannot be done at the moment. Then you could have predefined 
> classes - an rtf one, an html one, etc, but still override the 
> particular bits you need/want to.
> God Bless,
> Ben
> ------------------------------------------------------------------------------------------- 
> Be wretched and mourn and weep. Let your laughter be turned to mourning 
> and your joy to gloom.
> James 4:9 (ESV)
> ------------------------------------------------------------------------
> _______________________________________________
> sword-devel mailing list: sword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/sword-devel
> Instructions to unsubscribe/change your settings at above page

More information about the sword-devel mailing list