mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 09:02:01 +00:00
Handle contents listings.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@11791 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d7e28f6deb
commit
0d425b4731
5 changed files with 169 additions and 6 deletions
|
@ -35,6 +35,10 @@
|
||||||
NSString *nextFile; // Not retained
|
NSString *nextFile; // Not retained
|
||||||
NSString *prevFile; // Not retained
|
NSString *prevFile; // Not retained
|
||||||
NSString *upFile; // Not retained
|
NSString *upFile; // Not retained
|
||||||
|
unsigned chap;
|
||||||
|
unsigned sect;
|
||||||
|
unsigned ssect;
|
||||||
|
unsigned sssect;
|
||||||
}
|
}
|
||||||
- (void) decIndent;
|
- (void) decIndent;
|
||||||
- (void) incIndent;
|
- (void) incIndent;
|
||||||
|
|
106
Tools/AGSHtml.m
106
Tools/AGSHtml.m
|
@ -344,6 +344,10 @@ static NSMutableSet *textNodes = nil;
|
||||||
else if ([name isEqual: @"chapter"] == YES)
|
else if ([name isEqual: @"chapter"] == YES)
|
||||||
{
|
{
|
||||||
heading = @"h1";
|
heading = @"h1";
|
||||||
|
chap++;
|
||||||
|
sect = 0;
|
||||||
|
ssect = 0;
|
||||||
|
sssect = 0;
|
||||||
[self outputNodeList: children to: buf];
|
[self outputNodeList: children to: buf];
|
||||||
}
|
}
|
||||||
else if ([name isEqual: @"class"] == YES)
|
else if ([name isEqual: @"class"] == YES)
|
||||||
|
@ -372,6 +376,98 @@ static NSMutableSet *textNodes = nil;
|
||||||
[self outputText: children to: buf];
|
[self outputText: children to: buf];
|
||||||
[buf appendString: @"</code>"];
|
[buf appendString: @"</code>"];
|
||||||
}
|
}
|
||||||
|
else if ([name isEqual: @"contents"] == YES)
|
||||||
|
{
|
||||||
|
NSDictionary *dict;
|
||||||
|
|
||||||
|
dict = [[localRefs refs] objectForKey: @"contents"];
|
||||||
|
if ([dict count] > 0)
|
||||||
|
{
|
||||||
|
NSArray *a;
|
||||||
|
unsigned i;
|
||||||
|
unsigned l = 0;
|
||||||
|
|
||||||
|
[buf appendString: indent];
|
||||||
|
[buf appendString: @"<hr />\n"];
|
||||||
|
[buf appendString: indent];
|
||||||
|
[buf appendString: @"<h3>Contents -</h3>\n"];
|
||||||
|
|
||||||
|
a = [dict allKeys];
|
||||||
|
a = [a sortedArrayUsingSelector: @selector(compare:)];
|
||||||
|
for (i = 0; i < [a count]; i++)
|
||||||
|
{
|
||||||
|
NSString *k = [a objectAtIndex: i];
|
||||||
|
NSString *v = [dict objectForKey: k];
|
||||||
|
unsigned pos = 3;
|
||||||
|
|
||||||
|
if ([k hasSuffix: @"000"] == YES)
|
||||||
|
{
|
||||||
|
pos = 2;
|
||||||
|
if ([k hasSuffix: @"000000"] == YES)
|
||||||
|
{
|
||||||
|
pos = 1;
|
||||||
|
if ([k hasSuffix: @"000"] == YES)
|
||||||
|
{
|
||||||
|
pos = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (l == pos)
|
||||||
|
{
|
||||||
|
[buf appendString: indent];
|
||||||
|
[buf appendString: @"<ol>\n"];
|
||||||
|
[self incIndent];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (l > pos + 1)
|
||||||
|
{
|
||||||
|
[self decIndent];
|
||||||
|
[buf appendString: indent];
|
||||||
|
[buf appendString: @"</li>\n"];
|
||||||
|
[self decIndent];
|
||||||
|
[buf appendString: indent];
|
||||||
|
[buf appendString: @"</ol>\n"];
|
||||||
|
l--;
|
||||||
|
}
|
||||||
|
if (l == pos + 1)
|
||||||
|
{
|
||||||
|
[self decIndent];
|
||||||
|
[buf appendString: indent];
|
||||||
|
[buf appendString: @"</li>\n"];
|
||||||
|
l--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[buf appendString: indent];
|
||||||
|
[buf appendString: @"<li>\n"];
|
||||||
|
[self incIndent];
|
||||||
|
[buf appendString: indent];
|
||||||
|
[buf appendFormat: @"<a href=\"#%@\">%@</a>\n", k, v];
|
||||||
|
if (pos == 3)
|
||||||
|
{
|
||||||
|
[self decIndent];
|
||||||
|
[buf appendString: indent];
|
||||||
|
[buf appendString: @"</li>\n"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (l > 0)
|
||||||
|
{
|
||||||
|
[self decIndent];
|
||||||
|
[buf appendString: indent];
|
||||||
|
[buf appendString: @"</li>\n"];
|
||||||
|
[self decIndent];
|
||||||
|
[buf appendString: indent];
|
||||||
|
[buf appendString: @"</ol>\n"];
|
||||||
|
l--;
|
||||||
|
}
|
||||||
|
[buf appendString: indent];
|
||||||
|
[buf appendString: @"<hr />\n"];
|
||||||
|
}
|
||||||
|
}
|
||||||
else if ([name isEqual: @"desc"] == YES)
|
else if ([name isEqual: @"desc"] == YES)
|
||||||
{
|
{
|
||||||
[buf appendString: indent];
|
[buf appendString: indent];
|
||||||
|
@ -609,8 +705,10 @@ static NSMutableSet *textNodes = nil;
|
||||||
[buf appendString: @"<"];
|
[buf appendString: @"<"];
|
||||||
[buf appendString: heading];
|
[buf appendString: heading];
|
||||||
[buf appendString: @">"];
|
[buf appendString: @">"];
|
||||||
|
[buf appendFormat: @"<a name=\"%03u%03u%03u%03u\">",
|
||||||
|
chap, sect, ssect, sssect];
|
||||||
[self outputText: children to: buf];
|
[self outputText: children to: buf];
|
||||||
[buf appendString: @"</"];
|
[buf appendString: @"</a></"];
|
||||||
[buf appendString: heading];
|
[buf appendString: heading];
|
||||||
[buf appendString: @">\n"];
|
[buf appendString: @">\n"];
|
||||||
}
|
}
|
||||||
|
@ -856,6 +954,9 @@ NSLog(@"Element '%@' not implemented", name); // FIXME
|
||||||
else if ([name isEqual: @"section"] == YES)
|
else if ([name isEqual: @"section"] == YES)
|
||||||
{
|
{
|
||||||
heading = @"h2";
|
heading = @"h2";
|
||||||
|
sect++;
|
||||||
|
ssect = 0;
|
||||||
|
sssect = 0;
|
||||||
[self outputNodeList: children to: buf];
|
[self outputNodeList: children to: buf];
|
||||||
}
|
}
|
||||||
else if ([name isEqual: @"site"] == YES)
|
else if ([name isEqual: @"site"] == YES)
|
||||||
|
@ -873,11 +974,14 @@ NSLog(@"Element '%@' not implemented", name); // FIXME
|
||||||
else if ([name isEqual: @"subsect"] == YES)
|
else if ([name isEqual: @"subsect"] == YES)
|
||||||
{
|
{
|
||||||
heading = @"h3";
|
heading = @"h3";
|
||||||
|
ssect++;
|
||||||
|
sssect = 0;
|
||||||
[self outputNodeList: children to: buf];
|
[self outputNodeList: children to: buf];
|
||||||
}
|
}
|
||||||
else if ([name isEqual: @"subsubsect"] == YES)
|
else if ([name isEqual: @"subsubsect"] == YES)
|
||||||
{
|
{
|
||||||
heading = @"h4";
|
heading = @"h4";
|
||||||
|
sssect++;
|
||||||
[self outputNodeList: children to: buf];
|
[self outputNodeList: children to: buf];
|
||||||
}
|
}
|
||||||
else if ([name isEqual: @"type"] == YES)
|
else if ([name isEqual: @"type"] == YES)
|
||||||
|
|
|
@ -29,6 +29,10 @@
|
||||||
NSMutableDictionary *refs;
|
NSMutableDictionary *refs;
|
||||||
NSString *base; // Not retained
|
NSString *base; // Not retained
|
||||||
NSString *unit; // Not retained
|
NSString *unit; // Not retained
|
||||||
|
unsigned chap;
|
||||||
|
unsigned sect;
|
||||||
|
unsigned ssect;
|
||||||
|
unsigned sssect;
|
||||||
}
|
}
|
||||||
- (NSString*) globalRef: (NSString*)ref type: (NSString*)type;
|
- (NSString*) globalRef: (NSString*)ref type: (NSString*)type;
|
||||||
- (void) makeRefs: (GSXMLNode*)node;
|
- (void) makeRefs: (GSXMLNode*)node;
|
||||||
|
|
|
@ -32,6 +32,8 @@ mergeDictionaries(NSMutableDictionary *dst, NSDictionary *src, BOOL override)
|
||||||
static NSMutableArray *stack = nil;
|
static NSMutableArray *stack = nil;
|
||||||
NSEnumerator *e = [src keyEnumerator];
|
NSEnumerator *e = [src keyEnumerator];
|
||||||
NSString *k;
|
NSString *k;
|
||||||
|
id s;
|
||||||
|
id d;
|
||||||
|
|
||||||
if (stack == nil)
|
if (stack == nil)
|
||||||
{
|
{
|
||||||
|
@ -39,8 +41,12 @@ mergeDictionaries(NSMutableDictionary *dst, NSDictionary *src, BOOL override)
|
||||||
}
|
}
|
||||||
while ((k = [e nextObject]) != nil)
|
while ((k = [e nextObject]) != nil)
|
||||||
{
|
{
|
||||||
id s = [src objectForKey: k];
|
if ([k isEqualToString: @"contents"] == YES)
|
||||||
id d = [dst objectForKey: k];
|
{
|
||||||
|
continue; // Makes no sense to merge file contents.
|
||||||
|
}
|
||||||
|
s = [src objectForKey: k];
|
||||||
|
d = [dst objectForKey: k];
|
||||||
|
|
||||||
[stack addObject: k];
|
[stack addObject: k];
|
||||||
if (d == nil)
|
if (d == nil)
|
||||||
|
@ -195,6 +201,13 @@ setDirectory(NSMutableDictionary *dict, NSString *path)
|
||||||
|
|
||||||
[self setGlobalRef: unit type: name];
|
[self setGlobalRef: unit type: name];
|
||||||
}
|
}
|
||||||
|
else if ([name isEqual: @"chapter"] == YES)
|
||||||
|
{
|
||||||
|
chap++;
|
||||||
|
sect = 0;
|
||||||
|
ssect = 0;
|
||||||
|
sssect = 0;
|
||||||
|
}
|
||||||
else if ([name isEqual: @"class"] == YES)
|
else if ([name isEqual: @"class"] == YES)
|
||||||
{
|
{
|
||||||
NSString *tmp;
|
NSString *tmp;
|
||||||
|
@ -218,6 +231,24 @@ setDirectory(NSMutableDictionary *dict, NSString *path)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ([name isEqual: @"heading"] == YES)
|
||||||
|
{
|
||||||
|
NSMutableDictionary *d;
|
||||||
|
NSString *k;
|
||||||
|
|
||||||
|
d = [refs objectForKey: @"contents"];
|
||||||
|
if (d == nil)
|
||||||
|
{
|
||||||
|
d = [[NSMutableDictionary alloc] initWithCapacity: 8];
|
||||||
|
[refs setObject: d forKey: @"contents"];
|
||||||
|
RELEASE(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
k = [NSString stringWithFormat: @"%03u%03u%03u%03u",
|
||||||
|
chap, sect, ssect, sssect];
|
||||||
|
[d setObject: [[children content] stringByTrimmingSpaces] forKey: k];
|
||||||
|
children = nil;
|
||||||
|
}
|
||||||
else if ([name isEqual: @"ivariable"] == YES)
|
else if ([name isEqual: @"ivariable"] == YES)
|
||||||
{
|
{
|
||||||
NSString *tmp = [prop objectForKey: @"name"];
|
NSString *tmp = [prop objectForKey: @"name"];
|
||||||
|
@ -231,7 +262,7 @@ setDirectory(NSMutableDictionary *dict, NSString *path)
|
||||||
NSString *text;
|
NSString *text;
|
||||||
NSString *val;
|
NSString *val;
|
||||||
|
|
||||||
text = [children content];
|
text = [[children content] stringByTrimmingSpaces];
|
||||||
children = nil;
|
children = nil;
|
||||||
all = [refs objectForKey: name];
|
all = [refs objectForKey: name];
|
||||||
if (all == nil)
|
if (all == nil)
|
||||||
|
@ -281,7 +312,8 @@ setDirectory(NSMutableDictionary *dict, NSString *path)
|
||||||
{
|
{
|
||||||
if ([t type] == XML_TEXT_NODE)
|
if ([t type] == XML_TEXT_NODE)
|
||||||
{
|
{
|
||||||
sel = [sel stringByAppendingString: [t content]];
|
sel = [sel stringByAppendingString:
|
||||||
|
[[t content] stringByTrimmingSpaces]];
|
||||||
}
|
}
|
||||||
t = [t next];
|
t = [t next];
|
||||||
}
|
}
|
||||||
|
@ -324,6 +356,21 @@ setDirectory(NSMutableDictionary *dict, NSString *path)
|
||||||
|
|
||||||
[self setGlobalRef: tmp type: name];
|
[self setGlobalRef: tmp type: name];
|
||||||
}
|
}
|
||||||
|
else if ([name isEqual: @"section"] == YES)
|
||||||
|
{
|
||||||
|
sect++;
|
||||||
|
ssect = 0;
|
||||||
|
sssect = 0;
|
||||||
|
}
|
||||||
|
else if ([name isEqual: @"subsect"] == YES)
|
||||||
|
{
|
||||||
|
ssect++;
|
||||||
|
sssect = 0;
|
||||||
|
}
|
||||||
|
else if ([name isEqual: @"subsubsect"] == YES)
|
||||||
|
{
|
||||||
|
sssect++;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -323,7 +323,11 @@ static BOOL snuggleStart(NSString *t)
|
||||||
|
|
||||||
// Output document forward if available.
|
// Output document forward if available.
|
||||||
tmp = [info objectForKey: @"front"];
|
tmp = [info objectForKey: @"front"];
|
||||||
if (tmp != nil)
|
if (tmp == nil)
|
||||||
|
{
|
||||||
|
[self reformat: @"<front><contents /></front>" withIndent: 4 to: str];
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
[self reformat: tmp withIndent: 4 to: str];
|
[self reformat: tmp withIndent: 4 to: str];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue