This commit is contained in:
Zel
2025-02-23 18:47:21 +08:00
parent eaaffeeccb
commit e46a7ca31c
104 changed files with 2630 additions and 2516 deletions

View File

@@ -1,15 +1,16 @@
namespace ZelWiki.Engine.Library.Interfaces
{
/// <summary>
/// Handles wiki comments. These are generally removed from the result.
/// 处理评论.
/// </summary>
public interface ICommentHandler
{
/// <summary>
/// Handles a wiki comment.
/// 处理评论
/// </summary>
/// <param name="state">Reference to the wiki state object</param>
/// <param name="text">The comment text</param>
/// <param name="state"></param>
/// <param name="text"></param>
/// <returns></returns>
public HandlerResult Handle(IZelEngineState state, string text);
}
}
}

View File

@@ -1,14 +1,14 @@
namespace ZelWiki.Engine.Library.Interfaces
{
/// <summary>
/// Handles wiki completion events.
/// 处理完成事件
/// </summary>
public interface ICompletionHandler
{
/// <summary>
/// Handles wiki completion events. Is called when the wiki processing competes for a given page.
/// 处理完成事件
/// </summary>
/// <param name="state">Reference to the wiki state object</param>
/// <param name="state"></param>
public void Complete(IZelEngineState state);
}
}
}

View File

@@ -1,16 +1,17 @@
namespace ZelWiki.Engine.Library.Interfaces
{
/// <summary>
/// Handles wiki emojis.
/// emoji
/// </summary>
public interface IEmojiHandler
{
/// <summary>
/// Handles an emoji instruction.
///
/// </summary>
/// <param name="state">Reference to the wiki state object</param>
/// <param name="key">The lookup key for the given emoji.</param>
/// <param name="scale">The desired 1-100 scale factor for the emoji.</param>
/// <param name="state"></param>
/// <param name="key"></param>
/// <param name="scale"></param>
/// <returns></returns>
public HandlerResult Handle(IZelEngineState state, string key, int scale);
}
}
}

View File

@@ -1,16 +1,16 @@
namespace ZelWiki.Engine.Library.Interfaces
{
/// <summary>
/// Handles exceptions thrown by the wiki engine.
/// 错误日志
/// </summary>
public interface IExceptionHandler
{
/// <summary>
/// Called when an exception is thrown by the wiki engine.
///
/// </summary>
/// <param name="state">Reference to the wiki state object</param>
/// <param name="ex">Optional exception, in the case that this was an actual exception.</param>
/// <param name="customText">Text that accompanies the exception.</param>
/// <param name="state"></param>
/// <param name="ex"></param>
/// <param name="customText"></param>
public void Log(IZelEngineState state, Exception? ex, string customText);
}
}
}

View File

@@ -1,18 +1,18 @@
namespace ZelWiki.Engine.Library.Interfaces
{
/// <summary>
/// Handles links the wiki to another site.
///
/// </summary>
public interface IExternalLinkHandler
{
/// <summary>
/// Handles an internal wiki link.
///
/// </summary>
/// <param name="state">Reference to the wiki state object</param>
/// <param name="link">The address of the external site being linked to.</param>
/// <param name="text">The text which should be show in the absence of an image.</param>
/// <param name="image">The image that should be shown.</param>
/// <param name="imageScale">The 0-100 image scale factor for the given image.</param>
/// <param name="state"></param>
/// <param name="link"></param>
/// <param name="text"></param>
/// <param name="image"></param>
/// <returns></returns>
public HandlerResult Handle(IZelEngineState state, string link, string? text, string? image);
}
}
}

View File

@@ -3,22 +3,23 @@
namespace ZelWiki.Engine.Library.Interfaces
{
/// <summary>
/// Base function handler for standard, post-processing, scoped and processing-instruction functions.
/// 处理函数.
/// </summary>
public interface IFunctionHandler
{
/// <summary>
/// Returns a collection of function prototypes.
/// 回调.
/// </summary>
/// <returns></returns>
public FunctionPrototypeCollection Prototypes { get; }
/// <summary>
/// Called to handle function calls when proper prototypes are matched.
/// 当匹配到合适的原型时,调用以处理函数调用
/// </summary>
/// <param name="state">Reference to the wiki state object</param>
/// <param name="function">The parsed function call and all its parameters and their values.</param>
/// <param name="scopeBody">For scope functions, this is the text that the function is designed to affect.</param>
/// <param name="state"></param>
/// <param name="function"></param>
/// <param name="scopeBody"></param>
/// <returns></returns>
public HandlerResult Handle(IZelEngineState state, FunctionCall function, string? scopeBody = null);
}
}
}

View File

@@ -1,17 +1,18 @@
namespace ZelWiki.Engine.Library.Interfaces
{
/// <summary>
/// Handles wiki headings. These are automatically added to the table of contents.
/// 处理标题
/// </summary>
public interface IHeadingHandler
{
/// <summary>
/// Handles wiki headings. These are automatically added to the table of contents.
///
/// </summary>
/// <param name="state">Reference to the wiki state object</param>
/// <param name="depth">The size of the header, also used for table of table of contents indentation.</param>
/// <param name="link">The self link reference.</param>
/// <param name="text">The text for the self link.</param>
/// <param name="state"></param>
/// <param name="depth"></param>
/// <param name="link"></param>
/// <param name="text"></param>
/// <returns></returns>
public HandlerResult Handle(IZelEngineState state, int depth, string link, string text);
}
}
}

View File

