public static T WriteFilename <T>(this T output, string name) where T : ISyntaxHighlightOutput { if (name == null) { return(output); } name = NameUtils.CleanName(name); var s = name.Replace('\\', '/'); var parts = s.Split('/'); int slashIndex = 0; for (int i = 0; i < parts.Length - 1; i++) { output.Write(parts[i], TextTokenKind.DirectoryPart); slashIndex += parts[i].Length; output.Write(name[slashIndex].ToString(), TextTokenKind.Text); slashIndex++; } var fn = parts[parts.Length - 1]; int index = fn.LastIndexOf('.'); if (index < 0) { output.Write(fn, TextTokenKind.FileNameNoExtension); } else { string ext = fn.Substring(index + 1); fn = fn.Substring(0, index); output.Write(fn, TextTokenKind.FileNameNoExtension); output.Write(".", TextTokenKind.Text); output.Write(ext, TextTokenKind.FileExtension); } return(output); }
public static T WriteModule <T>(this T output, string name) where T : ISyntaxHighlightOutput { output.Write(NameUtils.CleanName(name), TextTokenKind.Module); return(output); }