DocSpace-client/common/ASC.Textile/FormatterState.cs
pavelbannov 320a1f2250 Merge branch 'develop' into feature/backend-refactor
# Conflicts:
#	common/ASC.Api.Core/Core/BaseStartup.cs
#	common/ASC.Common/Caching/AscCache.cs
#	common/ASC.Common/Data/StreamExtension.cs
#	common/ASC.Common/Utils/RandomString.cs
#	common/ASC.Core.Common/Billing/CouponManager.cs
#	common/ASC.Core.Common/Billing/License/LicenseReader.cs
#	common/ASC.Core.Common/Core/UserGroupRef.cs
#	common/ASC.Core.Common/Data/DbTenantService.cs
#	common/ASC.Core.Common/Notify/Jabber/JabberServiceClientWcf.cs
#	common/ASC.Core.Common/Notify/Telegram/Dao/CachedTelegramDao.cs
#	common/ASC.Data.Backup.Core/Core/DbHelper.cs
#	common/ASC.Data.Backup.Core/Storage/BackupRepository.cs
#	common/ASC.Data.Backup.Core/Tasks/Data/TableInfo.cs
#	common/ASC.Data.Storage/BaseStorage.cs
#	common/ASC.Data.Storage/DiscStorage/DiscDataStore.cs
#	common/ASC.Data.Storage/GoogleCloud/GoogleCloudStorage.cs
#	common/ASC.Data.Storage/RackspaceCloud/RackspaceCloudStorage.cs
#	common/ASC.Data.Storage/S3/S3Storage.cs
#	common/ASC.Notify.Textile/JabberStyler.cs
#	common/ASC.Textile/Blocks/GlyphBlockModifier.cs
#	common/ASC.Textile/States/TableRowFormatterState.cs
#	common/services/ASC.ApiSystem/Classes/CommonMethods.cs
#	common/services/ASC.ApiSystem/Controllers/PortalController.cs
#	common/services/ASC.ClearEvents/Program.cs
#	common/services/ASC.TelegramService/Startup.cs
#	common/services/ASC.UrlShortener.Svc/Program.cs
#	products/ASC.Files/Core/Core/Entries/File.cs
#	products/ASC.Files/Core/Core/Entries/FileEntry.cs
#	products/ASC.Files/Core/Core/Entries/FileHelper.cs
#	products/ASC.Files/Core/Core/Entries/Folder.cs
#	products/ASC.Files/Core/Core/FileStorageService.cs
#	products/ASC.Files/Core/Core/Thirdparty/ProviderDao/ProviderDaoBase.cs
#	products/ASC.Files/Core/Helpers/ThirdpartyConfiguration.cs
#	products/ASC.Files/Core/HttpHandlers/FileHandler.ashx.cs
#	products/ASC.Files/Core/Services/DocumentService/Configuration.cs
#	products/ASC.Files/Core/Services/DocumentService/DocumentServiceConnector.cs
#	products/ASC.Files/Core/Services/DocumentService/DocumentServiceTracker.cs
#	products/ASC.Files/Core/Services/WCFService/FileOperations/FileDownloadOperation.cs
#	products/ASC.Files/Core/Services/WCFService/FileOperations/FileMoveCopyOperation.cs
#	products/ASC.Files/Core/Utils/EntryManager.cs
#	products/ASC.Files/Server/Helpers/FilesControllerHelper.cs
#	products/ASC.Files/Server/Startup.cs
#	products/ASC.Files/Service/Thumbnail/Builder.cs
#	products/ASC.Files/Service/Thumbnail/FileDataProvider.cs
#	products/ASC.People/Server/Startup.cs
#	web/ASC.Web.Core/Files/DocumentService.cs
#	web/ASC.Web.Core/Files/DocumentServiceLicense.cs
#	web/ASC.Web.Core/QuotaSync.cs
#	web/ASC.Web.Core/Sms/SmsKeyStorage.cs
#	web/ASC.Web.Core/Users/UserManagerWrapper.cs
#	web/ASC.Web.HealthChecks.UI/Program.cs
#	web/ASC.Web.Studio/Startup.cs
2022-02-10 13:16:33 +03:00

136 lines
4.6 KiB
C#

#region License Statement
// Copyright (c) L.A.B.Soft. All rights reserved.
//
// The use and distribution terms for this software are covered by the
// Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
// which can be found in the file CPL.TXT at the root of this distribution.
// By using this software in any fashion, you are agreeing to be bound by
// the terms of this license.
//
// You must not remove this notice, or any other, from this software.
#endregion
namespace Textile
{
/// <summary>
/// Base class for formatter states.
/// </summary>
/// A formatter state describes the current situation
/// of the text being currently processed. A state can
/// write HTML code when entered, exited, and can modify
/// each line of text it receives.
public abstract class FormatterState
{
/// <summary>
/// The formatter this state belongs to.
/// </summary>
public TextileFormatter Formatter { get; }
/// <summary>
/// Public constructor.
/// </summary>
/// <param name="f">The parent formatter.</param>
protected FormatterState(TextileFormatter formatter)
{
Formatter = formatter;
}
/// <summary>
///
/// </summary>
/// <param name="input"></param>
/// <param name="m"></param>
/// <returns></returns>
public abstract string Consume(string input, Match m);
/// <summary>
/// Method called when the state is entered.
/// </summary>
public abstract void Enter();
/// <summary>
/// Method called when the state is exited.
/// </summary>
public abstract void Exit();
/// <summary>
/// Method called when a line of text should be written
/// to the web form.
/// </summary>
/// <param name="input">The line of text.</param>
public abstract void FormatLine(string input);
/// <summary>
/// Returns whether this state can last for more than one line.
/// </summary>
/// <returns>A boolean value stating whether this state is only for one line.</returns>
/// This method should return true only if this state is genuinely
/// multi-line. For example, a header text is only one line long. You can
/// have several consecutive lines of header texts, but they are not the same
/// header - just several headers one after the other.
/// Bulleted and numbered lists are good examples of multi-line states.
//abstract public bool IsOneLineOnly();
/// <summary>
///
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public abstract bool ShouldExit(string input);
/// <summary>
///
/// </summary>
/// <param name="actualTag"></param>
/// <param name="alignNfo"></param>
/// <param name="attNfo"></param>
/// <returns></returns>
public virtual bool ShouldNestState(FormatterState other)
{
return false;
}
/// <summary>
/// Returns whether block formatting (quick phrase modifiers, etc.) should be
/// applied to this line.
/// </summary>
/// <param name="input">The line of text</param>
/// <returns>Whether the line should be formatted for blocks</returns>
public virtual bool ShouldFormatBlocks(string input)
{
return true;
}
/// <summary>
/// Returns whether the current state accepts being superceded by another one
/// we would possibly find by parsing the input line of text.
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public virtual bool ShouldParseForNewFormatterState(string input)
{
return true;
}
/// <summary>
/// Gets the formatting state we should fallback to if we don't find anything
/// relevant in a line of text.
/// </summary>
public virtual Type FallbackFormattingState
{
get
{
return typeof(States.ParagraphFormatterState);
}
}
protected FormatterState CurrentFormatterState
{
get { return this.Formatter.CurrentState; }
}
protected void ChangeFormatterState(FormatterState formatterState)
{
this.Formatter.ChangeState(formatterState);
}
}
}