diff --git a/CSTNet.Tests/QuickFennec.CST.Tests.csproj b/CSTNet.Tests/Sixam.CST.Tests.csproj
similarity index 94%
rename from CSTNet.Tests/QuickFennec.CST.Tests.csproj
rename to CSTNet.Tests/Sixam.CST.Tests.csproj
index d94aef9..fbc2709 100644
--- a/CSTNet.Tests/QuickFennec.CST.Tests.csproj
+++ b/CSTNet.Tests/Sixam.CST.Tests.csproj
@@ -19,7 +19,7 @@
-
+
diff --git a/CSTNet.Tests/v2.cst b/CSTNet.Tests/v2.cst
index 773bc88..c2fb4d6 100644
--- a/CSTNet.Tests/v2.cst
+++ b/CSTNet.Tests/v2.cst
@@ -1,4 +1,4 @@
Singleline^Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ultricies nulla eu tortor mattis, dictum posuere lacus ornare. Maecenas a massa in ligula finibus luctus eu vitae nibh. Proin imperdiet dapibus mauris quis placerat.^
Multiline ^Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc gravida nunc non justo pretium consectetur. Sed tempus libero ac ligula aliquam elementum. Duis vitae interdum leo. Sed semper nulla %1 a lectus dictum dictum.
-Quisque vehicula, nisi ut scelerisque sodales, nisi ipsum sodales ipsum, in rutrum tellus lacus sed nibh. Etiam mauris velit, elementum sed placerat et, elementum et tellus. Duis vitae elit fermentum, viverra lorem in, lobortis elit.^
\ No newline at end of file
+Quisque vehicula, nisi ut scelerisque sodales, nisi ipsum sodales ipsum, in rutrum tellus lacus sed nibh. Etiam mauris velit, elementum sed placerat et, elementum et tellus. Duis vitae elit fermentum, viverra lorem in, lobortis elit^
\ No newline at end of file
diff --git a/CSTNet/CaretSeparatedText.cs b/CSTNet/CaretSeparatedText.cs
index 7244695..8c7a81a 100644
--- a/CSTNet/CaretSeparatedText.cs
+++ b/CSTNet/CaretSeparatedText.cs
@@ -38,46 +38,36 @@ namespace CSTNet
/// This stage ensures there are no crashes during parsing.
static IEnumerable NormalizeEntries(string content)
{
-
- /*
- I tried putting the end carets with the different
- line endings in with the split function but it didn't work
- */
- if (!content.Contains($"{CARET}{Environment.NewLine}"))
+ if (!content.Contains(Environment.NewLine))
{
- if (content.Contains($"{CARET}{_lf}"))
- content = content.Replace($"{CARET}{_lf}",
- $"{CARET}{Environment.NewLine}");
+ if (content.Contains(_lf))
+ content = content.Replace(_lf, Environment.NewLine);
- if (content.Contains($"{CARET}{_cr}"))
- content = content.Replace($"{CARET}{_cr}",
- $"{CARET}{Environment.NewLine}");
+ if (content.Contains(_cr))
+ content = content.Replace(_cr, Environment.NewLine);
- if (content.Contains($"{CARET}{_crlf}"))
- content = content.Replace($"{CARET}{_crlf}",
- $"{CARET}{Environment.NewLine}");
+ if (content.Contains(_crlf))
+ content = content.Replace(_crlf, Environment.NewLine);
- if (content.Contains($"{CARET}{_ls}"))
- content = content.Replace($"{CARET}{_ls}",
- $"{CARET}{Environment.NewLine}");
+ if (content.Contains(_ls))
+ content = content.Replace(_ls, Environment.NewLine);
}
-
- var entries = content.Split(new[] { $"{CARET}{Environment.NewLine}" },
+ var lines = content.Split(new[] { $"{CARET}{Environment.NewLine}" },
StringSplitOptions.RemoveEmptyEntries);
- var newContent = new List();
+ var entries = new List();
- foreach (var entry in entries)
+ foreach (var line in lines)
{
// Skip comments
- if (entry.StartsWith(@"//") || entry.StartsWith("#") ||
- entry.StartsWith("/*") || entry.EndsWith("*/"))
+ if (line.StartsWith("//") || line.StartsWith("#") ||
+ line.StartsWith("/*") || line.EndsWith("*/"))
continue;
- newContent.Add(entry);
+ entries.Add(line);
}
- return newContent;
+ return entries;
}
static string GetEntry(IEnumerable entries, string key)
@@ -85,32 +75,18 @@ namespace CSTNet
// Search through list
foreach (var entry in entries)
{
- // Locate index, trim carets and return translation
+ // If the line doesn't start with the key, keep searching.
if (!entry.StartsWith(key))
continue;
+ // Locate index, trim carets and return translation.
var startIndex = entry.IndexOf(CARET);
var line = entry.Substring(startIndex);
- if (!line.Contains(Environment.NewLine))
- {
- if (line.Contains(_lf))
- line = line.Replace(_lf, Environment.NewLine);
-
- if (line.Contains(_cr))
- line = line.Replace(_cr, Environment.NewLine);
-
- if (line.Contains(_crlf))
- line = line.Replace(_crlf, Environment.NewLine);
-
- if (line.Contains(_ls))
- line = line.Replace(_ls, Environment.NewLine);
- }
-
return line.TrimStart(CARET).TrimEnd(CARET);
}
- return "[ENTRY NOT FOUND]";
+ return "***MISSING***";
}
}
}
diff --git a/CSTNet/QuickFennec.CST.csproj b/CSTNet/Sixam.CST.csproj
similarity index 84%
rename from CSTNet/QuickFennec.CST.csproj
rename to CSTNet/Sixam.CST.csproj
index d008079..129d2db 100644
--- a/CSTNet/QuickFennec.CST.csproj
+++ b/CSTNet/Sixam.CST.csproj
@@ -2,10 +2,10 @@
netstandard2.0
- 1.0.1
+ 1.0.2
Tony Bark
Caret-Separated Text (or CST) is a key-value pair format represented by numbers or words as keys and the value is the string enclosed between carets (^) that contains the contents. CST.NET is a library for prasing the CST format.
- https://github.com/tonytins/cstnet
+ https://github.com/sixamsoft/cst-dotnet
MIT
CST.Net
CSTNet
diff --git a/README.md b/README.md
index 7c8cb71..e6b301a 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,17 @@
-# QuickFennec.CST
+# Sixam.CST
[](https://opensource.org/licenses/MIT) [](code_of_conduct.md)
-Caret-Separated Text (or CST) is a key-value pair format represented by numbers or words as keys and the value is the string enclosed between carets (^) that contains the contents. Any text which is not enclosed with carets is considered a comment and ignored. Neither strings nor comments may use the caret character.
-
-QuickFennec.CST is a library for parsing the CST format.
+Caret-Separated Text (or CST) is a key-value pair format represented by digits or words as keys and the value as text enclosed between carets. (e.g. `` ^^``) Any text which is not enclosed with carets is considered a comment and ignored. Neither strings nor comments may use the caret character. Sixam.CST is a library for parsing the CST format.
## Usage
+```text
+1 ^The quick brown fox jumps over the lazy dog.^
+```
+
```csharp
-#r "nuget:CSTNet,1.0.1"
+#r "nuget:CSTNet,1.0.2"
using System;
using System.IO;
using CSTNet;
@@ -20,12 +22,14 @@ var example = CaretSeparatedText.Parse(file, 1);
Console.WriteLine(example);
```
-In production, CST files were used in The Sims Online to provide translations. Each translation was split into their respective directories:
+See working example on [.NET Fiddle](https://dotnetfiddle.net/ecKb2h).
-- ``uitext/english.dir/misc/_154_miscstrings.cst``
-- ``uitext/swedish.dir/misc/_154_miscstrings.cst``
+In production, CST files were used in The Sims Online (TSO) to provide translations. Each translation was split into their respective directories:
-QuickFennec.CST only provides the basic parsing functionality.
+- ``uitext/english.dir/_154_miscstrings.cst``
+- ``uitext/swedish.dir/_154_miscstrings.cst``
+
+Sixam.CST only provides the basic parsing functionality.
## To-do
@@ -34,7 +38,6 @@ QuickFennec.CST only provides the basic parsing functionality.
## Known issues
- Skipping comments is a little buggy.
-- Multiline parsing with the v2 format is still unpredictable.
## Requirements
### Prerequisites
diff --git a/CSTNet.sln b/Sixam.CST.sln
similarity index 83%
rename from CSTNet.sln
rename to Sixam.CST.sln
index cdcdfc9..a166832 100644
--- a/CSTNet.sln
+++ b/Sixam.CST.sln
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30717.126
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QuickFennec.CST", "CSTNet\QuickFennec.CST.csproj", "{82775826-A366-46F0-A5D2-5BE7658C75E4}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sixam.CST", "CSTNet\Sixam.CST.csproj", "{82775826-A366-46F0-A5D2-5BE7658C75E4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CCFCE2DB-C18F-4D88-B025-19ED62BD2A1D}"
ProjectSection(SolutionItems) = preProject
@@ -12,7 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
EndProjectSection
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QuickFennec.CST.Tests", "CSTNet.Tests\QuickFennec.CST.Tests.csproj", "{B6A98C64-1419-4B9A-99CA-72BB11D29472}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sixam.CST.Tests", "CSTNet.Tests\Sixam.CST.Tests.csproj", "{B6A98C64-1419-4B9A-99CA-72BB11D29472}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
diff --git a/changelog.md b/changelog.md
index d7cd0c3..db502f8 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,8 @@
# Change Log
+## 1.0.2
+- Fixed the multiple line parsing in the v2 format.
+- Replaced "``[ENTRY NOT FOUND]``" message with "``***MISSING***``".
## 1.0.1
Despite only being a point release, this includes a major refinement to the normalizing algorithm.
@@ -10,7 +13,7 @@ The normalizing algorithm has been rewritten to be more efficient and hopefully
### CSTNet compatibility
-For point releases (such as this), QuickFennec.CST will remain under the CSTNet namespace for compatibility reasons. CSTNet will be moved to QuickFennec.CST namespace starting with 1.1.
+For point releases (such as this), Sixam.CST will remain under the CSTNet namespace for compatibility reasons. CSTNet will be moved to Sixam.CST namespace starting with 1.1.
### Known issues
diff --git a/notebooks/cst.ipynb b/notebooks/cst.ipynb
index 577aa7d..791ff97 100644
--- a/notebooks/cst.ipynb
+++ b/notebooks/cst.ipynb
@@ -63,46 +63,36 @@
" /// This stage ensures there are no crashes during parsing.\n",
" static IEnumerable NormalizeEntries(string content)\n",
" {\n",
- "\n",
- " /* \n",
- " I tried putting the end carets with the different\n",
- " line endings in with the split function but it didn't work \n",
- " */\n",
- " if (!content.Contains($\"{CARET}{Environment.NewLine}\"))\n",
+ " if (!content.Contains(Environment.NewLine))\n",
" {\n",
- " if (content.Contains($\"{CARET}{_lf}\"))\n",
- " content = content.Replace($\"{CARET}{_lf}\",\n",
- " $\"{CARET}{Environment.NewLine}\");\n",
+ " if (content.Contains(_lf))\n",
+ " content = content.Replace(_lf, Environment.NewLine);\n",
"\n",
- " if (content.Contains($\"{CARET}{_cr}\"))\n",
- " content = content.Replace($\"{CARET}{_cr}\",\n",
- " $\"{CARET}{Environment.NewLine}\");\n",
+ " if (content.Contains(_cr))\n",
+ " content = content.Replace(_cr, Environment.NewLine);\n",
"\n",
- " if (content.Contains($\"{CARET}{_crlf}\"))\n",
- " content = content.Replace($\"{CARET}{_crlf}\",\n",
- " $\"{CARET}{Environment.NewLine}\");\n",
+ " if (content.Contains(_crlf))\n",
+ " content = content.Replace(_crlf, Environment.NewLine);\n",
"\n",
- " if (content.Contains($\"{CARET}{_ls}\"))\n",
- " content = content.Replace($\"{CARET}{_ls}\",\n",
- " $\"{CARET}{Environment.NewLine}\");\n",
+ " if (content.Contains(_ls))\n",
+ " content = content.Replace(_ls, Environment.NewLine);\n",
" }\n",
"\n",
- "\n",
- " var entries = content.Split(new[] { $\"{CARET}{Environment.NewLine}\" },\n",
+ " var lines = content.Split(new[] { $\"{CARET}{Environment.NewLine}\" },\n",
" StringSplitOptions.RemoveEmptyEntries);\n",
- " var newContent = new List();\n",
+ " var entries = new List();\n",
"\n",
- " foreach (var entry in entries)\n",
+ " foreach (var line in lines)\n",
" {\n",
" // Skip comments\n",
- " if (entry.StartsWith(@\"//\") || entry.StartsWith(\"#\") ||\n",
- " entry.StartsWith(\"/*\") || entry.EndsWith(\"*/\"))\n",
+ " if (line.StartsWith(\"//\") || line.StartsWith(\"#\") ||\n",
+ " line.StartsWith(\"/*\") || line.EndsWith(\"*/\"))\n",
" continue;\n",
"\n",
- " newContent.Add(entry);\n",
+ " entries.Add(line);\n",
" }\n",
"\n",
- " return newContent;\n",
+ " return entries;\n",
" }\n",
"\n",
" static string GetEntry(IEnumerable entries, string key)\n",
@@ -110,32 +100,18 @@
" // Search through list\n",
" foreach (var entry in entries)\n",
" {\n",
- " // Locate index, trim carets and return translation\n",
+ " // If the line doesn't start with the key, keep searching.\n",
" if (!entry.StartsWith(key))\n",
" continue;\n",
"\n",
+ " // Locate index, trim carets and return translation.\n",
" var startIndex = entry.IndexOf(CARET);\n",
" var line = entry.Substring(startIndex);\n",
"\n",
- " if (!line.Contains(Environment.NewLine))\n",
- " {\n",
- " if (line.Contains(_lf))\n",
- " line = line.Replace(_lf, Environment.NewLine);\n",
- "\n",
- " if (line.Contains(_cr))\n",
- " line = line.Replace(_cr, Environment.NewLine);\n",
- "\n",
- " if (line.Contains(_crlf))\n",
- " line = line.Replace(_crlf, Environment.NewLine);\n",
- "\n",
- " if (line.Contains(_ls))\n",
- " line = line.Replace(_ls, Environment.NewLine);\n",
- " }\n",
- "\n",
" return line.TrimStart(CARET).TrimEnd(CARET);\n",
" }\n",
"\n",
- " return \"[ENTRY NOT FOUND]\";\n",
+ " return \"***MISSING***\";\n",
" }\n",
"}"
],
@@ -206,7 +182,7 @@
{
"output_type": "execute_result",
"data": {
- "text/plain": "Multiline v2:\r\n[ENTRY NOT FOUND]\r\n"
+ "text/plain": "Multiline v2:\r\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc gravida nunc non justo pretium consectetur. Sed tempus libero ac ligula aliquam elementum. Duis vitae interdum leo. Sed semper nulla %1 a lectus dictum dictum.\r\n\r\nQuisque vehicula, nisi ut scelerisque sodales, nisi ipsum sodales ipsum, in rutrum tellus lacus sed nibh. Etiam mauris velit, elementum sed placerat et, elementum et tellus. Duis vitae elit fermentum, viverra lorem in, lobortis elit\r\n"
},
"execution_count": 1,
"metadata": {}
diff --git a/notebooks/data/v2.cst b/notebooks/data/v2.cst
index 2949b37..c2fb4d6 100644
--- a/notebooks/data/v2.cst
+++ b/notebooks/data/v2.cst
@@ -1,6 +1,4 @@
Singleline^Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ultricies nulla eu tortor mattis, dictum posuere lacus ornare. Maecenas a massa in ligula finibus luctus eu vitae nibh. Proin imperdiet dapibus mauris quis placerat.^
-/* this is a
-test comment */
-Multiline^Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc gravida nunc non justo pretium consectetur. Sed tempus libero ac ligula aliquam elementum. Duis vitae interdum leo. Sed semper nulla %1 a lectus dictum dictum. Ut mattis eu tortor in bibendum. Integer mattis tincidunt aliquet. Vestibulum ante ipsum primis in faucibus orci %2 luctus et ultrices posuere cubilia Curae; Fusce quis orci nisl.
+Multiline ^Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc gravida nunc non justo pretium consectetur. Sed tempus libero ac ligula aliquam elementum. Duis vitae interdum leo. Sed semper nulla %1 a lectus dictum dictum.
-Quisque vehicula, nisi ut scelerisque sodales, nisi ipsum sodales ipsum, in rutrum tellus lacus sed nibh. Etiam mauris velit, elementum sed placerat et, elementum et tellus. Duis vitae elit fermentum, viverra lorem in, lobortis elit. Maecenas eget nibh et lectus auctor dignissim.^
\ No newline at end of file
+Quisque vehicula, nisi ut scelerisque sodales, nisi ipsum sodales ipsum, in rutrum tellus lacus sed nibh. Etiam mauris velit, elementum sed placerat et, elementum et tellus. Duis vitae elit fermentum, viverra lorem in, lobortis elit^
\ No newline at end of file