Fix parsing
This commit is contained in:
parent
e306af923c
commit
6f61ebd302
19
litexml.d
19
litexml.d
|
@ -140,6 +140,23 @@ class XmlNode
|
|||
}
|
||||
}
|
||||
|
||||
string text()
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case XmlNodeType.Text:
|
||||
return convertEntities(tag);
|
||||
case XmlNodeType.Node:
|
||||
case XmlNodeType.Root:
|
||||
string childrenText;
|
||||
foreach(child;children)
|
||||
childrenText ~= child.text();
|
||||
return childrenText;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
final XmlNode findChild(string tag)
|
||||
{
|
||||
foreach(child;children)
|
||||
|
@ -243,7 +260,7 @@ void skipWhitespace(Stream s)
|
|||
|
||||
bool isWord(char c)
|
||||
{
|
||||
return c=='-' || c=='_' || isalnum(c);
|
||||
return c=='-' || c=='_' || c==':' || isalnum(c);
|
||||
}
|
||||
|
||||
string readWord(Stream s)
|
||||
|
|
8
wp2git.d
8
wp2git.d
|
@ -26,11 +26,11 @@ int main(string[] args)
|
|||
foreach (child; xml[0]["page"])
|
||||
if (child.tag=="revision")
|
||||
{
|
||||
string summary = child["comment"].toString;
|
||||
string text = child["text"].toString;
|
||||
string summary = child["comment"] ? child["comment"].text : null;
|
||||
string text = child["text"].text;
|
||||
data ~=
|
||||
"commit master\n" ~
|
||||
"committer <" ~ (child["contributor"]["username"] ? child["contributor"]["username"].toString : child["contributor"]["ip"].toString) ~ "> now\n" ~
|
||||
"committer <" ~ (child["contributor"]["username"] ? child["contributor"]["username"].text : child["contributor"]["ip"].text) ~ "> now\n" ~
|
||||
"data " ~ .toString(summary.length) ~ "\n" ~
|
||||
summary ~ "\n" ~
|
||||
"M 644 inline " ~ name ~ ".txt\n" ~
|
||||
|
@ -38,6 +38,6 @@ int main(string[] args)
|
|||
text ~ "\n" ~
|
||||
"\n";
|
||||
}
|
||||
|
||||
write("fast-import-data", data);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue