pavelbannov
320a1f2250
# 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
66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
namespace Textile.States
|
|
{
|
|
[FormatterState(@"^\s*(?<tag>table)" +
|
|
Globals.SpanPattern +
|
|
Globals.AlignPattern +
|
|
Globals.BlockModifiersPattern +
|
|
@"\.\s*$")]
|
|
public class TableFormatterState : FormatterState
|
|
{
|
|
private string m_attsInfo;
|
|
private string m_alignInfo;
|
|
|
|
public TableFormatterState(TextileFormatter f)
|
|
: base(f)
|
|
{
|
|
}
|
|
|
|
public override string Consume(string input, Match m)
|
|
{
|
|
m_alignInfo = m.Groups["align"].Value;
|
|
m_attsInfo = m.Groups["atts"].Value;
|
|
|
|
//TODO: check the state (it could already be a table!)
|
|
this.Formatter.ChangeState(this);
|
|
|
|
return string.Empty;
|
|
}
|
|
|
|
public override bool ShouldNestState(FormatterState other)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public override void Enter()
|
|
{
|
|
Formatter.Output.WriteLine("<table" + FormattedStylesAndAlignment() + ">");
|
|
}
|
|
|
|
public override void Exit()
|
|
{
|
|
Formatter.Output.WriteLine("</table>");
|
|
}
|
|
|
|
public override void FormatLine(string input)
|
|
{
|
|
if (input.Length > 0)
|
|
throw new Exception("The TableFormatter state is not supposed to format any lines!");
|
|
}
|
|
|
|
public override bool ShouldExit(string input)
|
|
{
|
|
var m = Regex.Match(input,
|
|
@"^\s*" + Globals.AlignPattern + Globals.BlockModifiersPattern +
|
|
@"(\.\s?)?(?<tag>\|)" +
|
|
@"(?<content>.*)(?=\|)"
|
|
);
|
|
return !m.Success;
|
|
}
|
|
|
|
protected string FormattedStylesAndAlignment()
|
|
{
|
|
return Blocks.BlockAttributesParser.ParseBlockAttributes(m_alignInfo + m_attsInfo);
|
|
}
|
|
}
|
|
}
|