Skip to content
Snippets Groups Projects
Commit 788f5d27 authored by Fredrik Hübinette (Hubbe)'s avatar Fredrik Hübinette (Hubbe)
Browse files

made html_section_pages work better (links to sections)

Rev: tutorial/html.pike:1.33
Rev: tutorial/html_section_pages.pike:1.3
parent fd9ec584
No related branches found
No related tags found
No related merge requests found
...@@ -559,6 +559,10 @@ SGML convert(SGML data) ...@@ -559,6 +559,10 @@ SGML convert(SGML data)
} }
else else
{ {
if(!objectp(data))
{
error("Tag is neither string nor object: %O\n",data);
}
cpos=data->pos; cpos=data->pos;
switch(data->tag) switch(data->tag)
{ {
...@@ -903,15 +907,9 @@ SGML wmml_to_html(SGML data) ...@@ -903,15 +907,9 @@ SGML wmml_to_html(SGML data)
}); });
} }
SGML split_tag(TAG t, TAG t2)
SGML low_split(SGML data)
{
SGML current=({});
foreach(data, TAG t)
{
if(objectp(t))
{ {
TAG t2=get_tag(t); array current=({});
switch(t2->tag) switch(t2->tag)
{ {
case "preface": case "preface":
...@@ -924,7 +922,7 @@ SGML low_split(SGML data) ...@@ -924,7 +922,7 @@ SGML low_split(SGML data)
Sgml.Tag("hr") Sgml.Tag("hr")
})+ })+
sections->introduction; sections->introduction;
continue; return current;
case "introduction": case "introduction":
if(!sections->introduction) if(!sections->introduction)
...@@ -939,18 +937,17 @@ SGML low_split(SGML data) ...@@ -939,18 +937,17 @@ SGML low_split(SGML data)
sections->introduction+=({ sections->introduction+=({
t t
}); });
continue; return current;
case "index": case "index":
sections[t2->params->name || "index"]=({ t }); sections[t2->params->name || "index"]=({ t });
continue; return current;
case "chapter": case "chapter":
case "appendix": case "appendix":
t2->data=low_split(t2->data);
sections[t2->params->number]=({ t }); sections[t2->params->number]=({ t });
if (this_object()->split_and_remove_section) return current;
this_object()->split_and_remove_section(t);
continue;
case "firstpage": case "firstpage":
current+= current+=
...@@ -962,7 +959,7 @@ SGML low_split(SGML data) ...@@ -962,7 +959,7 @@ SGML low_split(SGML data)
sections->firstpage=({ sections->firstpage=({
t, t,
}); });
continue; return current;
case "table-of-contents": case "table-of-contents":
sections->frame=({ sections->frame=({
...@@ -989,9 +986,27 @@ SGML low_split(SGML data) ...@@ -989,9 +986,27 @@ SGML low_split(SGML data)
if(t->data) if(t->data)
t->data=low_split(t->data); t->data=low_split(t->data);
} }
return ({t});
}
SGML low_split(SGML data)
{
SGML current=({});
foreach(data, TAG t)
{
if(objectp(t))
{
SGML tmp=split_tag(t,get_tag(t));
if(search(tmp,0) != -1)
{
error("Got zero! %O\n",tmp);
} }
current+=tmp;
}else{
current+=({t}); current+=({t});
} }
}
return current; return current;
} }
......
...@@ -2,28 +2,27 @@ ...@@ -2,28 +2,27 @@
#if __VERSION__ >= 0.6 #if __VERSION__ >= 0.6
import "."; import ".";
#endif /* __VERSION__ >= 0.6 */ #endif /* __VERSION__ >= 0.6 */
inherit "html"; inherit "html.pike";
void split_and_remove_section(object t,object prev)
{ SGML split_tag(TAG t, TAG t2)
if (t->data)
foreach (t->data,object t2)
if (objectp(t2))
{
split_and_remove_section(t2,t->tag=="anchor"?t:0);
if (t2->tag=="section")
{ {
object tq; switch(t2->tag)
if (prev)
{ {
case "section":
t2->data=low_split(t2->data);
sections[t2->params->number]=({t}); sections[t2->params->number]=({t});
prev->data-=({t}); return ({
} Sgml.Tag("h3",0,0,({
else Sgml.Tag("link",(["to":t2->params->number]),0,
{ ({
sections[t2->params->number]=({t2}); sprintf("%s %s",
t->data-=({t2}); t2->params->number,
} (string) t2->params->title),
} })),
})
});
} }
return ::split_tag(t,t2);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment