diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-06-04 16:03:56 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-06-04 16:03:56 +0100 |
| commit | 45e530dceda42282fae56b4c4f5fa7865f57899d (patch) | |
| tree | 685868f4bf78c64e851cbcdafd674e887bc782a5 | |
| parent | b5a83b1cb96d410e325ff8b733d550295376d8c7 (diff) | |
Remove dotnet (use submodule from dotnet repo instead)
75 files changed, 0 insertions, 2411 deletions
diff --git a/couscous.json b/couscous.json deleted file mode 100644 index e628c14..0000000 --- a/couscous.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "backend": "csharp", - "sourcepath": [ - "src/main/java" - ], - "files": [ - "src/main/java/org/zwobble/mammoth", - "!src/main/java/org/zwobble/mammoth/DocumentConverter.java", - "!src/main/java/org/zwobble/mammoth/internal/docx/ZippedDocxFile.java", - "!src/main/java/org/zwobble/mammoth/internal/docx/InMemoryDocxFile.java", - "!src/main/java/org/zwobble/mammoth/internal/styles/parsing/LineParseException.java", - "!src/main/java/org/zwobble/mammoth/internal/styles/parsing/ParseException.java", - "!src/main/java/org/zwobble/mammoth/internal/util", - "src/main/java/org/zwobble/mammoth/internal/util/InputStreamSupplier.java", - "src/main/java/org/zwobble/mammoth/internal/util/Optionals.java", - "src/main/java/org/zwobble/mammoth/internal/util/SupplierWithException.java", - "!src/main/java/org/zwobble/mammoth/internal/xml/parsing/SimpleSax.java" - - ], - "output": "dotnet/Mammoth/generated.cs", - "namespace": "Mammoth.Couscous" -} diff --git a/dotnet/.gitignore b/dotnet/.gitignore deleted file mode 100644 index 217ab7a..0000000 --- a/dotnet/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -/Mammoth/generated.cs -/Mammoth/bin -/Mammoth/obj -/Mammoth.Cli/bin -/Mammoth.Cli/obj -/Mammoth.Tests/bin -/Mammoth.Tests/obj -/packages -*.userprefs diff --git a/dotnet/.nuget/packages.config b/dotnet/.nuget/packages.config deleted file mode 100644 index 4bbca7b..0000000 --- a/dotnet/.nuget/packages.config +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<packages> - <package id="xunit.runner.console" version="2.1.0" /> -</packages>
\ No newline at end of file diff --git a/dotnet/Mammoth.Cli/Mammoth.Cli.csproj b/dotnet/Mammoth.Cli/Mammoth.Cli.csproj deleted file mode 100644 index f7e125e..0000000 --- a/dotnet/Mammoth.Cli/Mammoth.Cli.csproj +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProjectGuid>{20602E78-EEBD-407B-B8C3-EDB6254BD663}</ProjectGuid> - <OutputType>Exe</OutputType> - <RootNamespace>Mammoth.Cli</RootNamespace> - <AssemblyName>Mammoth.Cli</AssemblyName> - <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug</OutputPath> - <DefineConstants>DEBUG;</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <Externalconsole>true</Externalconsole> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <DebugType>full</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release</OutputPath> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <Externalconsole>true</Externalconsole> - </PropertyGroup> - <ItemGroup> - <Reference Include="System" /> - </ItemGroup> - <ItemGroup> - <Compile Include="Program.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> - </ItemGroup> - <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> - <ItemGroup> - <ProjectReference Include="..\Mammoth\Mammoth.csproj"> - <Project>{51C5CBD6-8809-4D5E-BABE-1787A16F5ED8}</Project> - <Name>Mammoth</Name> - </ProjectReference> - </ItemGroup> -</Project>
\ No newline at end of file diff --git a/dotnet/Mammoth.Cli/Program.cs b/dotnet/Mammoth.Cli/Program.cs deleted file mode 100644 index f45b100..0000000 --- a/dotnet/Mammoth.Cli/Program.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using Mammoth; - -namespace Mammoth.Cli { - internal class Program { - public static void Main(string[] args) { - var result = new DocumentConverter().ConvertToHtml(args[0]); - Console.WriteLine(result.Value); - } - } -} diff --git a/dotnet/Mammoth.Cli/Properties/AssemblyInfo.cs b/dotnet/Mammoth.Cli/Properties/AssemblyInfo.cs deleted file mode 100644 index 1f83366..0000000 --- a/dotnet/Mammoth.Cli/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. - -[assembly: AssemblyTitle ("Mammoth.Cli")] -[assembly: AssemblyDescription ("")] -[assembly: AssemblyConfiguration ("")] -[assembly: AssemblyCompany ("")] -[assembly: AssemblyProduct ("")] -[assembly: AssemblyCopyright ("Michael Williamson")] -[assembly: AssemblyTrademark ("")] -[assembly: AssemblyCulture ("")] - -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. - -[assembly: AssemblyVersion ("1.0.*")] - -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. - -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - diff --git a/dotnet/Mammoth.Tests/DocumentConverterTests.cs b/dotnet/Mammoth.Tests/DocumentConverterTests.cs deleted file mode 100644 index 92a3adf..0000000 --- a/dotnet/Mammoth.Tests/DocumentConverterTests.cs +++ /dev/null @@ -1,214 +0,0 @@ -using Xunit; -using System.IO; -using Xunit.Sdk; -using System; -using System.Linq; - -namespace Mammoth.Tests { - public class DocumentConverterTests { - [Fact] - public void DocxContainingOneParagraphIsConvertedToSingleParagraphElement() { - AssertSuccessfulConversion( - ConvertToHtml("single-paragraph.docx"), - "<p>Walking on imported air</p>"); - } - - [Fact] - public void CanReadFilesWithUtf8Bom() { - AssertSuccessfulConversion( - ConvertToHtml("utf8-bom.docx"), - "<p>This XML has a byte order mark.</p>"); - } - - [Fact] - public void EmptyParagraphsAreIgnoredByDefault() { - AssertSuccessfulConversion( - ConvertToHtml("empty.docx"), - ""); - } - - [Fact] - public void EmptyParagraphsArePreservedIfIgnoreEmptyParagraphsIsFalse() { - AssertSuccessfulConversion( - ConvertToHtml("empty.docx", converter => converter.PreserveEmptyParagraphs()), - "<p></p>"); - } - - [Fact] - public void SimpleListIsConvertedToListElements() { - AssertSuccessfulConversion( - ConvertToHtml("simple-list.docx"), - "<ul><li>Apple</li><li>Banana</li></ul>"); - } - - [Fact] - public void WordTablesAreConvertedToHtmlTables() { - AssertSuccessfulConversion( - ConvertToHtml("tables.docx"), - "<p>Above</p>" + - "<table>" + - "<tr><td><p>Top left</p></td><td><p>Top right</p></td></tr>" + - "<tr><td><p>Bottom left</p></td><td><p>Bottom right</p></td></tr>" + - "</table>" + - "<p>Below</p>"); - } - - [Fact] - public void InlineImagesAreIncludedInOutput() { - AssertSuccessfulConversion( - ConvertToHtml("tiny-picture.docx"), - "<p><img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAOvgAADr4B6kKxwAAAABNJREFUKFNj/M+ADzDhlWUYqdIAQSwBE8U+X40AAAAASUVORK5CYII=\" /></p>"); - } - - [Fact] - public void ImagesStoredOutsideOfDocumentAreIncludedInOutput() { - AssertSuccessfulConversion( - ConvertToHtml("external-picture.docx"), - "<p><img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAOvgAADr4B6kKxwAAAABNJREFUKFNj/M+ADzDhlWUYqdIAQSwBE8U+X40AAAAASUVORK5CYII=\" /></p>"); - } - - [Fact] - public void WarnIfDocumentHasImagesStoredOutsideOfDocumentWhenPathOfDocumentIsUnknown() { - using (var file = File.OpenRead(TestFilePath("external-picture.docx"))) { - var result = new DocumentConverter().ConvertToHtml(file); - Assert.Equal("", result.Value); - Assert.Equal(new[]{"could not open external image 'tiny-picture.png': path of document is unknown, but is required for relative URI"}, result.Warnings); - } - } - - [Fact] - public void WarnIfImagesStoredOutsideOfDocumentAreNotFound() { - var tempDirectory = Path.Combine(Path.GetTempPath(), "mammoth-" + Guid.NewGuid()); - Directory.CreateDirectory(tempDirectory); - try { - var documentPath = Path.Combine(tempDirectory, "external-picture.docx"); - File.Copy(TestFilePath("external-picture.docx"), documentPath); - var result = new DocumentConverter().ConvertToHtml(documentPath); - Assert.Equal("", result.Value); - Assert.StartsWith("could not open external image 'tiny-picture.png':", result.Warnings.Single()); - } finally { - Directory.Delete(tempDirectory, recursive: true); - } - } - - [Fact] - public void ContentTypesAreRead() { - AssertSuccessfulConversion( - ConvertToHtml("tiny-picture-custom-content-type.docx"), - "<p><img src=\"data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAOvgAADr4B6kKxwAAAABNJREFUKFNj/M+ADzDhlWUYqdIAQSwBE8U+X40AAAAASUVORK5CYII=\" /></p>"); - } - - [Fact] - public void FootnotesAreAppendedToText() { - AssertSuccessfulConversion( - ConvertToHtml("footnotes.docx", mammoth => mammoth.IdPrefix("doc-42-")), - "<p>Ouch" + - "<sup><a href=\"#doc-42-footnote-1\" id=\"doc-42-footnote-ref-1\">[1]</a></sup>." + - "<sup><a href=\"#doc-42-footnote-2\" id=\"doc-42-footnote-ref-2\">[2]</a></sup></p>" + - "<ol><li id=\"doc-42-footnote-1\"><p> A tachyon walks into a bar. <a href=\"#doc-42-footnote-ref-1\">↑</a></p></li>" + - "<li id=\"doc-42-footnote-2\"><p> Fin. <a href=\"#doc-42-footnote-ref-2\">↑</a></p></li></ol>"); - } - - [Fact] - public void EndNotesAreAppendedToText() { - AssertSuccessfulConversion( - ConvertToHtml("endnotes.docx", mammoth => mammoth.IdPrefix("doc-42-")), - "<p>Ouch" + - "<sup><a href=\"#doc-42-endnote-2\" id=\"doc-42-endnote-ref-2\">[1]</a></sup>." + - "<sup><a href=\"#doc-42-endnote-3\" id=\"doc-42-endnote-ref-3\">[2]</a></sup></p>" + - "<ol><li id=\"doc-42-endnote-2\"><p> A tachyon walks into a bar. <a href=\"#doc-42-endnote-ref-2\">↑</a></p></li>" + - "<li id=\"doc-42-endnote-3\"><p> Fin. <a href=\"#doc-42-endnote-ref-3\">↑</a></p></li></ol>"); - } - - [Fact] - public void RelationshipsAreReadForEachFileContainingBodyXml() { - AssertSuccessfulConversion( - ConvertToHtml("footnote-hyperlink.docx", mammoth => mammoth.IdPrefix("doc-42-")), - - "<p><sup><a href=\"#doc-42-footnote-1\" id=\"doc-42-footnote-ref-1\">[1]</a></sup></p>" + - "<ol><li id=\"doc-42-footnote-1\"><p> <a href=\"http://www.example.com\">Example</a> <a href=\"#doc-42-footnote-ref-1\">↑</a></p></li></ol>"); - } - - [Fact] - public void TextBoxesAreRead() { - AssertSuccessfulConversion( - ConvertToHtml("text-box.docx"), - "<p>Datum plane</p>"); - } - - [Fact] - public void CanUseCustomStyleMap() { - AssertSuccessfulConversion( - ConvertToHtml("underline.docx", mammoth => mammoth.AddStyleMap("u => em")), - "<p><strong>The <em>Sunset</em> Tree</strong></p>"); - } - - [Fact] - public void MostRecentlyAddedStyleMapTakesPrecedence() { - AssertSuccessfulConversion( - ConvertToHtml("underline.docx", mammoth => mammoth.AddStyleMap("u => em").AddStyleMap("u => strong")), - "<p><strong>The <strong>Sunset</strong> Tree</strong></p>"); - } - - [Fact] - public void RulesFromPreviouslyAddedStyleMapsStillTakeEffectIfNotOverridden() { - AssertSuccessfulConversion( - ConvertToHtml("underline.docx", mammoth => mammoth.AddStyleMap("u => em").AddStyleMap("strike => del")), - "<p><strong>The <em>Sunset</em> Tree</strong></p>"); - } - - [Fact] - public void ErrorIsRaisedIfStyleMapCannotBeParsed() { - var exception = Assert.ThrowsAny<Exception>(() => - new DocumentConverter().AddStyleMap("p =>\np[style-name=] =>")); - Assert.Equal( - "error reading style map at line 2, character 14: expected token of type _STRING but was of type _CLOSE_SQUARE_BRACKET\n\n" + - "p[style-name=] =>\n" + - " ^", - exception.Message); - } - - [Fact] - public void CanDisableDefaultStyleMap() { - var result = ConvertToHtml("simple-list.docx", mammoth => mammoth.DisableDefaultStyleMap()); - Assert.Equal(new[]{"Unrecognised paragraph style: List Paragraph (Style ID: ListParagraph)"}, result.Warnings); - Assert.Equal("<p>Apple</p><p>Banana</p>", result.Value); - } - - [Fact] - public void CanExtractRawTextFromFile() { - AssertSuccessfulConversion( - new DocumentConverter().ExtractRawText(TestFilePath("simple-list.docx")), - "Apple\n\nBanana\n\n"); - } - - [Fact] - public void CanExtractRawTextFromStream() { - using (var file = File.OpenRead(TestFilePath("simple-list.docx"))) { - AssertSuccessfulConversion( - new DocumentConverter().ExtractRawText(file), - "Apple\n\nBanana\n\n"); - } - } - - private void AssertSuccessfulConversion(IResult<string> result, string expectedValue) { - if (result.Warnings.Count > 0) { - throw new XunitException("Unexpected warnings: " + string.Join(", ", result.Warnings)); - } - Assert.Equal(expectedValue, result.Value); - } - - private IResult<string> ConvertToHtml(string name) { - return ConvertToHtml(name, converter => converter); - } - - private IResult<string> ConvertToHtml(string name, Func<DocumentConverter, DocumentConverter> configure) { - return configure(new DocumentConverter()).ConvertToHtml(TestFilePath(name)); - } - - private string TestFilePath(string name) { - return Path.Combine("../../TestData", name); - } - } -} - diff --git a/dotnet/Mammoth.Tests/Mammoth.Tests.csproj b/dotnet/Mammoth.Tests/Mammoth.Tests.csproj deleted file mode 100644 index d561dde..0000000 --- a/dotnet/Mammoth.Tests/Mammoth.Tests.csproj +++ /dev/null @@ -1,77 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProjectGuid>{E9C3EA8B-FF3B-4E3E-8137-1510465200B5}</ProjectGuid> - <OutputType>Library</OutputType> - <RootNamespace>Mammoth.Tests</RootNamespace> - <AssemblyName>Mammoth.Tests</AssemblyName> - <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug</OutputPath> - <DefineConstants>DEBUG;</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <ConsolePause>false</ConsolePause> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <DebugType>full</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release</OutputPath> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <ConsolePause>false</ConsolePause> - </PropertyGroup> - <ItemGroup> - <Reference Include="System" /> - <Reference Include="xunit.abstractions"> - <HintPath>..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath> - </Reference> - <Reference Include="xunit.core"> - <HintPath>..\packages\xunit.extensibility.core.2.1.0\lib\portable-net45+win8+wp8+wpa81\xunit.core.dll</HintPath> - </Reference> - <Reference Include="xunit.execution.desktop"> - <HintPath>..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll</HintPath> - </Reference> - <Reference Include="xunit.assert"> - <HintPath>..\packages\xunit.assert.2.1.0\lib\portable-net45+win8+wp8+wpa81\xunit.assert.dll</HintPath> - </Reference> - </ItemGroup> - <ItemGroup> - <Compile Include="Properties\AssemblyInfo.cs" /> - <Compile Include="DocumentConverterTests.cs" /> - </ItemGroup> - <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> - <Import Project="..\packages\xunit.core.2.1.0\build\portable-net45+win8+wp8+wpa81\xunit.core.props" Condition="Exists('..\packages\xunit.core.2.1.0\build\portable-net45+win8+wp8+wpa81\xunit.core.props')" /> - <ItemGroup> - <None Include="packages.config" /> - </ItemGroup> - <ItemGroup> - <EmbeddedResource Include="TestData\empty.docx" /> - <EmbeddedResource Include="TestData\endnotes.docx" /> - <EmbeddedResource Include="TestData\external-picture.docx" /> - <EmbeddedResource Include="TestData\footnote-hyperlink.docx" /> - <EmbeddedResource Include="TestData\footnotes.docx" /> - <EmbeddedResource Include="TestData\simple-list.docx" /> - <EmbeddedResource Include="TestData\single-paragraph.docx" /> - <EmbeddedResource Include="TestData\strikethrough.docx" /> - <EmbeddedResource Include="TestData\tables.docx" /> - <EmbeddedResource Include="TestData\text-box.docx" /> - <EmbeddedResource Include="TestData\tiny-picture.docx" /> - <EmbeddedResource Include="TestData\tiny-picture.png" /> - <EmbeddedResource Include="TestData\tiny-picture-custom-content-type.docx" /> - <EmbeddedResource Include="TestData\underline.docx" /> - <EmbeddedResource Include="TestData\utf8-bom.docx" /> - </ItemGroup> - <ItemGroup> - <ProjectReference Include="..\Mammoth\Mammoth.csproj"> - <Project>{51C5CBD6-8809-4D5E-BABE-1787A16F5ED8}</Project> - <Name>Mammoth</Name> - </ProjectReference> - </ItemGroup> -</Project>
\ No newline at end of file diff --git a/dotnet/Mammoth.Tests/Properties/AssemblyInfo.cs b/dotnet/Mammoth.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 79596a3..0000000 --- a/dotnet/Mammoth.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. - -[assembly: AssemblyTitle ("Mammoth.Tests")] -[assembly: AssemblyDescription ("")] -[assembly: AssemblyConfiguration ("")] -[assembly: AssemblyCompany ("")] -[assembly: AssemblyProduct ("")] -[assembly: AssemblyCopyright ("Michael Williamson")] -[assembly: AssemblyTrademark ("")] -[assembly: AssemblyCulture ("")] - -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. - -[assembly: AssemblyVersion ("1.0.*")] - -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. - -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - diff --git a/dotnet/Mammoth.Tests/TestData b/dotnet/Mammoth.Tests/TestData deleted file mode 120000 index f8f6221..0000000 --- a/dotnet/Mammoth.Tests/TestData +++ /dev/null @@ -1 +0,0 @@ -../../src/test/resources/test-data
\ No newline at end of file diff --git a/dotnet/Mammoth.Tests/packages.config b/dotnet/Mammoth.Tests/packages.config deleted file mode 100644 index 69a4ec4..0000000 --- a/dotnet/Mammoth.Tests/packages.config +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<packages> - <package id="xunit" version="2.1.0" targetFramework="net45" /> - <package id="xunit.abstractions" version="2.0.0" targetFramework="net45" /> - <package id="xunit.assert" version="2.1.0" targetFramework="net45" /> - <package id="xunit.core" version="2.1.0" targetFramework="net45" /> - <package id="xunit.extensibility.core" version="2.1.0" targetFramework="net45" /> - <package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net45" /> -</packages>
\ No newline at end of file diff --git a/dotnet/Mammoth.sln b/dotnet/Mammoth.sln deleted file mode 100644 index 630467d..0000000 --- a/dotnet/Mammoth.sln +++ /dev/null @@ -1,29 +0,0 @@ -
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2012
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mammoth", "Mammoth\Mammoth.csproj", "{51C5CBD6-8809-4D5E-BABE-1787A16F5ED8}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mammoth.Cli", "Mammoth.Cli\Mammoth.Cli.csproj", "{20602E78-EEBD-407B-B8C3-EDB6254BD663}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mammoth.Tests", "Mammoth.Tests\Mammoth.Tests.csproj", "{E9C3EA8B-FF3B-4E3E-8137-1510465200B5}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {20602E78-EEBD-407B-B8C3-EDB6254BD663}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {20602E78-EEBD-407B-B8C3-EDB6254BD663}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {20602E78-EEBD-407B-B8C3-EDB6254BD663}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {20602E78-EEBD-407B-B8C3-EDB6254BD663}.Release|Any CPU.Build.0 = Release|Any CPU
- {51C5CBD6-8809-4D5E-BABE-1787A16F5ED8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {51C5CBD6-8809-4D5E-BABE-1787A16F5ED8}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {51C5CBD6-8809-4D5E-BABE-1787A16F5ED8}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {51C5CBD6-8809-4D5E-BABE-1787A16F5ED8}.Release|Any CPU.Build.0 = Release|Any CPU
- {E9C3EA8B-FF3B-4E3E-8137-1510465200B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E9C3EA8B-FF3B-4E3E-8137-1510465200B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E9C3EA8B-FF3B-4E3E-8137-1510465200B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E9C3EA8B-FF3B-4E3E-8137-1510465200B5}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
-EndGlobal
diff --git a/dotnet/Mammoth/Couscous/Adapters.cs b/dotnet/Mammoth/Couscous/Adapters.cs deleted file mode 100644 index c45f35b..0000000 --- a/dotnet/Mammoth/Couscous/Adapters.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Mammoth.Couscous.java.lang; -using Mammoth.Couscous.java.util; -using Mammoth.Couscous.java.io; - -namespace Mammoth.Couscous { - internal static class FromJava { - internal static IEnumerable<T> IterableToEnumerable<T>(Iterable<T> iterable) { - Iterator<T> iterator = iterable.iterator(); - while (iterator.hasNext()) { - yield return iterator.next(); - } - } - - internal static IDictionary<TKey, TValue> MapToDictionary<TKey, TValue>(Map<TKey, TValue> map) { - return map.AsDictionary(); - } - } - - internal static class ToJava { - internal static Iterable<T> EnumerableToIterable<T>(IEnumerable<T> enumerator) { - return new IterableWrapper<T>(enumerator); - } - - private class IterableWrapper<T> : Iterable<T> { - private readonly IEnumerable<T> _enumerable; - - internal IterableWrapper(IEnumerable<T> enumerable) { - _enumerable = enumerable; - } - - public Iterator<T> iterator() { - return EnumeratorToIterator(_enumerable.GetEnumerator()); - } - } - - internal static Iterator<T> EnumeratorToIterator<T>(IEnumerator<T> enumerator) { - return new EnumeratorToIteratorAdapter<T>(enumerator); - } - - private class EnumeratorToIteratorAdapter<T> : Iterator<T> { - private readonly IEnumerator<T> _enumerator; - private bool _ready; - private bool _hasNext; - - internal EnumeratorToIteratorAdapter(IEnumerator<T> enumerator) { - _enumerator = enumerator; - _ready = false; - } - - public bool hasNext() { - MakeReady(); - return _hasNext; - } - - public T next() { - MakeReady(); - if (_hasNext) { - _ready = false; - return _enumerator.Current; - } else { - throw new NoSuchElementException(); - } - } - - private void MakeReady() { - if (!_ready) { - MoveNext(); - } - } - - private void MoveNext() { - _hasNext = _enumerator.MoveNext(); - _ready = true; - } - } - - internal static Map<TKey, TValue> DictionaryToMap<TKey, TValue>(IDictionary<TKey, TValue> dictionary) { - return new HashMap<TKey, TValue>(dictionary); - } - - internal static java.util.List<T> ListToList<T>(IList<T> list) { - return new ArrayList<T>(list); - } - - internal static java.io.InputStream StreamToInputStream(System.IO.Stream stream) { - return new StreamToInputStreamAdapter(stream); - } - - private class StreamToInputStreamAdapter : InputStream { - public System.IO.Stream Stream { get; } - - internal StreamToInputStreamAdapter(System.IO.Stream stream) { - Stream = stream; - } - } - } -} diff --git a/dotnet/Mammoth/Couscous/HorribleHacks.cs b/dotnet/Mammoth/Couscous/HorribleHacks.cs deleted file mode 100644 index c97dc0a..0000000 --- a/dotnet/Mammoth/Couscous/HorribleHacks.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Mammoth.Couscous.java.util; -using Mammoth.Couscous.org.zwobble.mammoth.@internal.documents; -using Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing; -using System.Linq; - -namespace Mammoth.Couscous { - internal static class HorribleHacks { - internal static bool equals(this char first, int second) { - return first == second; - } - - internal static bool equals(this Optional<string> first, Optional<string> second) { - return (!first.isPresent() && !second.isPresent()) || (first.isPresent() && second.isPresent() && first.get() == second.get()); - } - - internal static bool equals(this Map<string, string> firstMap, Map<string, string> secondMap) { - var first = FromJava.MapToDictionary(firstMap); - var second = FromJava.MapToDictionary(secondMap); - return first.Count == second.Count && first.All(item => second.ContainsKey(item.Key) && second[item.Key] == item.Value); - } - - internal static bool equals(this NoteType first, NoteType second) { - return first == second; - } - - internal static bool equals(this TokenType first, TokenType second) { - return first == second; - } - - internal static string getMessage(this System.Exception exception) { - return exception.Message; - } - } -} diff --git a/dotnet/Mammoth/Couscous/IterableExtensions.cs b/dotnet/Mammoth/Couscous/IterableExtensions.cs deleted file mode 100644 index bac0b43..0000000 --- a/dotnet/Mammoth/Couscous/IterableExtensions.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Mammoth.Couscous.java.lang; -using Mammoth.Couscous.java.util.function; - -namespace Mammoth.Couscous { - internal static class IterableExtensions { - public static void forEach<T>(this Iterable<T> iterable, Consumer<T> consumer) { - var iterator = iterable.iterator(); - while (iterator.hasNext()) { - consumer.accept(iterator.next()); - } - } - } -} diff --git a/dotnet/Mammoth/Couscous/JavaStringExtensions.cs b/dotnet/Mammoth/Couscous/JavaStringExtensions.cs deleted file mode 100644 index bf4e73f..0000000 --- a/dotnet/Mammoth/Couscous/JavaStringExtensions.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; - -namespace Mammoth.Couscous { - internal static class JavaStringExtensions { - internal static char charAt(this string value, int index) { - return value[index]; - } - - internal static bool equalsIgnoreCase(this string first, string second) { - return first.Equals(second, StringComparison.InvariantCultureIgnoreCase); - } - - internal static string replace(this string original, string search, string replacement) { - return original.Replace(search, replacement); - } - - internal static bool isEmpty(this string value) { - return value.Length == 0; - } - - internal static bool startsWith(this string value, string prefix) { - return value.StartsWith(prefix); - } - - internal static string trim(this string value) { - return value.Trim(); - } - - internal static string[] split(this string value, string separator) { - return System.Text.RegularExpressions.Regex.Split(value, separator); - } - } -} diff --git a/dotnet/Mammoth/Couscous/java/io/Closeable.cs b/dotnet/Mammoth/Couscous/java/io/Closeable.cs deleted file mode 100644 index 9dc10c5..0000000 --- a/dotnet/Mammoth/Couscous/java/io/Closeable.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace Mammoth.Couscous.java.io { - internal interface Closeable { - void close(); - } -} - diff --git a/dotnet/Mammoth/Couscous/java/io/File.cs b/dotnet/Mammoth/Couscous/java/io/File.cs deleted file mode 100644 index abff40a..0000000 --- a/dotnet/Mammoth/Couscous/java/io/File.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Mammoth.Couscous.java.nio.file; - -namespace Mammoth.Couscous.java.io { - internal class File { - internal string Path { get; } - - internal File(string path) { - Path = path; - } - - internal Path toPath() { - return new Path(Path); - } - } -} diff --git a/dotnet/Mammoth/Couscous/java/io/IOException.cs b/dotnet/Mammoth/Couscous/java/io/IOException.cs deleted file mode 100644 index f7b708e..0000000 --- a/dotnet/Mammoth/Couscous/java/io/IOException.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; - -namespace Mammoth.Couscous.java.io -{ - internal class IOException : Exception { - internal IOException() : base() { - } - - internal IOException(string message) : base(message) { - } - - internal string getMessage() { - return Message; - } - } -} - diff --git a/dotnet/Mammoth/Couscous/java/io/InputStream.cs b/dotnet/Mammoth/Couscous/java/io/InputStream.cs deleted file mode 100644 index b474bb8..0000000 --- a/dotnet/Mammoth/Couscous/java/io/InputStream.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Mammoth.Couscous.java.io { - internal interface InputStream { - System.IO.Stream Stream { get; } - } -} diff --git a/dotnet/Mammoth/Couscous/java/lang/IllegalArgumentException.cs b/dotnet/Mammoth/Couscous/java/lang/IllegalArgumentException.cs deleted file mode 100644 index 57ef62b..0000000 --- a/dotnet/Mammoth/Couscous/java/lang/IllegalArgumentException.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace Mammoth.Couscous.java.lang { - internal class IllegalArgumentException : RuntimeException { - internal IllegalArgumentException(string message) : base(message) { - } - } -} diff --git a/dotnet/Mammoth/Couscous/java/lang/IndexOutOfBoundsException.cs b/dotnet/Mammoth/Couscous/java/lang/IndexOutOfBoundsException.cs deleted file mode 100644 index c56c7c1..0000000 --- a/dotnet/Mammoth/Couscous/java/lang/IndexOutOfBoundsException.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System; - -namespace Mammoth.Couscous.java.lang { - internal class IndexOutOfBoundsException : RuntimeException { - } -} - diff --git a/dotnet/Mammoth/Couscous/java/lang/Iterable.cs b/dotnet/Mammoth/Couscous/java/lang/Iterable.cs deleted file mode 100644 index d050b06..0000000 --- a/dotnet/Mammoth/Couscous/java/lang/Iterable.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Mammoth.Couscous.java.lang { - internal interface Iterable<out T> { - java.util.Iterator<T> iterator(); - } -} diff --git a/dotnet/Mammoth/Couscous/java/lang/RuntimeException.cs b/dotnet/Mammoth/Couscous/java/lang/RuntimeException.cs deleted file mode 100644 index cf882aa..0000000 --- a/dotnet/Mammoth/Couscous/java/lang/RuntimeException.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; - -namespace Mammoth.Couscous.java.lang -{ - internal class RuntimeException : Exception { - internal RuntimeException() : base() { - } - - internal RuntimeException(string message) : base(message) { - } - } -} - diff --git a/dotnet/Mammoth/Couscous/java/lang/String.cs b/dotnet/Mammoth/Couscous/java/lang/String.cs deleted file mode 100644 index bd0838d..0000000 --- a/dotnet/Mammoth/Couscous/java/lang/String.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Mammoth.Couscous.java.lang { - internal partial class String { - internal static string join(string separator, Iterable<string> values) { - return string.Join(separator, FromJava.IterableToEnumerable(values)); - } - } -} diff --git a/dotnet/Mammoth/Couscous/java/lang/StringBuilder.cs b/dotnet/Mammoth/Couscous/java/lang/StringBuilder.cs deleted file mode 100644 index c894936..0000000 --- a/dotnet/Mammoth/Couscous/java/lang/StringBuilder.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Mammoth.Couscous.java.lang { - internal class StringBuilder { - private readonly System.Text.StringBuilder _builder = new System.Text.StringBuilder(); - - internal StringBuilder append(string value) { - _builder.Append(value); - return this; - } - - internal string toString() { - return _builder.ToString(); - } - } -} diff --git a/dotnet/Mammoth/Couscous/java/lang/UnsupportedOperationException.cs b/dotnet/Mammoth/Couscous/java/lang/UnsupportedOperationException.cs deleted file mode 100644 index da86874..0000000 --- a/dotnet/Mammoth/Couscous/java/lang/UnsupportedOperationException.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System; - -namespace Mammoth.Couscous.java.lang { - internal class UnsupportedOperationException : RuntimeException { - } -} - diff --git a/dotnet/Mammoth/Couscous/java/math/BigInteger.cs b/dotnet/Mammoth/Couscous/java/math/BigInteger.cs deleted file mode 100644 index 40ac3d3..0000000 --- a/dotnet/Mammoth/Couscous/java/math/BigInteger.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace Mammoth.Couscous.java.math { - internal class BigInteger { - internal static readonly BigInteger _ONE = new BigInteger(1); - - // TOOD: use proper BigInteger - private readonly long _value; - - internal BigInteger(string value) { - _value = long.Parse(value); - } - - internal BigInteger(long value) { - _value = value; - } - - internal BigInteger subtract(BigInteger other) { - return new BigInteger(_value - other._value); - } - - internal string toString() { - return _value.ToString(); - } - } -} diff --git a/dotnet/Mammoth/Couscous/java/net/URI.cs b/dotnet/Mammoth/Couscous/java/net/URI.cs deleted file mode 100644 index 818d694..0000000 --- a/dotnet/Mammoth/Couscous/java/net/URI.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; - -namespace Mammoth.Couscous.java.net { - internal class URI { - private readonly Uri _uri; - - internal URI(string uri) { - try { - _uri = new Uri(uri, UriKind.RelativeOrAbsolute); - } catch (UriFormatException exception) { - throw new URISyntaxException(exception.Message); - } - } - - internal URI(Uri uri) { - _uri = uri; - } - - internal bool isAbsolute() { - return _uri.IsAbsoluteUri; - } - - internal URL toURL() { - return new URL(_uri.ToString()); - } - - internal URI resolve(string relativeUri) { - if (new URI(relativeUri).isAbsolute()) { - return new URI(relativeUri); - } else if (_uri.IsAbsoluteUri) { - return new URI(new Uri(_uri, relativeUri)); - } else { - var path = _uri.ToString(); - var lastSlashIndex = path.LastIndexOf("/"); - var basePath = lastSlashIndex == -1 - ? "." - : path.Substring(0, lastSlashIndex + 1); - return new URI(basePath + relativeUri); - } - } - } -} diff --git a/dotnet/Mammoth/Couscous/java/net/URISyntaxException.cs b/dotnet/Mammoth/Couscous/java/net/URISyntaxException.cs deleted file mode 100644 index 7380ff6..0000000 --- a/dotnet/Mammoth/Couscous/java/net/URISyntaxException.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Mammoth.Couscous.java.net { - internal class URISyntaxException : System.Exception { - internal URISyntaxException(string message) : base(message) { - } - } -} diff --git a/dotnet/Mammoth/Couscous/java/net/URL.cs b/dotnet/Mammoth/Couscous/java/net/URL.cs deleted file mode 100644 index 88479e8..0000000 --- a/dotnet/Mammoth/Couscous/java/net/URL.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Net; -using Mammoth.Couscous.java.io; - -namespace Mammoth.Couscous.java.net { - internal class URL { - private readonly string _url; - - internal URL(string url) { - _url = url; - } - - internal InputStream openStream() { - try { - var response = WebRequest.Create(_url).GetResponse(); - try { - return ToJava.StreamToInputStream(response.GetResponseStream()); - } catch { - response.Close(); - throw; - } - } catch (System.UriFormatException) { - return ToJava.StreamToInputStream(System.IO.File.OpenRead(_url)); - } catch (System.Net.WebException exception) { - throw new java.io.IOException(exception.Message); - } - } - } -} diff --git a/dotnet/Mammoth/Couscous/java/nio/file/Path.cs b/dotnet/Mammoth/Couscous/java/nio/file/Path.cs deleted file mode 100644 index 030f757..0000000 --- a/dotnet/Mammoth/Couscous/java/nio/file/Path.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Mammoth.Couscous.java.net; - -namespace Mammoth.Couscous.java.nio.file { - internal class Path { - private readonly string _path; - - internal Path(string path) { - _path = path; - } - - internal URI toUri() { - return new URI(_path); - } - } -} - diff --git a/dotnet/Mammoth/Couscous/java/util/ArrayDeque.cs b/dotnet/Mammoth/Couscous/java/util/ArrayDeque.cs deleted file mode 100644 index df5447d..0000000 --- a/dotnet/Mammoth/Couscous/java/util/ArrayDeque.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace Mammoth.Couscous.java.util { - internal class ArrayDeque<T> : Deque<T> { - private readonly System.Collections.Generic.IList<T> _list = new System.Collections.Generic.List<T>(); - - public int size() { - return _list.Count; - } - - public T getFirst() { - if (_list.Count > 0) { - return _list[0]; - } else { - throw new NoSuchElementException(); - } - } - - public T getLast() { - if (_list.Count > 0) { - return _list[_list.Count - 1]; - } else { - throw new NoSuchElementException(); - } - } - - public void add(T value) { - _list.Add(value); - } - - public T removeLast() { - T value = getLast(); - _list.RemoveAt(_list.Count - 1); - return value; - } - } -} diff --git a/dotnet/Mammoth/Couscous/java/util/ArrayList.cs b/dotnet/Mammoth/Couscous/java/util/ArrayList.cs deleted file mode 100644 index 4414123..0000000 --- a/dotnet/Mammoth/Couscous/java/util/ArrayList.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Mammoth.Couscous.java.lang; -using Mammoth.Couscous.java.util; - -namespace Mammoth.Couscous.java.util { - internal class ArrayList<T> : List<T> { - private readonly System.Collections.Generic.IList<T> _list; - - internal ArrayList() : this(new System.Collections.Generic.List<T>()) { - } - - internal ArrayList(System.Collections.Generic.IList<T> list) { - _list = list; - } - - public Iterator<T> iterator() { - return ToJava.EnumeratorToIterator(_list.GetEnumerator()); - } - - public bool isEmpty() { - return _list.Count == 0; - } - - public int size() { - return _list.Count; - } - - public bool contains(object value) { - return value is T && _list.Contains((T) value); - } - - public T get(int index) { - if (index < 0 || index >= _list.Count) { - throw new IndexOutOfBoundsException(); - } else { - return _list[index]; - } - } - - public void add(T value) { - _list.Add(value); - } - - public T remove(int index) { - T value = _list[index]; - _list.RemoveAt(index); - return value; - } - } -} diff --git a/dotnet/Mammoth/Couscous/java/util/Arrays.cs b/dotnet/Mammoth/Couscous/java/util/Arrays.cs deleted file mode 100644 index 093db83..0000000 --- a/dotnet/Mammoth/Couscous/java/util/Arrays.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Mammoth.Couscous.java.util { - internal static class Arrays { - internal static List<T> asList<T>(T[] elements) { - return ToJava.ListToList(elements); - } - } -} diff --git a/dotnet/Mammoth/Couscous/java/util/Collection.cs b/dotnet/Mammoth/Couscous/java/util/Collection.cs deleted file mode 100644 index a0cae74..0000000 --- a/dotnet/Mammoth/Couscous/java/util/Collection.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Mammoth.Couscous.java.lang; - -namespace Mammoth.Couscous.java.util { - interface Collection<T> : Iterable<T> { - bool isEmpty(); - int size(); - bool contains(object value); - - void add(T value); - } -} diff --git a/dotnet/Mammoth/Couscous/java/util/Deque.cs b/dotnet/Mammoth/Couscous/java/util/Deque.cs deleted file mode 100644 index c954fce..0000000 --- a/dotnet/Mammoth/Couscous/java/util/Deque.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Mammoth.Couscous.java.util { - internal interface Deque<T> { - int size(); - T getFirst(); - T getLast(); - - void add(T value); - T removeLast(); - } -} diff --git a/dotnet/Mammoth/Couscous/java/util/HashMap.cs b/dotnet/Mammoth/Couscous/java/util/HashMap.cs deleted file mode 100644 index 38e516e..0000000 --- a/dotnet/Mammoth/Couscous/java/util/HashMap.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Mammoth.Couscous.org.zwobble.mammoth.@internal.util; -using Mammoth.Couscous.java.lang; - -namespace Mammoth.Couscous.java.util { - internal class HashMap<TKey, TValue> : Map<TKey, TValue> { - private readonly IDictionary<TKey, TValue> _dictionary; - - internal HashMap() : this(new Dictionary<TKey, TValue>()) { - } - - internal HashMap(IDictionary<TKey, TValue> dictionary) { - _dictionary = dictionary; - } - - public void put(TKey key, TValue value) { - _dictionary[key] = value; - } - - public bool containsKey(TKey key) { - return _dictionary.ContainsKey(key); - } - - public Set<Map__Entry<TKey, TValue>> entrySet() { - return new EntrySet(_dictionary); - } - - public Optional<TValue> _lookup(TKey key) { - if (_dictionary.ContainsKey(key)) { - return new Some<TValue>(_dictionary[key]); - } else { - return new None<TValue>(); - } - } - - public IDictionary<TKey, TValue> AsDictionary() { - return _dictionary; - } - - internal class EntrySet : Set<Map__Entry<TKey, TValue>> { - private readonly IDictionary<TKey, TValue> _dictionary; - - internal EntrySet(IDictionary<TKey, TValue> dictionary) { - _dictionary = dictionary; - } - - public Iterator<Map__Entry<TKey, TValue>> iterator() { - return ToJava.EnumeratorToIterator(_dictionary.Select(entry => Maps.entry(entry.Key, entry.Value)).GetEnumerator()); - } - - public bool isEmpty() { - return _dictionary.Count == 0; - } - - public int size() { - return _dictionary.Count; - } - - public bool contains(object value) { - return value is TKey && _dictionary.ContainsKey((TKey) value); - } - - public void add(Map__Entry<TKey, TValue> value) { - throw new UnsupportedOperationException(); - } - } - } -} diff --git a/dotnet/Mammoth/Couscous/java/util/HashSet.cs b/dotnet/Mammoth/Couscous/java/util/HashSet.cs deleted file mode 100644 index ac10075..0000000 --- a/dotnet/Mammoth/Couscous/java/util/HashSet.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Collections.Generic; - -namespace Mammoth.Couscous.java.util { - internal class HashSet<T> : Set<T> { - private readonly ISet<T> _set; - - internal HashSet() : this(new System.Collections.Generic.HashSet<T>()) { - } - - internal HashSet(ISet<T> set) { - _set = set; - } - - public Iterator<T> iterator() { - return ToJava.EnumeratorToIterator(_set.GetEnumerator()); - } - - public bool isEmpty() { - return _set.Count == 0; - } - - public int size() { - return _set.Count; - } - - public bool contains(object value) { - return value is T && _set.Contains((T)value); - } - - public void add(T value) { - _set.Add(value); - } - } -} diff --git a/dotnet/Mammoth/Couscous/java/util/Iterator.cs b/dotnet/Mammoth/Couscous/java/util/Iterator.cs deleted file mode 100644 index 0ae48b2..0000000 --- a/dotnet/Mammoth/Couscous/java/util/Iterator.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Mammoth.Couscous.java.util { - internal interface Iterator<out T> { - bool hasNext(); - T next(); - } -} diff --git a/dotnet/Mammoth/Couscous/java/util/List.cs b/dotnet/Mammoth/Couscous/java/util/List.cs deleted file mode 100644 index 45a9299..0000000 --- a/dotnet/Mammoth/Couscous/java/util/List.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Mammoth.Couscous.java.lang; - -namespace Mammoth.Couscous.java.util { - interface List<T> : Collection<T> { - T get(int index); - T remove(int index); - } -} diff --git a/dotnet/Mammoth/Couscous/java/util/Map.cs b/dotnet/Mammoth/Couscous/java/util/Map.cs deleted file mode 100644 index 5405c77..0000000 --- a/dotnet/Mammoth/Couscous/java/util/Map.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Mammoth.Couscous.java.util { - internal interface Map<K, V> { - void put(K key, V value); - bool containsKey(K key); - Set<Map__Entry<K, V>> entrySet(); - - Optional<V> _lookup(K key); - System.Collections.Generic.IDictionary<K, V> AsDictionary(); - } - - internal interface Map__Entry<K, V> { - K getKey(); - V getValue(); - } -} diff --git a/dotnet/Mammoth/Couscous/java/util/NoSuchElementException.cs b/dotnet/Mammoth/Couscous/java/util/NoSuchElementException.cs deleted file mode 100644 index 4a1ee9c..0000000 --- a/dotnet/Mammoth/Couscous/java/util/NoSuchElementException.cs +++ /dev/null @@ -1,6 +0,0 @@ -using Mammoth.Couscous.java.lang; - -namespace Mammoth.Couscous.java.util { - internal class NoSuchElementException : RuntimeException { - } -} diff --git a/dotnet/Mammoth/Couscous/java/util/Optional.cs b/dotnet/Mammoth/Couscous/java/util/Optional.cs deleted file mode 100644 index f295688..0000000 --- a/dotnet/Mammoth/Couscous/java/util/Optional.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using Mammoth.Couscous.java.util.function; - -namespace Mammoth.Couscous.java.util -{ - internal interface Optional<T> - { - bool isPresent(); - Optional<U> map<U>(Function<T, U> function); - Optional<U> flatMap<U>(Function<T, Optional<U>> function); - T orElse(T value); - T orElseGet(Supplier<T> supplier); - T orElseThrow<TException>(Supplier<TException> exceptionSupplier) where TException : Exception; - T get(); - void ifPresent(Consumer<T> consumer); - } - - internal class None<T> : Optional<T> { - public bool isPresent() { - return false; - } - - public Optional<U> map<U>(Function<T, U> function) { - return new None<U>(); - } - - public Optional<U> flatMap<U>(Function<T, Optional<U>> function) { - return new None<U>(); - } - - public T orElse(T value) { - return value; - } - - public T orElseGet(Supplier<T> supplier) { - return supplier.get(); - } - - public T orElseThrow<TException>(Supplier<TException> exceptionSupplier) where TException : Exception { - throw exceptionSupplier.get(); - } - - public T get() { - throw new NoSuchElementException(); - } - - public void ifPresent(Consumer<T> consumer) { - } - } - - internal class Some<T> : Optional<T> { - private readonly T _value; - - internal Some(T value) { - _value = value; - } - - public bool isPresent() { - return true; - } - - public Optional<U> map<U>(Function<T, U> function) { - return new Some<U>(function.apply(_value)); - } - - public Optional<U> flatMap<U>(Function<T, Optional<U>> function) { - return function.apply(_value); - } - - public T orElse(T value) { - return _value; - } - - public T orElseGet(Supplier<T> supplier) { - return _value; - } - - public T orElseThrow<TException>(Supplier<TException> exceptionSupplier) where TException : Exception { - return _value; - } - - public T get() { - return _value; - } - - public void ifPresent(Consumer<T> consumer) { - consumer.accept(_value); - } - } - - internal static class Optional - { - internal static Optional<T> empty<T>() - { - return new None<T>(); - } - - internal static Optional<T> of<T>(T value) - { - return new Some<T> (value); - } - } -} diff --git a/dotnet/Mammoth/Couscous/java/util/Set.cs b/dotnet/Mammoth/Couscous/java/util/Set.cs deleted file mode 100644 index 34a23ac..0000000 --- a/dotnet/Mammoth/Couscous/java/util/Set.cs +++ /dev/null @@ -1,6 +0,0 @@ -using Mammoth.Couscous.java.lang; - -namespace Mammoth.Couscous.java.util { - internal interface Set<T> : Collection<T> { - } -} diff --git a/dotnet/Mammoth/Couscous/java/util/function/BiConsumer.cs b/dotnet/Mammoth/Couscous/java/util/function/BiConsumer.cs deleted file mode 100644 index 9479a78..0000000 --- a/dotnet/Mammoth/Couscous/java/util/function/BiConsumer.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Mammoth.Couscous.java.util.function { - internal interface BiConsumer<T1, T2> { - void accept(T1 first, T2 second); - } -} diff --git a/dotnet/Mammoth/Couscous/java/util/function/BiFunction.cs b/dotnet/Mammoth/Couscous/java/util/function/BiFunction.cs deleted file mode 100644 index 050f85f..0000000 --- a/dotnet/Mammoth/Couscous/java/util/function/BiFunction.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Mammoth.Couscous.java.util.function -{ - internal interface BiFunction<T1, T2, U> { - U apply(T1 first, T2 second); - } -}
\ No newline at end of file diff --git a/dotnet/Mammoth/Couscous/java/util/function/BiPredicate.cs b/dotnet/Mammoth/Couscous/java/util/function/BiPredicate.cs deleted file mode 100644 index 0419a6e..0000000 --- a/dotnet/Mammoth/Couscous/java/util/function/BiPredicate.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Mammoth.Couscous.java.util.function -{ - internal interface BiPredicate<T, U> { - bool test(T first, U second); - } -}
\ No newline at end of file diff --git a/dotnet/Mammoth/Couscous/java/util/function/Consumer.cs b/dotnet/Mammoth/Couscous/java/util/function/Consumer.cs deleted file mode 100644 index f80d426..0000000 --- a/dotnet/Mammoth/Couscous/java/util/function/Consumer.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Mammoth.Couscous.java.util.function { - internal interface Consumer<T> { - void accept(T value); - } -}
\ No newline at end of file diff --git a/dotnet/Mammoth/Couscous/java/util/function/Function.cs b/dotnet/Mammoth/Couscous/java/util/function/Function.cs deleted file mode 100644 index 2b4d3ae..0000000 --- a/dotnet/Mammoth/Couscous/java/util/function/Function.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Mammoth.Couscous.java.util.function -{ - internal interface Function<T, U> { - U apply(T arg); - } -}
\ No newline at end of file diff --git a/dotnet/Mammoth/Couscous/java/util/function/Predicate.cs b/dotnet/Mammoth/Couscous/java/util/function/Predicate.cs deleted file mode 100644 index 2023309..0000000 --- a/dotnet/Mammoth/Couscous/java/util/function/Predicate.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Mammoth.Couscous.java.util.function { - internal interface Predicate<T> { - bool test(T value); - } -}
\ No newline at end of file diff --git a/dotnet/Mammoth/Couscous/java/util/function/Supplier.cs b/dotnet/Mammoth/Couscous/java/util/function/Supplier.cs deleted file mode 100644 index eab3ffb..0000000 --- a/dotnet/Mammoth/Couscous/java/util/function/Supplier.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Mammoth.Couscous.java.util.function { - internal interface Supplier<T> { - T get(); - } -}
\ No newline at end of file diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/docx/InMemoryDocxFile.cs b/dotnet/Mammoth/Couscous/mammoth/internal/docx/InMemoryDocxFile.cs deleted file mode 100644 index 9b7efd0..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/docx/InMemoryDocxFile.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Mammoth.Couscous.java.io; -using Mammoth.Couscous.java.util; -using System.IO; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { - internal class InMemoryDocxFile { - internal static DocxFile fromStream(InputStream stream) { - var memoryStream = new MemoryStream(); - stream.Stream.CopyTo(memoryStream); - return new ZippedDocxFile(memoryStream); - } - } -} diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/docx/ZippedDocxFile.cs b/dotnet/Mammoth/Couscous/mammoth/internal/docx/ZippedDocxFile.cs deleted file mode 100644 index cf39e63..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/docx/ZippedDocxFile.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.IO.Compression; -using Mammoth.Couscous.java.io; -using Mammoth.Couscous.java.util; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { - internal class ZippedDocxFile : DocxFile { - private readonly ZipArchive _zipFile; - - internal ZippedDocxFile(File file) { - _zipFile = ZipFile.OpenRead(file.Path); - } - - internal ZippedDocxFile(System.IO.Stream stream) { - _zipFile = new ZipArchive(stream); - } - - public Optional<InputStream> tryGetInputStream(string name) { - var entry = _zipFile.GetEntry(name); - if (entry == null) { - return Optional.empty<InputStream>(); - } else { - return Optional.of(ToJava.StreamToInputStream(entry.Open())); - } - } - - public void close() { - _zipFile.Dispose(); - } - } -} diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/LineParseException.cs b/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/LineParseException.cs deleted file mode 100644 index 6ca9381..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/LineParseException.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Mammoth.Couscous.java.lang; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing { - internal class LineParseException : RuntimeException { - private readonly Token _token; - - internal LineParseException(Token token, string message) : base(message) { - _token = token; - } - - internal Token getToken() { - return _token; - } - } -} diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/ParseException.cs b/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/ParseException.cs deleted file mode 100644 index 73f349c..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/ParseException.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Mammoth.Couscous.java.lang; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing { - internal class ParseException : RuntimeException { - internal ParseException(string message) : base(message) { - } - } -} diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/StyleMapParser.cs b/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/StyleMapParser.cs deleted file mode 100644 index 53315f3..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/StyleMapParser.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Mammoth.Couscous.java.util; -using Mammoth.Couscous.org.zwobble.mammoth.@internal.styles; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing { - internal static class StyleMapParser { - internal static StyleMap parseStyleMappings(List<string> mappings) { - return DefaultStyleMap(); - } - - internal static StyleMap parse(string styleMap) { - return DefaultStyleMap(); - } - - private static StyleMap DefaultStyleMap() { - return StyleMap.builder() - - .mapParagraph(ParagraphMatcher.styleName("Normal"), HtmlPath.element("p")) - - .build(); - } - } -} diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/util/Base64Encoding.cs b/dotnet/Mammoth/Couscous/mammoth/internal/util/Base64Encoding.cs deleted file mode 100644 index 24d2f9c..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/util/Base64Encoding.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Mammoth.Couscous.java.lang; -using Mammoth.Couscous.java.io; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util { - internal static class Base64Encoding { - internal static string streamToBase64(SupplierWithException<InputStream, IOException> streamSupplier) { - using (var stream = streamSupplier.get().Stream) { - return streamToBase64(stream); - } - } - - internal static string streamToBase64(System.IO.Stream stream) { - var memoryStream = new System.IO.MemoryStream(); - stream.CopyTo(memoryStream); - return System.Convert.ToBase64String(memoryStream.ToArray()); - } - } -} diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/util/Casts.cs b/dotnet/Mammoth/Couscous/mammoth/internal/util/Casts.cs deleted file mode 100644 index c342e20..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/util/Casts.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Mammoth.Couscous.java.util; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util { - internal static class Casts { - internal static Optional<T> tryCast<T>(System.Type type, object value) { - if (value is T) { - return new Some<T>((T) value); - } else { - return new None<T>(); - } - } - } -} diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/util/Iterables.cs b/dotnet/Mammoth/Couscous/mammoth/internal/util/Iterables.cs deleted file mode 100644 index b1e1477..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/util/Iterables.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Mammoth.Couscous.java.lang; -using Mammoth.Couscous.java.util; -using Mammoth.Couscous.java.util.function; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util -{ - internal static class Iterables - { - internal static T getFirst<T>(Iterable<T> iterable, T defaultValue) { - var iterator = iterable.iterator(); - if (iterator.hasNext()) { - return iterator.next(); - } else { - return defaultValue; - } - } - - internal static Optional<T> tryFind<T>(Iterable<T> iterable, Predicate<T> predicate) { - var iterator = iterable.iterator(); - while (iterator.hasNext()) { - T value = iterator.next(); - if (predicate.test(value)) { - return new Some<T>(value); - } - } - return new None<T>(); - } - - internal static Iterable<T> lazyFilter<T>(Iterable<T> iterable, Predicate<T> predicate) { - var enumerable = FromJava.IterableToEnumerable(iterable).Where(predicate.test); - return ToJava.EnumerableToIterable(enumerable); - } - - internal static Iterable<U> lazyFilter<T, U>(Iterable<T> iterable, System.Type type) { - var enumerable = FromJava.IterableToEnumerable(iterable).OfType<U>(); - return ToJava.EnumerableToIterable(enumerable); - } - - internal static Iterable<U> lazyMap<T, U>(Iterable<T> iterable, Function<T, U> function) { - var enumerable = FromJava.IterableToEnumerable(iterable) - .Select(function.apply); - return ToJava.EnumerableToIterable(enumerable); - } - - internal static Iterable<U> lazyFlatMap<T, U>(Iterable<T> iterable, Function<T, Iterable<U>> function) { - var enumerable = FromJava.IterableToEnumerable(iterable) - .SelectMany(element => FromJava.IterableToEnumerable(function.apply(element))); - return ToJava.EnumerableToIterable(enumerable); - } - - internal static Iterable<T> lazyConcat<T>(Iterable<T> first, Iterable<T> second) { - var enumerable = FromJava.IterableToEnumerable(first) - .Concat(FromJava.IterableToEnumerable(second)); - return ToJava.EnumerableToIterable(enumerable); - } - } -} - diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/util/Lists.cs b/dotnet/Mammoth/Couscous/mammoth/internal/util/Lists.cs deleted file mode 100644 index b914a34..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/util/Lists.cs +++ /dev/null @@ -1,97 +0,0 @@ -using Mammoth.Couscous.java.lang; -using Mammoth.Couscous.java.util; -using Mammoth.Couscous.java.util.function; -using System.Linq; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util { - internal static class Lists { - internal static List<T> list<T>(params T[] values) { - return ToJava.ListToList(values); - } - - internal static List<T> toList<T>(Iterable<T> iterable) { - return ToJava.ListToList(FromJava.IterableToEnumerable(iterable).ToList()); - } - - internal static List<U> eagerMap<T, U>(Iterable<T> iterable, Function<T, U> function) { - var result = FromJava.IterableToEnumerable(iterable) - .Select(function.apply) - .ToList(); - return ToJava.ListToList(result); - } - - internal static List<U> eagerFlatMap<T, U>(Iterable<T> iterable, Function<T, Iterable<U>> function) { - var result = FromJava.IterableToEnumerable(iterable) - .SelectMany(element => FromJava.IterableToEnumerable(function.apply(element))) - .ToList(); - return ToJava.ListToList(result); - } - - internal static List<T> cons<T>(T head, Iterable<T> tail) { - var result = new T[] { head } - .Concat(FromJava.IterableToEnumerable(tail)) - .ToList(); - return ToJava.ListToList(result); - } - - internal static List<T> eagerConcat<T>(Iterable<T> first, Iterable<T> second) { - var result = FromJava.IterableToEnumerable(first) - .Concat(FromJava.IterableToEnumerable(second)) - .ToList(); - return ToJava.ListToList(result); - } - - internal static List<T> orderedBy<T, R>(Iterable<T> iterable, Function<T, R> getKey) { - var result = FromJava.IterableToEnumerable(iterable) - .OrderBy(getKey.apply) - .ToList(); - return ToJava.ListToList(result); - } - - internal static Optional<T> tryGetLast<T>(List<T> list) { - if (list.isEmpty()) { - return new None<T>(); - } else { - return new Some<T>(list.get(list.size() - 1)); - } - } - - internal static Iterable<T> reversed<T>(List<T> list) { - return new ReversedList<T>(list); - } - - private class ReversedList<T> : Iterable<T> { - private readonly List<T> _list; - - internal ReversedList(List<T> list) { - _list = list; - } - - public Iterator<T> iterator() { - return new ReverseIterator<T>(_list); - } - } - - private class ReverseIterator<T> : Iterator<T> { - private readonly List<T> _list; - private int _nextIndex; - - internal ReverseIterator(List<T> list) { - _list = list; - _nextIndex = _list.size() - 1; - } - - public bool hasNext() { - return _nextIndex >= 0; - } - - public T next() { - if (hasNext()) { - return _list.get(_nextIndex--); - } else { - throw new NoSuchElementException(); - } - } - } - } -} diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/util/Maps.cs b/dotnet/Mammoth/Couscous/mammoth/internal/util/Maps.cs deleted file mode 100644 index bee2dac..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/util/Maps.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System.Linq; -using Mammoth.Couscous.java.util; -using Mammoth.Couscous.java.lang; -using Mammoth.Couscous.java.util.function; -using Mammoth.Couscous; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util -{ - internal static class Maps - { - internal static Map<K, V> map<K, V>() { - return ToJava.DictionaryToMap(new System.Collections.Generic.Dictionary<K, V>()); - } - - internal static Map<K, V> map<K, V>(K key1, V value1) { - return ToJava.DictionaryToMap(new System.Collections.Generic.Dictionary<K, V> { - {key1, value1} - }); - } - - internal static Map<K, V> map<K, V>(K key1, V value1, K key2, V value2) { - return ToJava.DictionaryToMap(new System.Collections.Generic.Dictionary<K, V> { - {key1, value1}, - {key2, value2} - }); - } - - internal static Map<K, V> toMap<T, K, V>(Iterable<T> iterable, Function<T, Map__Entry<K, V>> function) { - var dictionary = FromJava.IterableToEnumerable(iterable) - .Select(function.apply) - .ToDictionary(entry => entry.getKey(), entry => entry.getValue()); - return ToJava.DictionaryToMap(dictionary); - - } - - internal static Map<K, T> toMapWithKey<T, K>(Iterable<T> iterable, Function<T, K> function) { - var dictionary = FromJava.IterableToEnumerable(iterable) - .ToDictionary(function.apply); - return ToJava.DictionaryToMap(dictionary); - } - - internal static Map<K, java.util.List<T>> toMultiMapWithKey<T, K>(Iterable<T> iterable, Function<T, K> function) { - var dictionary = FromJava.IterableToEnumerable(iterable) - .GroupBy(value => function.apply(value)) - .ToDictionary( - grouping => grouping.Key, - grouping => ToJava.ListToList(grouping.ToList())); - return ToJava.DictionaryToMap(dictionary); - } - - internal static Optional<V> lookup<K, V>(Map<K, V> map, K key) { - return map._lookup(key); - } - - internal static Map<K2, V> eagerMapKeys<K1, K2, V>(Map<K1, V> map, Function<K1, K2> function) { - var dictionary = FromJava.MapToDictionary(map) - .ToDictionary( - entry => function.apply(entry.Key), - entry => entry.Value); - return ToJava.DictionaryToMap(dictionary); - } - - internal static Map<K, V2> eagerMapValues<K, V1, V2>(Map<K, V1> map, Function<V1, V2> function) { - var dictionary = FromJava.MapToDictionary(map) - .ToDictionary( - entry => entry.Key, - entry => function.apply(entry.Value)); - return ToJava.DictionaryToMap(dictionary); - } - - internal static Map__Entry<K, V> entry<K, V>(K key, V value) { - return new Entry<K, V>(key, value); - } - - private class Entry<K, V> : Map__Entry<K, V> { - private readonly K _key; - private readonly V _value; - - internal Entry(K key, V value) { - this._key = key; - this._value = value; - } - - public K getKey() { - return _key; - } - - public V getValue() { - return _value; - } - } - - internal static Builder<K, V> builder<K, V>() { - return new Builder<K, V>(); - } - - internal class Builder<K, V> { - private readonly System.Collections.Generic.IDictionary<K, V> _values = new System.Collections.Generic.Dictionary<K, V>(); - - internal Builder<K, V> put(K key, V value) { - _values[key] = value; - return this; - } - - internal Map<K, V> build() { - return ToJava.DictionaryToMap(_values); - } - } - } -} diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/util/PassThroughException.cs b/dotnet/Mammoth/Couscous/mammoth/internal/util/PassThroughException.cs deleted file mode 100644 index 88597e3..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/util/PassThroughException.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Mammoth.Couscous.java.lang; -using Mammoth.Couscous.java.io; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util { - internal class PassThroughException : RuntimeException { - internal static T wrap<T>(SupplierWithException<T, IOException> supplier) { - try { - return supplier.get(); - } catch (IOException exception) { - throw new PassThroughException(exception); - } - } - - internal static T unwrap<T>(SupplierWithException<T, IOException> supplier) { - try { - return supplier.get(); - } catch (PassThroughException exception) { - throw exception._exception; - } - } - - private readonly IOException _exception; - - internal PassThroughException(IOException exception) { - _exception = exception; - } - } -} - diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/util/Paths.cs b/dotnet/Mammoth/Couscous/mammoth/internal/util/Paths.cs deleted file mode 100644 index ca876eb..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/util/Paths.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util { - internal static class Paths { - internal static string getExtension(string path) { - int dotIndex = path.LastIndexOf('.'); - return dotIndex == -1 ? "" : path.Substring(dotIndex + 1); - } - } -} diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/util/Sets.cs b/dotnet/Mammoth/Couscous/mammoth/internal/util/Sets.cs deleted file mode 100644 index bfce619..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/util/Sets.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Mammoth.Couscous.java.lang; -using Mammoth.Couscous.java.util; -using Mammoth.Couscous.java.nio.file; -using System; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util -{ - internal static class Sets { - internal static Set<T> set<T>(T[] values) { - return new HashSet<T>(new System.Collections.Generic.HashSet<T>(values)); - } - - internal static Set<T> toSet<T>(Iterable<T> iterable) { - return new HashSet<T>(new System.Collections.Generic.HashSet<T>(FromJava.IterableToEnumerable(iterable))); - } - } -} - diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/util/Strings.cs b/dotnet/Mammoth/Couscous/mammoth/internal/util/Strings.cs deleted file mode 100644 index 65f5e0b..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/util/Strings.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util { - internal static class Strings { - internal static string trimLeft(string value, int character) { - int index = 0; - while (index < value.Length && value[index] == character) { - index++; - } - return value.Substring(index); - } - - internal static bool isNullOrEmpty(string value) { - return string.IsNullOrEmpty(value); - } - } -} - diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/xml/parsing/SimpleSax.cs b/dotnet/Mammoth/Couscous/mammoth/internal/xml/parsing/SimpleSax.cs deleted file mode 100644 index 65f63c3..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/xml/parsing/SimpleSax.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Mammoth.Couscous.java.io; -using Mammoth.Couscous.java.util; -using System.Xml; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing { - internal static class SimpleSax { - internal static void parseStream(InputStream input, SimpleSaxHandler handler) { - var reader = XmlReader.Create(input.Stream); - while (reader.Read()) { - switch (reader.NodeType) { - case XmlNodeType.Element: - var name = new ElementName(reader.NamespaceURI, reader.LocalName); - var attributes = new HashMap<ElementName, string>(); - var isEmpty = reader.IsEmptyElement; - for (int attributeIndex = 0; attributeIndex < reader.AttributeCount; attributeIndex++) { - reader.MoveToAttribute(attributeIndex); - attributes.put(new ElementName(reader.NamespaceURI, reader.LocalName), reader.Value); - } - handler.startElement(name, attributes); - if (isEmpty) { - handler.endElement(); - } - break; - case XmlNodeType.CDATA: - case XmlNodeType.Text: - case XmlNodeType.SignificantWhitespace: - handler.characters(reader.Value); - break; - case XmlNodeType.EntityReference: - throw new System.NotImplementedException(); - case XmlNodeType.EndElement: - handler.endElement(); - break; - } - } - } - - internal static void parseString(string value, SimpleSaxHandler handler) { - throw new System.NotImplementedException(); - } - } -} diff --git a/dotnet/Mammoth/DocumentConverter.cs b/dotnet/Mammoth/DocumentConverter.cs deleted file mode 100644 index eb8c939..0000000 --- a/dotnet/Mammoth/DocumentConverter.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.IO; -using Mammoth.Couscous; -using Mammoth.Couscous.org.zwobble.mammoth.@internal; -using Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion; - -namespace Mammoth { - public class DocumentConverter { - private readonly DocumentToHtmlOptions options; - - public DocumentConverter() : this(DocumentToHtmlOptions._DEFAULT) { - } - - private DocumentConverter(DocumentToHtmlOptions options) { - this.options = options; - } - - public DocumentConverter IdPrefix(string idPrefix) { - return new DocumentConverter(options.idPrefix(idPrefix)); - } - - public DocumentConverter PreserveEmptyParagraphs() { - return new DocumentConverter(options.preserveEmptyParagraphs()); - } - - public DocumentConverter AddStyleMap(string styleMap) { - return new DocumentConverter(options.addStyleMap(styleMap)); - } - - public DocumentConverter DisableDefaultStyleMap() { - return new DocumentConverter(options.disableDefaultStyleMap()); - } - - public IResult<string> ConvertToHtml(Stream stream) { - return new InternalDocumentConverter(options) - .convertToHtml(ToJava.StreamToInputStream(stream)) - .ToResult(); - } - - public IResult<string> ConvertToHtml(string path) { - return new InternalDocumentConverter(options) - .convertToHtml(new Couscous.java.io.File(path)) - .ToResult(); - } - - public IResult<string> ExtractRawText(Stream stream) { - return new InternalDocumentConverter(options) - .extractRawText(ToJava.StreamToInputStream(stream)) - .ToResult(); - } - - public IResult<string> ExtractRawText(string path) { - return new InternalDocumentConverter(options) - .extractRawText(new Couscous.java.io.File(path)) - .ToResult(); - } - } -} diff --git a/dotnet/Mammoth/IResult.cs b/dotnet/Mammoth/IResult.cs deleted file mode 100644 index 7088f3a..0000000 --- a/dotnet/Mammoth/IResult.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System.Collections.Generic; - -namespace Mammoth { - public interface IResult<T> { - T Value { get; } - ISet<string> Warnings { get; } - } -} diff --git a/dotnet/Mammoth/Mammoth.csproj b/dotnet/Mammoth/Mammoth.csproj deleted file mode 100644 index 6e2c473..0000000 --- a/dotnet/Mammoth/Mammoth.csproj +++ /dev/null @@ -1,107 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProjectGuid>{51C5CBD6-8809-4D5E-BABE-1787A16F5ED8}</ProjectGuid> - <OutputType>Library</OutputType> - <RootNamespace>Mammoth</RootNamespace> - <AssemblyName>Mammoth</AssemblyName> - <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug</OutputPath> - <DefineConstants>DEBUG;</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <ConsolePause>false</ConsolePause> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <DebugType>full</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release</OutputPath> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - <ConsolePause>false</ConsolePause> - </PropertyGroup> - <ItemGroup> - <Reference Include="System" /> - <Reference Include="System.Xml" /> - <Reference Include="System.IO.Compression" /> - <Reference Include="System.IO.Compression.FileSystem" /> - </ItemGroup> - <ItemGroup> - <Compile Include="Properties\AssemblyInfo.cs" /> - <Compile Include="DocumentConverter.cs" /> - <Compile Include="IResult.cs" /> - <Compile Include="SimpleResult.cs" /> - <Compile Include="generated.cs" /> - <Compile Include="Couscous\Adapters.cs" /> - <Compile Include="Couscous\HorribleHacks.cs" /> - <Compile Include="Couscous\IterableExtensions.cs" /> - <Compile Include="Couscous\JavaStringExtensions.cs" /> - <Compile Include="Couscous\java\io\File.cs" /> - <Compile Include="Couscous\java\io\InputStream.cs" /> - <Compile Include="Couscous\java\io\IOException.cs" /> - <Compile Include="Couscous\java\io\Closeable.cs" /> - <Compile Include="Couscous\java\nio\file\Path.cs" /> - <Compile Include="Couscous\java\lang\IllegalArgumentException.cs" /> - <Compile Include="Couscous\java\lang\IndexOutOfBoundsException.cs" /> - <Compile Include="Couscous\java\lang\Iterable.cs" /> - <Compile Include="Couscous\java\lang\RuntimeException.cs" /> - <Compile Include="Couscous\java\lang\String.cs" /> - <Compile Include="Couscous\java\lang\StringBuilder.cs" /> - <Compile Include="Couscous\java\lang\UnsupportedOperationException.cs" /> - <Compile Include="Couscous\java\math\BigInteger.cs" /> - <Compile Include="Couscous\java\net\URI.cs" /> - <Compile Include="Couscous\java\net\URISyntaxException.cs" /> - <Compile Include="Couscous\java\net\URL.cs" /> - <Compile Include="Couscous\java\util\function\BiConsumer.cs" /> - <Compile Include="Couscous\java\util\function\BiFunction.cs" /> - <Compile Include="Couscous\java\util\function\BiPredicate.cs" /> - <Compile Include="Couscous\java\util\function\Consumer.cs" /> - <Compile Include="Couscous\java\util\function\Function.cs" /> - <Compile Include="Couscous\java\util\function\Predicate.cs" /> - <Compile Include="Couscous\java\util\function\Supplier.cs" /> - <Compile Include="Couscous\java\util\ArrayDeque.cs" /> - <Compile Include="Couscous\java\util\ArrayList.cs" /> - <Compile Include="Couscous\java\util\Arrays.cs" /> - <Compile Include="Couscous\java\util\Collection.cs" /> - <Compile Include="Couscous\java\util\Deque.cs" /> - <Compile Include="Couscous\java\util\HashMap.cs" /> - <Compile Include="Couscous\java\util\HashSet.cs" /> - <Compile Include="Couscous\java\util\Iterator.cs" /> - <Compile Include="Couscous\java\util\List.cs" /> - <Compile Include="Couscous\java\util\Map.cs" /> - <Compile Include="Couscous\java\util\NoSuchElementException.cs" /> - <Compile Include="Couscous\java\util\Optional.cs" /> - <Compile Include="Couscous\java\util\Set.cs" /> - <Compile Include="Couscous\mammoth\internal\docx\InMemoryDocxFile.cs" /> - <Compile Include="Couscous\mammoth\internal\docx\ZippedDocxFile.cs" /> - <Compile Include="Couscous\mammoth\internal\styles\parsing\LineParseException.cs" /> - <Compile Include="Couscous\mammoth\internal\styles\parsing\ParseException.cs" /> - <Compile Include="Couscous\mammoth\internal\util\Base64Encoding.cs" /> - <Compile Include="Couscous\mammoth\internal\util\Casts.cs" /> - <Compile Include="Couscous\mammoth\internal\util\Lists.cs" /> - <Compile Include="Couscous\mammoth\internal\util\Maps.cs" /> - <Compile Include="Couscous\mammoth\internal\util\Paths.cs" /> - <Compile Include="Couscous\mammoth\internal\util\PassThroughException.cs" /> - <Compile Include="Couscous\mammoth\internal\util\Sets.cs" /> - <Compile Include="Couscous\mammoth\internal\util\Strings.cs" /> - <Compile Include="Couscous\mammoth\internal\util\Iterables.cs" /> - <Compile Include="Couscous\mammoth\internal\xml\parsing\SimpleSax.cs" /> - </ItemGroup> - <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> - <ItemGroup> - <Folder Include="Couscous\" /> - <Folder Include="Couscous\java\" /> - <Folder Include="Couscous\mammoth\" /> - <Folder Include="Couscous\mammoth\internal\" /> - <Folder Include="Couscous\mammoth\internal\util\" /> - <Folder Include="Couscous\java\nio\" /> - <Folder Include="Couscous\java\nio\file\" /> - </ItemGroup> -</Project> diff --git a/dotnet/Mammoth/Mammoth.nuspec b/dotnet/Mammoth/Mammoth.nuspec deleted file mode 100644 index 943c9c6..0000000 --- a/dotnet/Mammoth/Mammoth.nuspec +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0"?> -<package > - <metadata> - <id>$id$</id> - <version>$version$</version> - <title>$title$</title> - <authors>$author$</authors> - <owners>$author$</owners> - <licenseUrl>http://opensource.org/licenses/BSD-2-Clause</licenseUrl> - <projectUrl>https://github.com/mwilliamson/dotnet-mammoth</projectUrl> - <requireLicenseAcceptance>false</requireLicenseAcceptance> - <description>$description$</description> - <copyright>Copyright 2015 - 2016 Michael Williamson</copyright> - <tags>docx html office word</tags> - </metadata> -</package> diff --git a/dotnet/Mammoth/Properties/AssemblyInfo.cs b/dotnet/Mammoth/Properties/AssemblyInfo.cs deleted file mode 100644 index a1b9415..0000000 --- a/dotnet/Mammoth/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. - -[assembly: AssemblyTitle("Mammoth")] -[assembly: AssemblyDescription("Convert Word documents from docx to simple HTML")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Michael Williamson")] -[assembly: AssemblyProduct("Mammoth")] -[assembly: AssemblyCopyright("Copyright © Michael Williamson 2015 - 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. - -[assembly: AssemblyVersion("0.0.2.0")] - -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. - -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - diff --git a/dotnet/Mammoth/SimpleResult.cs b/dotnet/Mammoth/SimpleResult.cs deleted file mode 100644 index f20cd42..0000000 --- a/dotnet/Mammoth/SimpleResult.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Collections.Generic; -using Mammoth.Couscous; -using Mammoth.Couscous.org.zwobble.mammoth.@internal.results; - -namespace Mammoth { - internal static class SimpleResult { - internal static IResult<T> ToResult<T>(this InternalResult<T> result) { - var warnings = new HashSet<string>(FromJava.IterableToEnumerable(result.getWarnings())); - return new SimpleResult<T>(result.getValue(), warnings); - } - } - - internal class SimpleResult<T> : IResult<T> { - public T Value { get; } - public ISet<string> Warnings { get; } - - internal SimpleResult(T value, ISet<string> warnings) { - Value = value; - Warnings = warnings; - } - } -} diff --git a/dotnet/README.md b/dotnet/README.md deleted file mode 100644 index 1265c85..0000000 --- a/dotnet/README.md +++ /dev/null @@ -1,394 +0,0 @@ -# Mammoth .docx to HTML converter for .NET - -Mammoth is designed to convert .docx documents, -such as those created by Microsoft Word, -and convert them to HTML. -Mammoth aims to produce simple and clean HTML by using semantic information in the document, -and ignoring other details. -For instance, -Mammoth converts any paragraph with the style `Heading 1` to `h1` elements, -rather than attempting to exactly copy the styling (font, text size, colour, etc.) of the heading. - -There's a large mismatch between the structure used by .docx and the structure of HTML, -meaning that the conversion is unlikely to be perfect for more complicated documents. -Mammoth works best if you only use styles to semantically mark up your document. - -The following features are currently supported: - -* Headings. - -* Lists. - -* Customisable mapping from your own docx styles to HTML. - For instance, you could convert `WarningHeading` to `h1.warning` by providing an appropriate style mapping. - -* Tables. - The formatting of the table itself, such as borders, is currently ignored, - but the formatting of the text is treated the same as in the rest of the document. - -* Footnotes and endnotes. - -* Images. - -* Bold, italics, underlines, strikethrough, superscript and subscript. - -* Links. - -* Line breaks. - -* Text boxes. The contents of the text box are treated as a separate paragraph - that appears after the paragraph containing the text box. - -## Installation - -Available on [NuGet](https://www.nuget.org/packages/Mammoth/). - -``` -Install-Package Mammoth -``` - -## Other supported platforms - -* [JavaScript](https://github.com/mwilliamson/mammoth.js), both the browser and node.js. - Available [on npm](https://www.npmjs.com/package/mammoth). - -* [Python](https://github.com/mwilliamson/python-mammoth). - Available [on PyPI](https://pypi.python.org/pypi/mammoth). - -* [WordPress](https://wordpress.org/plugins/mammoth-docx-converter/). - -* [Java/JVM](https://github.com/mwilliamson/java-mammoth). - Available [on Maven Central](http://search.maven.org/#search|ga|1|g%3A%22org.zwobble.mammoth%22%20AND%20a%3A%22mammoth%22). - -## Usage - -### Library - -#### Basic conversion - -To convert an existing .docx file to HTML, -create an instance of `DocumentConverter` and -pass the path of the file to `ConvertToHtml`. -For instance: - -```csharp -using Mammoth; - -var converter = new DocumentConverter(); -var result = converter.ConvertToHtml("document.docx"); -var html = result.Value; // The generated HTML -var warnings = result.Warnings; // Any warnings during conversion -``` - -You can also extract the raw text of the document by using `ExtractRawText`. -This will ignore all formatting in the document. -Each paragraph is followed by two newlines. - -```csharp -var converter = new DocumentConverter(); -var result = converter.ExtractRawText("document.docx"); -var html = result.Value; // The raw text -var warnings = result.Warnings; // Any warnings during conversion -``` - -#### Custom style map - -By default, -Mammoth maps some common .docx styles to HTML elements. -For instance, -a paragraph with the style name `Heading 1` is converted to a `h1` element. -You can add custom style maps by calling `AddStyleMap(string)`. -A description of the syntax for style maps can be found in the section "Writing style maps". -For instance, if paragraphs with the style name `Section Title` should be converted to `h1` elements, -and paragraphs with the style name `Subsection Title` should be converted to `h2` elements: - -```csharp -var converter = new DocumentConverter() - .AddStyleMap("p[style-name='Section Title'] => h1:fresh") - .AddStyleMap("p[style-name='Subsection Title'] => h2:fresh"); -``` - -You can also pass in the entire style map as a single string, -which can be useful if style maps are stored in text files: - -```csharp -var styleMap = - "p[style-name='Section Title'] => h1:fresh\n" + - "p[style-name='Subsection Title'] => h2:fresh"; -var converter = new DocumentConverter() - .AddStyleMap(styleMap); -``` - -The most recently-added styles have the greatest precedence. -User-defined style mappings are used in preference to the default style mappings. -To stop using the default style mappings altogether, -call `DisableDefaultStyleMap`: - -```csharp -var converter = new DocumentConverter() - .DisableDefaultStyleMap(); -``` - -#### Bold - -By default, bold text is wrapped in `<strong>` tags. -This behaviour can be changed by adding a style mapping for `b`. -For instance, to wrap bold text in `<em>` tags: - -```csharp -var converter = new DocumentConverter() - .AddStyleMap("b => em"); -``` - -#### Italic - -By default, italic text is wrapped in `<em>` tags. -This behaviour can be changed by adding a style mapping for `i`. -For instance, to wrap italic text in `<strong>` tags: - -```csharp -var converter = new DocumentConverter() - .AddStyleMap("i => strong"); -``` - -#### Underline - -By default, the underlining of any text is ignored since underlining can be confused with links in HTML documents. -This behaviour can be changed by adding a style mapping for `u`. -For instance, suppose that a source document uses underlining for emphasis. -The following will wrap any explicitly underlined source text in `<em>` tags: - -```csharp -var converter = new DocumentConverter() - .AddStyleMap("u => em"); -``` - -#### Strikethrough - -By default, strikethrough text is wrapped in `<s>` tags. -This behaviour can be changed by adding a style mapping for `strike`. -For instance, to wrap strikethrough text in `<del>` tags: - -```csharp -var converter = new DocumentConverter() - .AddStyleMap("strike => del"); -``` -### API - -#### `DocumentConverter` - -Methods: - -* `IResult<string> ConvertToHtml(string path)`: converts the file at `path` into an HTML string. - -* `IResult<string> ConvertToHtml(Stream stream)`: converts `stream` into an HTML string. - Note that using this method instead of `convertToHtml(File file)` means that relative paths - to other files, such as images, cannot be resolved. - -* `IResult<string> ExtractRawText(string path)`: - Extract the raw text of the document. - This will ignore all formatting in the document. - Each paragraph is followed by two newlines. - -* `IResult<string> ExtractRawText(Stream stream)`: - Extract the raw text of the document. - This will ignore all formatting in the document. - Each paragraph is followed by two newlines. - -* `DocumentConverter AddStyleMap(string styleMap)`: - add a style map to specify the mapping of Word styles to HTML. - The most recently added style map has the greatest precedence. - See the section "Writing style maps" for a description of the syntax. - -* `DocumentConverter DisableDefaultStyleMap()`: by default, - any added style maps are combined with the default style map. - Call this to stop using the default style map altogether. - -* `DocumentConverter PreserveEmptyParagraphs()`: by default, empty paragraphs are ignored. - Call this to preserve empty paragraphs in the output. - -* `DocumentConverter IdPrefix(string idPrefix)`: - a string to prepend to any generated IDs, - such as those used by bookmarks, footnotes and endnotes. - Defaults to the empty string. - -#### `IResult<T>` - -Represents the result of a conversion. Properties: - -* `T Value`: the generated text. - -* `ISet<string> Warnings`: any warnings generated during the conversion. - -## Writing style maps - -A style map is made up of a number of style mappings separated by new lines. -Blank lines and lines starting with `#` are ignored. - -A style mapping has two parts: - -* On the left, before the arrow, is the document element matcher. -* On the right, after the arrow, is the HTML path. - -When converting each paragraph, -Mammoth finds the first style mapping where the document element matcher matches the current paragraph. -Mammoth then ensures the HTML path is satisfied. - -### Freshness - -When writing style mappings, it's helpful to understand Mammoth's notion of freshness. -When generating, Mammoth will only close an HTML element when necessary. -Otherwise, elements are reused. - -For instance, suppose one of the specified style mappings is `p[style-name='Heading 1'] => h1`. -If Mammoth encounters a .docx paragraph with the style name `Heading 1`, -the .docx paragraph is converted to a `h1` element with the same text. -If the next .docx paragraph also has the style name `Heading 1`, -then the text of that paragraph will be appended to the *existing* `h1` element, -rather than creating a new `h1` element. - -In most cases, you'll probably want to generate a new `h1` element instead. -You can specify this by using the `:fresh` modifier: - -`p[style-name='Heading 1'] => h1:fresh` - -The two consective `Heading 1` .docx paragraphs will then be converted to two separate `h1` elements. - -Reusing elements is useful in generating more complicated HTML structures. -For instance, suppose your .docx contains asides. -Each aside might have a heading and some body text, -which should be contained within a single `div.aside` element. -In this case, style mappings similar to `p[style-name='Aside Heading'] => div.aside > h2:fresh` and -`p[style-name='Aside Text'] => div.aside > p:fresh` might be helpful. - -### Document element matchers - -#### Paragraphs and runs - -Match any paragraph: - -``` -p -``` - -Match any run: - -``` -r -``` - -To match a paragraph or run with a specific style, -you can reference the style by name. -This is the style name that is displayed in Microsoft Word or LibreOffice. -For instance, to match a paragraph with the style name `Heading 1`: - -``` -p[style-name='Heading 1'] -``` - -Styles can also be referenced by style ID. -This is the ID used internally in the .docx file. -To match a paragraph or run with a specific style ID, -append a dot followed by the style ID. -For instance, to match a paragraph with the style ID `Heading1`: - -``` -p.Heading1 -``` - -#### Bold - -Match explicitly bold text: - -``` -b -``` - -Note that this matches text that has had bold explicitly applied to it. -It will not match any text that is bold because of its paragraph or run style. - -#### Italic - -Match explicitly italic text: - -``` -i -``` - -Note that this matches text that has had italic explicitly applied to it. -It will not match any text that is italic because of its paragraph or run style. - -#### Underline - -Match explicitly underlined text: - -``` -u -``` - -Note that this matches text that has had underline explicitly applied to it. -It will not match any text that is underlined because of its paragraph or run style. - -#### Strikethough - -Match explicitly struckthrough text: - -``` -strike -``` - -Note that this matches text that has had strikethrough explicitly applied to it. -It will not match any text that is struckthrough because of its paragraph or run style. - -### HTML paths - -#### Single elements - -The simplest HTML path is to specify a single element. -For instance, to specify an `h1` element: - -``` -h1 -``` - -To give an element a CSS class, -append a dot followed by the name of the class: - -``` -h1.section-title -``` - -To require that an element is fresh, use `:fresh`: - -``` -h1:fresh -``` - -Modifiers must be used in the correct order: - -``` -h1.section-title:fresh -``` - -#### Nested elements - -Use `>` to specify nested elements. -For instance, to specify `h2` within `div.aside`: - -``` -div.aside > h2 -``` - -You can nest elements to any depth. - -## Missing features - -Compared to the JavaScript and Python implementations, the following features -are currently missing: - -* Custom image handlers -* CLI -* Embedded style map support -* Markdown support -* Document transforms - diff --git a/dotnet/makefile b/dotnet/makefile deleted file mode 100644 index aeeb74b..0000000 --- a/dotnet/makefile +++ /dev/null @@ -1,7 +0,0 @@ -.PHONY: build test - -build: - xbuild Mammoth.sln - -test: build - mono --debug packages/xunit.runner.console.2.1.0/tools/xunit.console.exe Mammoth.Tests/bin/Debug/Mammoth.Tests.dll -noshadow |
