diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
deleted file mode 100644
index 27b2f58..0000000
--- a/.github/workflows/ci.yml
+++ /dev/null
@@ -1,33 +0,0 @@
-name: .NET Core
-
-on:
- push:
- branches: [ master ]
- pull_request:
- branches: [ master ]
-
-jobs:
- build:
-
- runs-on: ubuntu-latest
-
- steps:
- - uses: actions/checkout@v2
- - name: Setup .NET Core 2.1
- uses: actions/setup-dotnet@v1
- with:
- dotnet-version: 2.1.x
- - name: Setup .NET Core 3.1
- uses: actions/setup-dotnet@v1
- with:
- dotnet-version: 3.1.x
- - name: Setup .NET Core 5.0
- uses: actions/setup-dotnet@v1
- with:
- dotnet-version: 5.0.x
- - name: Install dependencies
- run: dotnet restore
- - name: Build
- run: dotnet build --configuration Release --no-restore
- - name: Test
- run: dotnet test --no-restore --verbosity normal
diff --git a/.github/workflows/nuget-publish.yml b/.github/workflows/nuget-publish.yml
new file mode 100644
index 0000000..458476e
--- /dev/null
+++ b/.github/workflows/nuget-publish.yml
@@ -0,0 +1,45 @@
+# This workflow will publish a package when a release is created
+
+name: Publish package to NuGet repository
+on:
+ release:
+ types: [created]
+jobs:
+ publish-nuget:
+ runs-on: windows-latest
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v1
+ - name: Setup .NET Core @ Latest
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: '3.1.x'
+ env:
+ NUGET_AUTH_TOKEN: ${{ secrets.NUGET_AUTH_TOKEN }}
+ - name: Build solution and generate NuGet package
+ run: |
+ cd contentstack-utils-dotnet
+ dotnet pack -c Release -o out
+
+ - name: Push generated package to GitHub registry
+ run: dotnet nuget push ./contentstack-utils-dotnet/out/*.nupkg --api-key $NUGET_AUTH_TOKEN --skip-duplicate --no-symbols true
+
+ publish-git:
+ runs-on: windows-latest
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v1
+ - name: Setup .NET Core @ Latest
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: '3.1.x'
+ source-url: https://nuget.pkg.github.com/Contentstack/index.json
+ env:
+ NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ - name: Build solution and generate NuGet package
+ run: |
+ cd contentstack-utils-dotnet
+ dotnet pack -c Release -o out
+
+ - name: Push generated package to GitHub registry
+ run: dotnet nuget push ./contentstack-utils-dotnet/out/*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate --no-symbols true
diff --git a/.github/workflows/sast-scan.yml b/.github/workflows/sast-scan.yml
deleted file mode 100644
index f931630..0000000
--- a/.github/workflows/sast-scan.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-name: SAST Scan
-on:
- pull_request:
- types: [opened, synchronize, reopened]
-jobs:
- security:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - name: Horusec Scan
- run: docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/src horuszup/horusec-cli:latest horusec start -p /src -P $(pwd)
\ No newline at end of file
diff --git a/.github/workflows/sca-scan.yml b/.github/workflows/sca-scan.yml
index b5b34f2..be402b2 100644
--- a/.github/workflows/sca-scan.yml
+++ b/.github/workflows/sca-scan.yml
@@ -6,10 +6,14 @@ jobs:
security:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@master
+ - name: Checkout repository
+ uses: actions/checkout@master
+ - uses: snyk/actions/setup@master
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v3.0.3
+ - name: Restore dependencies
+ run: dotnet restore ./Contentstack.Utils.sln
- name: Run Snyk to check for vulnerabilities
- uses: snyk/actions/dotnet@master
+ run: cd Contentstack.Utils && snyk test --fail-on=all
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
- with:
- args: --fail-on=all
diff --git a/.github/workflows/secrets-scan.yml b/.github/workflows/secrets-scan.yml
deleted file mode 100644
index 1e8f176..0000000
--- a/.github/workflows/secrets-scan.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-name: Secrets Scan
-on:
- pull_request:
- types: [opened, synchronize, reopened]
-jobs:
- security:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - name: Gittyleaks
- uses: gupy-io/gittyleaks-action@v0.1
\ No newline at end of file
diff --git a/.talismanrc b/.talismanrc
new file mode 100644
index 0000000..bd9bf54
--- /dev/null
+++ b/.talismanrc
@@ -0,0 +1,4 @@
+fileignoreconfig:
+- filename: Contentstack.Utils/Models/Options.cs
+ checksum: 3dc51f0de02429ef9a43b66e666ac4dbde41195e245f8ecc0094548ca8603245
+version: ""
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 640ad67..355db18 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,8 @@
+### Version: 1.0.2
+#### Date: Mar-14-2024
+- Style attributes supported in converted HTML.
+
### Version: 1.0.1
#### Date: July-16-2021
- Json RTE content to Html Support added.
diff --git a/Contentstack.Utils.Tests/Constants/JsonToHtmlConstants.cs b/Contentstack.Utils.Tests/Constants/JsonToHtmlConstants.cs
index e1a3451..a4b7ae6 100644
--- a/Contentstack.Utils.Tests/Constants/JsonToHtmlConstants.cs
+++ b/Contentstack.Utils.Tests/Constants/JsonToHtmlConstants.cs
@@ -4,7 +4,7 @@ public static class JsonToHtmlResultConstants
{
public const string kPlainTextHtml = "Aliquam sit amet libero dapibus, eleifend ligula at, varius justoLorem ipsumdolor sit ametconsectetur adipiscing elit.Sed condimentum iaculis magna in vehicula. Vestibulum vitae convallis lacus. ";
public const string kParagraphHtml = "
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed condimentum iaculis magna in vehicula. Vestibulum vitae convallis lacus. Praesent a diam iaculis turpis rhoncus faucibus. Aliquam sed pulvinar sem.
";
- public const string kH1Html = "Lorem ipsum dolor sit amet.
";
+ public const string kH1Html = "Lorem ipsum dolor sit amet.
";
public const string kH2Html = "Vestibulum a ligula eget massa sagittis aliquam sit amet quis tortor.
";
public const string kH3Html = "Mauris venenatis dui id massa sollicitudin, non bibendum nunc dictum.
";
public const string kH4Html = "MaNullam feugiat turpis quis elit interdum, vitae laoreet quam viverra
";
@@ -24,7 +24,7 @@ public static class JsonToHtmlConstants
{
public const string kBlankDocument = "{ \"uid\":\"06e34a7a4e5d7fc2acd\", \"_version\":13, \"attrs\":{ }, \"children\":[],\"type\":\"doc\"}";
public const string kPlainTextJson = "{ \"uid\":\"06e34a7a4e5d7fc2acd\", \"_version\":13, \"attrs\":{ }, \"children\":[{\"text\":\"Aliquam sit amet libero dapibus, eleifend ligula at, varius justo\",\"bold\":true},{ \"text\":\"Lorem ipsum\",\"bold\":true,\"italic\":true},{ \"text\":\"dolor sit amet\",\"bold\":true,\"italic\":true,\"underline\":true},{ \"text\":\"consectetur adipiscing elit.\",\"bold\":true,\"italic\":true,\"underline\":true,\"strikethrough\":true},{ \"text\":\"Sed condimentum iaculis magna in vehicula. \",\"bold\":true,\"italic\":true,\"underline\":true,\"inlineCode\":true},{ \"text\":\" Vestibulum vitae convallis \",\"bold\":true,\"italic\":true,\"underline\":true,\"superscript\":true},{ \"text\":\" lacus. \",\"bold\":true,\"italic\":true,\"underline\":true,\"subscript\":true}],\"type\":\"doc\"}";
- public const string kH1Json = "{ \"uid\":\"06e34a7a449d7fc2acd\",\"_version\":13,\"attrs\":{ },\"children\":[{ \"type\":\"h1\",\"attrs\":{ },\"uid\":\"c2dfed70 4d7030c65e2e1\",\"children\":[{ \"text\":\"Lorem ipsum dolor sit amet.\",\"bold\":true,\"italic\":true,\"underline\":true,\"subscript\":true}]}],\"type\":\"doc\"}";
+ public const string kH1Json = "{ \"uid\":\"06e34a7a449d7fc2acd\",\"_version\":13,\"attrs\":{ },\"children\":[{ \"type\":\"h1\",\"attrs\":{ \"style\": { \"color\": \"blue\", \"font-size\": \"24px\" } },\"uid\":\"c2dfed70 4d7030c65e2e1\",\"children\":[{ \"text\":\"Lorem ipsum dolor sit amet.\",\"bold\":true,\"italic\":true,\"underline\":true,\"subscript\":true}]}],\"type\":\"doc\"}";
public const string kH2Json = "{ \"uid\":\"06e34a7a4e2acd\",\"_version\":13,\"attrs\":{ },\"children\":[{ \"type\":\"h2\",\"attrs\":{ },\"uid\":\"c2dfed9a7030c65e2e1\",\"children\":[{ \"text\":\"Vestibulum a ligula eget massa sagittis aliquam sit amet quis tortor. \",\"bold\":true,\"italic\":true,\"underline\":true,\"subscript\":true}]}],\"type\":\"doc\"}";
public const string kH3Json = "{ \"uid\":\"06e34ad7fc2acd\",\"_version\":13,\"attrs\":{ },\"children\":[{ \"type\":\"h3\",\"attrs\":{ },\"uid\":\"c2df42cfb70 4d7030c65e2e1\",\"children\":[{ \"text\":\"Mauris venenatis dui id massa sollicitudin, non bibendum nunc dictum.\",\"bold\":true,\"italic\":true,\"underline\":true,\"subscript\":true}]}],\"type\":\"doc\"}";
public const string kH4Json = "{ \"uid\":\"06e34a7a4e54cd\", \"_version\":13, \"attrs\":{ \"style\":{ \"text-align\":\"center\" }, \"redactor-attributes\":{ } }, \"children\":[{\"type\":\"h4\",\"attrs\":{},\"uid\":\"c2dfed4d7030c65e2e1\",\"children\":[{\"text\":\"MaNullam feugiat turpis quis elit interdum, vitae laoreet quam viverra\",\"bold\":true,\"italic\":true,\"underline\":true,\"subscript\":true}]}],\"type\":\"doc\"}";
diff --git a/Contentstack.Utils.Tests/Contentstack.Utils.Tests.csproj b/Contentstack.Utils.Tests/Contentstack.Utils.Tests.csproj
index 8c4cf96..02e6e09 100644
--- a/Contentstack.Utils.Tests/Contentstack.Utils.Tests.csproj
+++ b/Contentstack.Utils.Tests/Contentstack.Utils.Tests.csproj
@@ -1,23 +1,30 @@
- netcoreapp3.1
+ netstandard2.0;net47;net472;
false
- 1.0.1
+ $(Version)
-
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
+
+ ..\Contentstack.Utils\bin\Debug\netstandard2.0\Contentstack.Utils.dll
+
+
diff --git a/Contentstack.Utils.sln b/Contentstack.Utils.sln
index 288921f..5356759 100644
--- a/Contentstack.Utils.sln
+++ b/Contentstack.Utils.sln
@@ -21,7 +21,7 @@ Global
{EB2B5E23-E45F-4C6C-BF98-FE3971DE4250}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
- version = 1.0.1
+ version = 1.0.2
Policies = $0
$0.DotNetNamingPolicy = $1
$1.DirectoryNamespaceAssociation = PrefixedHierarchical
diff --git a/Contentstack.Utils/Contentstack.Utils.csproj b/Contentstack.Utils/Contentstack.Utils.csproj
index 794cfca..311a0cc 100644
--- a/Contentstack.Utils/Contentstack.Utils.csproj
+++ b/Contentstack.Utils/Contentstack.Utils.csproj
@@ -7,15 +7,15 @@
Contentstack
en-US
Utils .NET SDK for the Contentstack. 0.1.0
- 1.0.1
+ $(Version)
Contentstack
true
- v1.0.1
+ v$(Version)
Json RTE content to Html content support added
Copyright © 2012-2021 Contentstack. All Rights Reserved
https://github.com/contentstack/contentstack-utils-dotnet
LICENSE.txt
- 1.0.1
+ $(Version)
Contentstack Utils
diff --git a/Contentstack.Utils/Models/Options.cs b/Contentstack.Utils/Models/Options.cs
index c8553ee..2572f46 100644
--- a/Contentstack.Utils/Models/Options.cs
+++ b/Contentstack.Utils/Models/Options.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using Contentstack.Utils.Enums;
using Contentstack.Utils.Interfaces;
@@ -89,66 +90,89 @@ public virtual string RenderMark(MarkType markType, string text)
public virtual string RenderNode(string nodeType, Node node, NodeChildrenCallBack callBack)
{
string href = "";
+ string styleAttrs = "";
+
+ if (node.attrs.ContainsKey("style"))
+ {
+ var styleVal = node.attrs["style"];
+ if (styleVal != null)
+ {
+ if (styleVal is string)
+ {
+ styleAttrs = $" style=\"{styleVal}\"";
+ }
+ else if (styleVal is IDictionary)
+ {
+ var styleDictionary = (IDictionary)styleVal;
+ styleAttrs = " style=\"";
+ foreach (var pair in styleDictionary)
+ {
+ styleAttrs += $"{pair.Key}:{pair.Value};";
+ }
+ styleAttrs += "\"";
+ }
+ }
+ }
switch (nodeType)
{
case "p":
- return $"{callBack(node.children)}
";
+ return $"{callBack(node.children)}
";
case "a":
if (node.attrs.ContainsKey("url"))
{
href = (string)node.attrs["url"];
}
- return $"{callBack(node.children)}";
+ return $"{callBack(node.children)}";
case "img":
if (node.attrs.ContainsKey("url"))
{
href = (string)node.attrs["url"];
}
- return $"
{callBack(node.children)}";
+ return $"
{callBack(node.children)}";
case "embed":
if (node.attrs.ContainsKey("url"))
{
href = (string)node.attrs["url"];
}
- return $"";
+ return $"";
case "h1":
- return $"{callBack(node.children)}
";
+ return $"{callBack(node.children)}
";
case "h2":
- return $"{callBack(node.children)}
";
+ return $"{callBack(node.children)}
";
case "h3":
- return $"{callBack(node.children)}
";
+ return $"{callBack(node.children)}
";
case "h4":
- return $"{callBack(node.children)}
";
+ return $"{callBack(node.children)}
";
case "h5":
- return $"{callBack(node.children)}
";
+ return $"{callBack(node.children)}
";
case "h6":
- return $"{callBack(node.children)}
";
+ return $"{callBack(node.children)}
";
case "ol":
- return $"{callBack(node.children)}
";
+ return $"{callBack(node.children)}
";
case "ul":
- return $"{callBack(node.children)}
";
+ return $"{callBack(node.children)}
";
case "li":
- return $"{callBack(node.children)}";
+ return $"{callBack(node.children)}";
case "hr":
return $"
";
case "table":
- return $"{callBack(node.children)}
";
+ return $"{callBack(node.children)}
";
case "thead":
- return $"{callBack(node.children)}";
+ return $"{callBack(node.children)}";
case "tbody":
- return $"{callBack(node.children)}";
+ return $"{callBack(node.children)}";
case "tfoot":
- return $"{callBack(node.children)}";
+ return $"{callBack(node.children)}";
case "tr":
- return $"{callBack(node.children)}
";
+ return $"{callBack(node.children)}
";
case "th":
- return $"{callBack(node.children)} | ";
+ return $"{callBack(node.children)} | ";
case "td":
- return $"{callBack(node.children)} | ";
+ return $"{callBack(node.children)} | ";
case "blockquote":
return $"{callBack(node.children)}
";
case "code":
- return $"{callBack(node.children)}";
+ return $"{callBack(node.children)}";
default:
return callBack(node.children);
}
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 0000000..4f93bc6
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,5 @@
+
+
+ 1.0.2
+
+
diff --git a/LICENSE b/LICENSE
index df79778..3333caa 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright © 2012-2021 Contentstack. All Rights Reserved
+Copyright © 2012-2024 Contentstack. All Rights Reserved
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal