mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-14 00:34:23 +00:00
Added an option for mandatory terms of use dialogs (#725)
Build and Release / Determine run mode (push) Has been cancelled
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,deb,updater, appimage,deb) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,deb,updater, appimage,deb) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled
Build and Release / Determine run mode (push) Has been cancelled
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,deb,updater, appimage,deb) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,deb,updater, appimage,deb) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled
This commit is contained in:
1 parent
09258c7548
commit
8b11e2317b
29 files changed
+836
-21
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using Markdig;
|
||||
using System.Text;
|
||||
|
||||
namespace AIStudio.Tools;
|
||||
|
||||
@@ -26,4 +27,123 @@ public static class Markdown
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
public static string RemoveSharedIndentation(string value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
return string.Empty;
|
||||
|
||||
return RemoveSharedIndentation(value.AsSpan());
|
||||
}
|
||||
|
||||
private static string RemoveSharedIndentation(ReadOnlySpan<char> value)
|
||||
{
|
||||
var firstContentLineStart = -1;
|
||||
var lastContentLineStart = -1;
|
||||
var lastContentLineEnd = -1;
|
||||
var commonIndentation = int.MaxValue;
|
||||
var position = 0;
|
||||
|
||||
while (TryGetNextLine(value, position, out var lineStart, out var currentLineEnd, out var nextPosition))
|
||||
{
|
||||
var lineContent = value[lineStart..currentLineEnd];
|
||||
if (IsWhiteSpace(lineContent))
|
||||
{
|
||||
position = nextPosition;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (firstContentLineStart < 0)
|
||||
firstContentLineStart = lineStart;
|
||||
|
||||
lastContentLineStart = lineStart;
|
||||
lastContentLineEnd = currentLineEnd;
|
||||
commonIndentation = Math.Min(commonIndentation, CountIndentation(lineContent));
|
||||
position = nextPosition;
|
||||
}
|
||||
|
||||
if (firstContentLineStart < 0)
|
||||
return string.Empty;
|
||||
|
||||
if (commonIndentation == int.MaxValue)
|
||||
commonIndentation = 0;
|
||||
|
||||
var builder = new StringBuilder(lastContentLineEnd - firstContentLineStart);
|
||||
var shouldAppendLineBreak = false;
|
||||
position = firstContentLineStart;
|
||||
|
||||
while (TryGetNextLine(value, position, out var lineStart, out var lineEnd, out var nextPosition))
|
||||
{
|
||||
var lineContent = value[lineStart..lineEnd];
|
||||
|
||||
if (shouldAppendLineBreak)
|
||||
builder.Append('\n');
|
||||
|
||||
if (IsWhiteSpace(lineContent))
|
||||
shouldAppendLineBreak = true;
|
||||
else if (lineContent.Length > commonIndentation)
|
||||
{
|
||||
builder.Append(lineContent[commonIndentation..]);
|
||||
shouldAppendLineBreak = true;
|
||||
}
|
||||
else
|
||||
shouldAppendLineBreak = true;
|
||||
|
||||
if (lineStart == lastContentLineStart)
|
||||
break;
|
||||
|
||||
position = nextPosition;
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
private static bool IsWhiteSpace(ReadOnlySpan<char> value)
|
||||
{
|
||||
foreach (var character in value)
|
||||
{
|
||||
if (!char.IsWhiteSpace(character))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int CountIndentation(ReadOnlySpan<char> value)
|
||||
{
|
||||
var indentation = 0;
|
||||
while (indentation < value.Length && char.IsWhiteSpace(value[indentation]))
|
||||
indentation++;
|
||||
|
||||
return indentation;
|
||||
}
|
||||
|
||||
private static bool TryGetNextLine(ReadOnlySpan<char> value, int position, out int lineStart, out int lineEnd, out int nextPosition)
|
||||
{
|
||||
if (position > value.Length)
|
||||
{
|
||||
lineStart = 0;
|
||||
lineEnd = 0;
|
||||
nextPosition = position;
|
||||
return false;
|
||||
}
|
||||
|
||||
lineStart = position;
|
||||
for (var i = position; i < value.Length; i++)
|
||||
{
|
||||
if (value[i] != '\n')
|
||||
continue;
|
||||
|
||||
lineEnd = i > lineStart && value[i - 1] == '\r'
|
||||
? i - 1
|
||||
: i;
|
||||
|
||||
nextPosition = i + 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
lineEnd = value.Length;
|
||||
nextPosition = value.Length + 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user