using ZelWiki.Engine.Library;
using ZelWiki.Engine.Library.Interfaces;

namespace ZelWiki.Engine.Implementation
{
    /// <summary>
    /// 处理基本的标记/样式指令，如粗体、斜体、下划线等.
    /// </summary>
    public class MarkupHandler : IMarkupHandler
    {
        /// <summary>
        /// 处理基本的标记指令，如粗体、斜体、下划线等
        /// </summary>
        /// <param name="state"></param>
        /// <param name="sequence"></param>
        /// <param name="scopeBody"></param>
        /// <returns></returns>
        public HandlerResult Handle(IZelEngineState state, char sequence, string scopeBody)
        {
            switch (sequence)
            {
                case '~': return new HandlerResult($"<strike>{scopeBody}</strike>");
                case '*': return new HandlerResult($"<strong>{scopeBody}</strong>");
                case '_': return new HandlerResult($"<u>{scopeBody}</u>");
                case '/': return new HandlerResult($"<i>{scopeBody}</i>");
                case '!': return new HandlerResult($"<mark>{scopeBody}</mark>");
                default:
                    break;
            }
            return new HandlerResult() { Instructions = [Constants.HandlerResultInstruction.Skip] };
        }
    }
}