我发现Emacs有一种字幕文件模式,如.srt
.smi
。
但是,它不会对这些文件进行任何语法突出显示。
如果有办法,请告诉我。
感谢。
答案 0 :(得分:2)
此模式https://github.com/naokiri/subtitle-mode/blob/master/subtitle-mode.el似乎为数字,时间和文本做了高级语法。
此外,它可以从光标所在位置开始阅读电影(using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Newtonsoft.Json.Linq;
namespace Your.Extensions
{
public enum PropertyFormat
{
AsIs,
PascalCase,
CamelCase
}
public static class DataShapingExtensions
{
public static object ToDataShape<ObjectIn>(this ObjectIn objectToShape, string fields, PropertyFormat propertyFormat = PropertyFormat.AsIs) where ObjectIn : class
{
var listOfFields = new List<string>();
if (!string.IsNullOrWhiteSpace(fields))
{
listOfFields = fields.ToLower().Split(',').ToList();
}
if (listOfFields.Any())
{
var objectToReturn = new JObject();
//====
var enumerable = objectToShape as IEnumerable;
if (enumerable != null)
{
var listOfObjects = new List<JObject>();
foreach (var item in enumerable)
{
var objectToReturn2 = new JObject();
listOfFields.ForEach(field =>
{
try
{
var prop = item.GetType()
.GetProperty(field, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
var fieldName = prop.Name;
var fieldValue = prop.GetValue(item, null);
fieldName = GetName(fieldName, propertyFormat);
objectToReturn2.Add(new JProperty(fieldName, fieldValue));
}
catch (Exception ex) { }
});
listOfObjects.Add(objectToReturn2);
}
return listOfObjects.ConvertAll(o => o);
}
//====
listOfFields.ForEach(field =>
{
try
{
var prop = objectToShape.GetType()
.GetProperty(field, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
var fieldName = prop.Name;
var fieldValue = prop.GetValue(objectToShape, null);
fieldName = GetName(fieldName, propertyFormat);
objectToReturn.Add(new JProperty(fieldName, fieldValue));
}
catch (Exception ex) { }
});
return objectToReturn;
}
return objectToShape;
}
private static string GetName(string field, PropertyFormat propertyFormat)
{
switch (propertyFormat)
{
case PropertyFormat.AsIs: return field;
case PropertyFormat.PascalCase: return field.ToPascalCase();
case PropertyFormat.CamelCase: return field.ToCamelCase();
default: return field;
}
}
}
}
)。