Browse Source

Merge pull request #15414 from JadynWong/jadyn/fix-cmskit-content-parser

cms-kit: Fix ContentParser parse content
pull/15415/head
maliming 4 years ago
committed by GitHub
parent
commit
d2336fba7c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CmsKit/Components/Contents/ContentParser.cs

8
modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CmsKit/Components/Contents/ContentParser.cs

@ -19,7 +19,7 @@ public class ContentParser : ITransientDependency
_options = options.Value; _options = options.Value;
} }
public Task<List<ContentFragment>> ParseAsync(string content) public virtual Task<List<ContentFragment>> ParseAsync(string content)
{ {
if (!_options.WidgetConfigs.Any() || content is null) if (!_options.WidgetConfigs.Any() || content is null)
{ {
@ -38,9 +38,9 @@ public class ContentParser : ITransientDependency
return Task.FromResult(contentFragments); return Task.FromResult(contentFragments);
} }
private void ParseContent(string content, List<string> parsedList) protected virtual void ParseContent(string content, List<string> parsedList)
{ {
var replacedText = Regex.Replace(content, @"\[.*?\]", Delimeter); var replacedText = Regex.Replace(content, @"\[Widget.*?\]", Delimeter);
if (!replacedText.Contains(Delimeter)) if (!replacedText.Contains(Delimeter))
{ {
parsedList.Add(replacedText); parsedList.Add(replacedText);
@ -74,7 +74,7 @@ public class ContentParser : ITransientDependency
} }
} }
private void FillContentFragment(string content, List<string> parsedList, List<ContentFragment> contentFragments) protected virtual void FillContentFragment(string content, List<string> parsedList, List<ContentFragment> contentFragments)
{ {
content = Regex.Replace(content, @"=\s*""", @"="""); content = Regex.Replace(content, @"=\s*""", @"=""");
content = Regex.Replace(content, @"""\s*=", @"""="); content = Regex.Replace(content, @"""\s*=", @"""=");

Loading…
Cancel
Save