Skip to content
This repository was archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
Moved MessageRenderer to Quarrel.Markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Avid29 committed Apr 28, 2022
1 parent 5e76adf commit ff358fe
Show file tree
Hide file tree
Showing 14 changed files with 370 additions and 96 deletions.
45 changes: 44 additions & 1 deletion Quarrel.sln
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Quarrel.Samples.RichPresenc
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Testing", "Testing", "{E3BFEBEE-5570-4885-B4C7-2CB3E7B04C60}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Quarrel.Testing.DirtyServices", "tests\Quarrel.Testing.DirtyServices\Quarrel.Testing.DirtyServices.csproj", "{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Quarrel.Testing.DirtyServices", "tests\Quarrel.Testing.DirtyServices\Quarrel.Testing.DirtyServices.csproj", "{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Quarrel.Markdown", "src\Libs\Quarrel.Markdown\Quarrel.Markdown.csproj", "{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -488,6 +490,46 @@ Global
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|x64.Build.0 = Release|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|x86.ActiveCfg = Release|Any CPU
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2}.Release|x86.Build.0 = Release|Any CPU
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Alpha|Any CPU.ActiveCfg = Debug|Any CPU
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Alpha|Any CPU.Build.0 = Debug|Any CPU
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Alpha|ARM.ActiveCfg = Debug|ARM
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Alpha|ARM.Build.0 = Debug|ARM
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Alpha|ARM64.ActiveCfg = Debug|ARM64
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Alpha|ARM64.Build.0 = Debug|ARM64
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Alpha|x64.ActiveCfg = Debug|x64
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Alpha|x64.Build.0 = Debug|x64
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Alpha|x86.ActiveCfg = Debug|x86
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Alpha|x86.Build.0 = Debug|x86
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Debug|ARM.ActiveCfg = Debug|ARM
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Debug|ARM.Build.0 = Debug|ARM
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Debug|ARM64.ActiveCfg = Debug|ARM64
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Debug|ARM64.Build.0 = Debug|ARM64
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Debug|x64.ActiveCfg = Debug|x64
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Debug|x64.Build.0 = Debug|x64
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Debug|x86.ActiveCfg = Debug|x86
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Debug|x86.Build.0 = Debug|x86
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Insider|Any CPU.ActiveCfg = Debug|Any CPU
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Insider|Any CPU.Build.0 = Debug|Any CPU
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Insider|ARM.ActiveCfg = Debug|ARM
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Insider|ARM.Build.0 = Debug|ARM
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Insider|ARM64.ActiveCfg = Debug|ARM64
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Insider|ARM64.Build.0 = Debug|ARM64
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Insider|x64.ActiveCfg = Debug|x64
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Insider|x64.Build.0 = Debug|x64
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Insider|x86.ActiveCfg = Debug|x86
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Insider|x86.Build.0 = Debug|x86
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Release|Any CPU.Build.0 = Release|Any CPU
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Release|ARM.ActiveCfg = Release|ARM
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Release|ARM.Build.0 = Release|ARM
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Release|ARM64.ActiveCfg = Release|ARM64
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Release|ARM64.Build.0 = Release|ARM64
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Release|x64.ActiveCfg = Release|x64
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Release|x64.Build.0 = Release|x64
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Release|x86.ActiveCfg = Release|x86
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -501,6 +543,7 @@ Global
{BA8BE893-2B4D-4213-A4AF-53AA28BF2E46} = {7B631D3A-F353-4557-B848-A68140341F53}
{4304E7AB-92E3-4313-AD8B-EFDCB033C0CE} = {7B631D3A-F353-4557-B848-A68140341F53}
{8BD6BF36-6ECD-4103-B064-1CAE37E954F2} = {E3BFEBEE-5570-4885-B4C7-2CB3E7B04C60}
{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3} = {29E0E840-B85F-4209-933B-8369DB2EA187}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2B4323A3-5C28-4929-AB1C-20CE992D6024}
Expand Down
File renamed without changes.
29 changes: 29 additions & 0 deletions src/Libs/Quarrel.Markdown/Parsing/AST.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Quarrel © 2022

using System;
using System.Collections.Generic;

namespace Quarrel.Markdown.Parsing
{
internal interface AST { }
internal abstract record ASTChildren(IList<AST> Children) : AST;

internal record CodeBlock(string Content, string Language) : AST;
internal record BlockQuote(IList<AST> Children) : ASTChildren(Children);
internal record ASTRoot(IList<AST> Children) : ASTChildren(Children);
internal record SurrogateEmoji(string Name, string Surrogate) : AST;
internal record Emoji(string Name, string Id) : AST;
internal record AnimatedEmoji(string Name, string Id) : AST;
internal record Url(string Content) : AST;
internal record Strong(IList<AST> Children) : ASTChildren(Children);
internal record Em(IList<AST> Children) : ASTChildren(Children);
internal record U(IList<AST> Children) : ASTChildren(Children);
internal record S(IList<AST> Children) : ASTChildren(Children);
internal record InlineCode(string Content) : AST;
internal record Timestamp(DateTime Time, string Format) : AST;
internal record RoleMention(string RoleID) : AST;
internal record Mention(ulong UserID) : AST;
internal record Channel(string ChannelID) : AST;
internal record Spoiler(IList<AST> Children) : ASTChildren(Children);
internal record Text(string Content) : AST;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Collections.Generic;
using System.Text;

namespace Quarrel.Controls.Message
namespace Quarrel.Markdown.Parsing
{
public static class EmojiTable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using System.Text;
using System.Text.RegularExpressions;

namespace Quarrel.Controls.Message
namespace Quarrel.Markdown.Parsing
{
public static class Parser
internal static class Parser
{
private static Regex heading = new Regex(@"^ *(#{1,3})(?:\s+)((?![#]+)[^\n]+?)#*\s*(?:\n|$)");
private static Regex codeBlock = new Regex(@"^```(?:([a-z0-9_+\-.]+?)\n)?\n*([^\n][\s\S]*?)\n*```");
Expand Down Expand Up @@ -44,7 +44,7 @@ public static class Parser
private static Regex textUnicodeRange = new Regex("^(?:\uDB40[\uDC61-\uDC7A])$");


public static IList<AST> ParseAST(string text, bool inlineState, bool nested)
internal static IList<AST> ParseAST(string text, bool inlineState, bool nested)
{
List<AST> collection = new List<AST>();
while (!string.IsNullOrEmpty(text))
Expand Down
29 changes: 29 additions & 0 deletions src/Libs/Quarrel.Markdown/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Quarrel.Markdown")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Quarrel.Markdown")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: ComVisible(false)]
33 changes: 33 additions & 0 deletions src/Libs/Quarrel.Markdown/Properties/Quarrel.Markdown.rd.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file contains Runtime Directives, specifications about types your application accesses
through reflection and other dynamic code patterns. Runtime Directives are used to control the
.NET Native optimizer and ensure that it does not remove code accessed by your library. If your
library does not do any reflection, then you generally do not need to edit this file. However,
if your library reflects over types, especially types passed to it or derived from its types,
then you should write Runtime Directives.
The most common use of reflection in libraries is to discover information about types passed
to the library. Runtime Directives have three ways to express requirements on types passed to
your library.
1. Parameter, GenericParameter, TypeParameter, TypeEnumerableParameter
Use these directives to reflect over types passed as a parameter.
2. SubTypes
Use a SubTypes directive to reflect over types derived from another type.
3. AttributeImplies
Use an AttributeImplies directive to indicate that your library needs to reflect over
types or methods decorated with an attribute.
For more information on writing Runtime Directives for libraries, please visit
https://go.microsoft.com/fwlink/?LinkID=391919
-->
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Library Name="Quarrel.Markdown">

<!-- add directives for your library here -->

</Library>
</Directives>
169 changes: 169 additions & 0 deletions src/Libs/Quarrel.Markdown/Quarrel.Markdown.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E4B6DFB8-B9B7-4EE7-9F86-AFDDC221FFB3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Quarrel.Markdown</RootNamespace>
<AssemblyName>Quarrel.Markdown</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.22000.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'">
<PlatformTarget>ARM64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM64'">
<PlatformTarget>ARM64</PlatformTarget>
<OutputPath>bin\ARM64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup>
<ItemGroup>
<Compile Include="Parsing\EmojiTable.cs" />
<Compile Include="IsExternalInit.cs" />
<Compile Include="Parsing\AST.cs" />
<Compile Include="Parsing\Parser.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Rendering\MessageRenderer.cs" />
<EmbeddedResource Include="Properties\Quarrel.Markdown.rd.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Humanizer">
<Version>2.8.25</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.13</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls">
<Version>7.1.2</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Page Include="Themes\Generic.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Quarrel.Client\Quarrel.Client.csproj">
<Project>{e20b2927-0c9e-437f-9b51-b76bae2ef67c}</Project>
<Name>Quarrel.Client</Name>
</ProjectReference>
<ProjectReference Include="..\..\Quarrel.ViewModels\Quarrel.ViewModels.csproj">
<Project>{e069a285-68fe-43c7-957f-9cc6bbf17bce}</Project>
<Name>Quarrel.ViewModels</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Loading

0 comments on commit ff358fe

Please sign in to comment.