📄 translatorflex.cs
字号:
}
else
{
string[] split1 = split[1].Split(new char[] { '.' }, 2);
if (split1.Length == 1) s = "[" + split[1].Substring(1, split[1].Length - 2) + "|" + split[0].Substring(1, split[0].Length - 2) + "]";
else s = "[" + split1[1].Substring(0, split1[1].Length - 1) + "|" + split[0].Substring(1, split[0].Length - 2) + "]";
}
sb.Remove(match.Index, match.Length);
sb.Insert(match.Index, s);
ComputeNoWiki(sb.ToString(), ref noWikiBegin, ref noWikiEnd);
match = camelCase.Match(sb.ToString(), match.Index + s.Length);
}
}
match = pascalCase.Match(sb.ToString());
while (match.Success)
{
int end;
if (IsNoWikied(match.Index, noWikiBegin, noWikiEnd, out end))
match = pascalCase.Match(sb.ToString(), end);
else
{
string s;
string[] split = match.Value.Split(new char[] { ':' }, 2);
if (split.Length == 1)
{
string[] split1 = match.Value.Split(new char[] { '.' }, 2);
if (split1.Length == 1) s = "[" + match.Value + "]";
else s = "[" + split1[1] + "]";
}
else
{
string[] split1 = split[1].Split(new char[] { '.' });
if (split1.Length == 1) s = "[" + split[1] + "|" + split[0].Substring(1, split[0].Length - 2) + "]";
else s = "[" + split1[1] + "|" + split[0].Substring(1, split[0].Length - 2) + "]";
}
sb.Remove(match.Index, match.Length);
sb.Insert(match.Index, s);
ComputeNoWiki(sb.ToString(), ref noWikiBegin, ref noWikiEnd);
match = pascalCase.Match(sb.ToString(), match.Index + s.Length);
}
}
match = lists.Match(sb.ToString());
while (match.Success)
{
int end;
if (IsNoWikied(match.Index, noWikiBegin, noWikiEnd, out end))
match = lists.Match(sb.ToString(), end);
else
{
string s = "";
char kindOfList;
int i = 0;
char[] ca=match.Value.ToCharArray();
while(ca[i]==' ')
i++;
if (i > 0)
{
kindOfList = ca[i];
i = i / 8;
}
else
{
while (ca[i] == '\t')
i++;
kindOfList = ca[i];
}
for (int k = 1; k <= i; k++)
{
if (kindOfList == '*') s += "*";
if (kindOfList == '1') s += "#";
}
sb.Remove(match.Index, match.Length);
sb.Insert(match.Index, s);
ComputeNoWiki(sb.ToString(), ref noWikiBegin, ref noWikiEnd);
match = lists.Match(sb.ToString(), match.Index + s.Length);
}
}
bool tableBegin = true;
match = table.Match(sb.ToString());
while (match.Success)
{
int end;
if (IsNoWikied(match.Index, noWikiBegin, noWikiEnd, out end))
match = table.Match(sb.ToString(), end);
else
{
string s = "";
int indexEndOfLine = sb.ToString().IndexOf("\r\n", match.Index);
if (indexEndOfLine < 0) indexEndOfLine = sb.Length;
string[] split = sb.ToString().Substring(match.Index + 2, indexEndOfLine - match.Index - 4).Split(new string[] { "||" }, StringSplitOptions.None);
if (tableBegin) s = "{|\r\n| " + split[0];
else s = "|-\r\n| " + split[0];
for (int i = 1; i < split.Length; i++)
s += " || " + split[i];
if (indexEndOfLine != sb.Length)
{
if (sb.ToString().Substring(indexEndOfLine + 2, 2) == "||") tableBegin = false;
else
{
tableBegin = true;
s += "\r\n|}";
}
}
else
{
tableBegin = true;
s += "\r\n|}";
}
sb.Remove(match.Index, indexEndOfLine - match.Index);
sb.Insert(match.Index, s);
ComputeNoWiki(sb.ToString(), ref noWikiBegin, ref noWikiEnd);
match = table.Match(sb.ToString(), match.Index + s.Length);
}
}
match = italic.Match(sb.ToString());
while (match.Success)
{
int end;
if (IsNoWikied(match.Index, noWikiBegin, noWikiEnd, out end))
match = italic.Match(sb.ToString(), end);
else
{
if (IsNoFlexed(match.Index, noFlexBegin, noFlexEnd, out end))
match = italic.Match(sb.ToString(), end);
else
{
sb.Remove(match.Index, match.Length);
sb.Insert(match.Index, "''" + match.Value.Substring(1, match.Length - 2) + @"''");
ComputeNoWiki(sb.ToString(), ref noWikiBegin, ref noWikiEnd);
match = italic.Match(sb.ToString());
}
}
}
bool first = true;
match = newlinespace.Match(sb.ToString());
while (match.Success)
{
int end;
if (IsNoWikied(match.Index, noWikiBegin, noWikiEnd, out end))
match = newlinespace.Match(sb.ToString(), end);
else
{
string s = "";
if (first)
s += "{{{{" + match.Value.Substring(1, match.Value.Length - 1);
else
s += match.Value.Substring(1, match.Value.Length - 1);
if (sb.Length > match.Index + match.Length + 1)
{
if (sb[match.Index + match.Length] == '\n' && sb[match.Index + match.Length + 1] == ' ')
{
first = false;
}
else
{
s += "}}}}";
first = true;
}
}
sb.Remove(match.Index, match.Length);
sb.Insert(match.Index, s);
match = newlinespace.Match(sb.ToString(), match.Index + s.Length);
ComputeNoWiki(sb.ToString(), ref noWikiBegin, ref noWikiEnd);
}
}
return sb.ToString().Replace("<noflex>", "").Replace("</noflex>", "");
}
private void ComputeNoWiki(string text, ref List<int> noWikiBegin, ref List<int> noWikiEnd)
{
Match match;
noWikiBegin.Clear();
noWikiEnd.Clear();
match = noWiki.Match(text);
while (match.Success)
{
noWikiBegin.Add(match.Index);
noWikiEnd.Add(match.Index + match.Length - 1);
match = noWiki.Match(text, match.Index + match.Length);
}
}
private bool IsNoWikied(int index, List<int> noWikiBegin, List<int> noWikiEnd, out int end)
{
for (int i = 0; i < noWikiBegin.Count; i++)
{
if (index >= noWikiBegin[i] && index <= noWikiEnd[i])
{
end = noWikiEnd[i];
return true;
}
}
end = 0;
return false;
}
private void ComputeNoFlex(string text, ref List<int> noFlexBegin, ref List<int> noFlexEnd)
{
Match match;
noFlexBegin.Clear();
noFlexEnd.Clear();
match = noFlex.Match(text);
while (match.Success)
{
noFlexBegin.Add(match.Index);
noFlexEnd.Add(match.Index + match.Length - 1);
match = noFlex.Match(text, match.Index + match.Length);
}
}
private bool IsNoFlexed(int index, List<int> noFlexBegin, List<int> noFlexEnd, out int end)
{
for (int i = 0; i < noFlexBegin.Count; i++)
{
if (index >= noFlexBegin[i] && index <= noFlexEnd[i])
{
end = noFlexEnd[i];
return true;
}
}
end = 0;
return false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -