Skip to content

Commit

Permalink
fixed html formatting issue for linux/windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ycechungAI committed Oct 8, 2021
1 parent 74d33e2 commit 117708a
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions kimchi-ssg/helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ static string generateHTMLStr(string[] source, string[] elements, string title,

}


string toHTMLfile = string.Join("\n", toHtml);
return toHTMLfile;
}
Expand Down Expand Up @@ -246,7 +247,11 @@ public static void strToFile(string s, string output)
substr = "/";
}
//suhhee_lab02 - create HTML files in dist folder in main directory
string[] html = HTMLstr.Split("\n");
string[] html;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
html = HTMLstr.Split("\n");
else
html = HTMLstr.Split("\r\n");
string sCurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
string sFile = sCurrentDirectory;//Path.Combine(sCurrentDirectory, substr); //windows can modify to ur usecase
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
Expand All @@ -271,10 +276,18 @@ public static void strToFile(string s, string output)
if (Path.GetExtension(s) == ".txt")
{
var text = File.ReadAllText(txtDirectory + substr + s); //removed "\\net5.0\\"


string fileName = Path.GetFileNameWithoutExtension(txtDirectory+ substr +s);
string extension = Path.GetExtension(txtDirectory+ substr + s);

string[] contents = text.Split("\n\n");
string[] contents;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
contents = text.Split("\n\n");
else
contents = text.Split("\r\n\r\n");


toHTMLfile = generateHTMLStr(html, contents, fileName, extension);
generateHTMLfile(toHTMLfile, txtDirectory + substr + output, fileName);
}
Expand Down Expand Up @@ -323,7 +336,9 @@ public static void strToFile(string s, string output)
}
else
{
contents = File.ReadAllText(filePath).Split("\n");
contents = File.ReadAllText(filePath).Split("\r\n\r\n");
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
contents = File.ReadAllText(filePath).Split("\n\n");
}
//suhhee_lab02

Expand Down

0 comments on commit 117708a

Please sign in to comment.