Add Utilities.MarkdownToText() (#903)

* Add Utilities.MarkdownToText()

* Add GET /Api/WWW/MarkdownToText?text={text} and sort usings alphabetically

* Revert sorting usings

* Sort functions

* Remove Log if the user is at fault

* Rename variable and adjust if for errors
This commit is contained in:
Abrynos
2018-09-20 22:20:52 +02:00
committed by Łukasz Domeradzki
parent b247ba6167
commit 18cd620db8
3 changed files with 25 additions and 0 deletions

View File

@@ -177,6 +177,21 @@ namespace ArchiSteamFarm {
return true;
}
internal static string MarkdownToText(string markdownText) {
if (string.IsNullOrEmpty(markdownText)) {
ASF.ArchiLogger.LogNullError(nameof(markdownText));
return null;
}
string plainText = Markdig.Markdown.ToPlainText(markdownText);
if (plainText == null) {
ASF.ArchiLogger.LogNullError(nameof(plainText));
return null;
}
return plainText;
}
internal static int RandomNext() {
lock (Random) {
return Random.Next();