mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Restructured folders and project names, ci should be fixed
This commit is contained in:
32
src/NadekoBot/Common/Yml/MultilineScalarFlowStyleEmitter.cs
Normal file
32
src/NadekoBot/Common/Yml/MultilineScalarFlowStyleEmitter.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using YamlDotNet.Core;
|
||||
using YamlDotNet.Serialization;
|
||||
using YamlDotNet.Serialization.EventEmitters;
|
||||
|
||||
namespace NadekoBot.Common.Yml
|
||||
{
|
||||
public class MultilineScalarFlowStyleEmitter : ChainedEventEmitter
|
||||
{
|
||||
public MultilineScalarFlowStyleEmitter(IEventEmitter nextEmitter)
|
||||
: base(nextEmitter) { }
|
||||
|
||||
public override void Emit(ScalarEventInfo eventInfo, IEmitter emitter)
|
||||
{
|
||||
|
||||
if (typeof(string).IsAssignableFrom(eventInfo.Source.Type))
|
||||
{
|
||||
string value = eventInfo.Source.Value as string;
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
bool isMultiLine = value.IndexOfAny(new char[] { '\r', '\n', '\x85', '\x2028', '\x2029' }) >= 0;
|
||||
if (isMultiLine)
|
||||
eventInfo = new ScalarEventInfo(eventInfo.Source)
|
||||
{
|
||||
Style = ScalarStyle.Literal,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
nextEmitter.Emit(eventInfo, emitter);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user