wiki: Modify Wiki2XHTMLConvert to convert wiki [code] tags to html <code> tags (instead of <pre> which causes a line break)

git-svn-id: trunk@49325 -
This commit is contained in:
wp 2015-06-13 12:16:18 +00:00
parent 794294016d
commit 11c6f4dfca

View File

@ -823,55 +823,62 @@ begin
doc:=Page.XHTML; doc:=Page.XHTML;
CurName:=lowercase(copy(W.Src,Token.NameStartPos,Token.NameEndPos-Token.NameStartPos)); CurName:=lowercase(copy(W.Src,Token.NameStartPos,Token.NameEndPos-Token.NameStartPos));
CurValue:=copy(W.Src,Token.ValueStartPos,Token.ValueEndPos-Token.ValueStartPos); CurValue:=copy(W.Src,Token.ValueStartPos,Token.ValueEndPos-Token.ValueStartPos);
CodeNode:=doc.CreateElement('pre');
if (CurName='pascal') if CurName = 'code' then begin
or (CurName='delphi') CodeNode := doc.CreateElement('code');
or (CurName='code') Page.CurDomNode.AppendChild(CodeNode);
or (CurName='syntaxhighlight') CodeNode.AppendChild(doc.CreateTextNode(CurValue));
or (CurName='source') end else
or (CurName='fpc') begin
then CodeNode:=doc.CreateElement('pre');
CurName:='pascal'; if (CurName='pascal')
if CurName<>'' then or (CurName='delphi')
CodeNode.SetAttribute('class',CurName); or (CurName='syntaxhighlight')
Page.CurDOMNode.AppendChild(CodeNode); or (CurName='source')
if CurValue<>'' then begin or (CurName='fpc')
if (CurName='pascal') then begin then
p:=PChar(CurValue); CurName:='pascal';
AtomStart:=p; if CurName<>'' then
LastToken:=pNone; CodeNode.SetAttribute('class',CurName);
LastRangeStart:=p; Page.CurDOMNode.AppendChild(CodeNode);
repeat if CurValue<>'' then begin
// skip space if (CurName='pascal') then begin
while p^ in [#1..#31,' '] do inc(p); p:=PChar(CurValue);
// read token AtomStart:=p;
if (p^='{') or ((p^='/') and (p[1]='/')) or ((p^='(') and (p[1]='*')) LastToken:=pNone;
then begin LastRangeStart:=p;
// comment repeat
AddSpan(pComment,p); // skip space
p:=FindCommentEnd(p,false); while p^ in [#1..#31,' '] do inc(p);
end else begin // read token
ReadRawNextPascalAtom(p,AtomStart); if (p^='{') or ((p^='/') and (p[1]='/')) or ((p^='(') and (p[1]='*'))
if AtomStart^=#0 then break; then begin
case AtomStart^ of // comment
'''','#': AddSpan(pComment,p);
AddSpan(pString,AtomStart); p:=FindCommentEnd(p,false);
'0'..'9','%','$','&': end else begin
AddSpan(pNumber,AtomStart); ReadRawNextPascalAtom(p,AtomStart);
'a'..'z','A'..'Z','_': if AtomStart^=#0 then break;
if WordIsKeyWord.DoIdentifier(AtomStart) then case AtomStart^ of
AddSpan(pKey,AtomStart) '''','#':
AddSpan(pString,AtomStart);
'0'..'9','%','$','&':
AddSpan(pNumber,AtomStart);
'a'..'z','A'..'Z','_':
if WordIsKeyWord.DoIdentifier(AtomStart) then
AddSpan(pKey,AtomStart)
else
AddSpan(pNone,AtomStart);
else else
AddSpan(pNone,AtomStart); AddSpan(pSymbol,AtomStart);
else end;
AddSpan(pSymbol,AtomStart);
end; end;
end; until false;
until false; Flush(p);
Flush(p); end else begin
end else begin // default: add as text
// default: add as text CodeNode.AppendChild(doc.CreateTextNode(CurValue));
CodeNode.AppendChild(doc.CreateTextNode(CurValue)); end;
end; end;
end; end;
end; end;