@@ -3,19 +3,21 @@
namespace ZelWiki.Engine.Library.Interfaces
{
/// <summary>
/// Handles links from one wiki page to another.
/// 处理内链
/// </summary>
public interface IInternalLinkHandler
{
/// <summary>
/// Handles an internal wiki link.
///
/// </summary>
/// <param name="state">Reference to the wiki state object</param>
/// <param name="pageNavigation">The navigation for the linked page.</param>
/// <param name="pageName">The name of the page being linked to.</param>
/// <param name="linkText">The text which should be show in the absence of an image.</param>
/// <param name="image">The image that should be shown.</param>
/// <param name="imageScale">The 0-100 image scale factor for the given image.</param>
public HandlerResult Handle(IZelEngineState state, NamespaceNavigation pageNavigation, string pageName, string linkText, string? image, int imageScale);
/// <param name="state"></param>
/// <param name="pageNavigation"></param>
/// <param name="pageName"></param>
/// <param name="linkText"></param>
/// <param name="image"></param>
/// <param name="imageScale"></param>
/// <returns></returns>
public HandlerResult Handle(IZelEngineState state, NamespaceNavigation pageNavigation, string pageName,
string linkText, string? image, int imageScale);
}
}
}

View File

@@ -1,16 +1,17 @@
namespace ZelWiki.Engine.Library.Interfaces
{
/// <summary>
/// Handles basic markup/style instructions like bole, italic, underline, etc.
/// 处理基本的标记/样式指令,如粗体、斜体、下划线等.
/// </summary>
public interface IMarkupHandler
{
/// <summary>
/// Handles basic markup instructions like bole, italic, underline, etc.
///
/// </summary>
/// <param name="state">Reference to the wiki state object</param>
/// <param name="sequence">The sequence of symbols that were found to denotate this markup instruction,</param>
/// <param name="scopeBody">The body of text to apply the style to.</param>
/// <param name="state"></param>
/// <param name="sequence"></param>
/// <param name="scopeBody"></param>
/// <returns></returns>
public HandlerResult Handle(IZelEngineState state, char sequence, string scopeBody);
}
}
}

View File

@@ -1,7 +1,7 @@
namespace ZelWiki.Engine.Library.Interfaces
{
/// <summary>
/// Handles post-processing function calls.
///
/// </summary>
public interface IPostProcessingFunctionHandler : IFunctionHandler
{

View File

@@ -1,7 +1,7 @@
namespace ZelWiki.Engine.Library.Interfaces
{
/// <summary>
/// Handles processing-instruction function calls.
///
/// </summary>
public interface IProcessingInstructionFunctionHandler : IFunctionHandler
{

View File

@@ -1,7 +1,7 @@
namespace ZelWiki.Engine.Library.Interfaces
{
/// <summary>
/// Handles scope function calls.
///
/// </summary>
public interface IScopeFunctionHandler : IFunctionHandler
{

View File

@@ -1,7 +1,7 @@
namespace ZelWiki.Engine.Library.Interfaces
{
/// <summary>
/// Handles standard function calls.
///
/// </summary>
public interface IStandardFunctionHandler : IFunctionHandler
{

View File

@@ -6,69 +6,64 @@ namespace ZelWiki.Engine.Library.Interfaces
{
public interface IZelEngineState
{
#region Parameters.
#region
ISessionState? Session { get; }
IQueryCollection QueryString { get; }
IZelEngine Engine { get; }
IPage Page { get; }
int? Revision { get; }
public ISessionState? Session { get; }
public IQueryCollection QueryString { get; }
public IZelEngine Engine { get; }
public IPage Page { get; }
public int? Revision { get; }
public HashSet<Constants.WikiMatchType> OmitMatches { get; }
public int NestDepth { get; } //Used for recursion.
public int NestDepth { get; }
#endregion
#region State.
#region
/// <summary>
/// Custom page title set by a call to @@Title("...")
/// </summary>
public string? PageTitle { get; set; }
Dictionary<string, string> Variables { get; }
Dictionary<string, string> Snippets { get; }
List<string> Tags { get; set; }
List<string> ProcessingInstructions { get; }
List<PageReference> OutgoingLinks { get; }
List<TableOfContentsTag> TableOfContents { get; }
List<string> Headers { get; }
public Dictionary<string, string> Variables { get; }
public Dictionary<string, string> Snippets { get; }
public List<string> Tags { get; set; }
public List<string> ProcessingInstructions { get; }
public List<PageReference> OutgoingLinks { get; }
public List<TableOfContentsTag> TableOfContents { get; }
public List<string> Headers { get; }
#endregion
#region Results.
#region
string HtmlResult { get; }
TimeSpan ProcessingTime { get; }
int ErrorCount { get; }
int MatchCount { get; }
public string HtmlResult { get; }
public TimeSpan ProcessingTime { get; }
public int ErrorCount { get; }
public int MatchCount { get; }
#endregion
/// <summary>
/// Used to store values for handlers that needs to survive only a single wiki processing session.
///
/// </summary>
public void SetStateValue<T>(string key, T value);
/// <summary>
/// Used to get values for handlers that needs to survive only a single wiki processing session.
///
/// </summary>
public bool TryGetStateValue<T>(string key, [MaybeNullWhen(false)] out T? outValue);
/// <summary>
/// Used to get values for handlers that needs to survive only a single wiki processing session.
///
/// </summary>
public T GetStateValue<T>(string key, T defaultValue);
string GetNextQueryToken();
/// <summary>
/// Transforms "included" wiki pages, for example if a wiki function
/// injected additional wiki markup, this 'could' be processed separately.
///
/// </summary>
/// <param name="page">The child page to process</param>
/// <param name="revision">The optional revision of the child page to process</param>
/// <param name="page"></param>
/// <param name="revision"></param>
/// <returns></returns>
IZelEngineState TransformChild(IPage page, int? revision = null);
}
}
}