From ec5037c01868fecaec2eba89b975f3e53aded89a Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 30 Apr 2016 17:20:53 +0100 Subject: Export from java-mammoth 5f538798b147f0e76 --- .gitignore | 10 +- Mammoth.Cli/Mammoth.Cli.csproj | 44 + Mammoth.Cli/Program.cs | 11 + Mammoth.Cli/Properties/AssemblyInfo.cs | 27 + Mammoth.Tests/DocumentConverterTests.cs | 232 +- Mammoth.Tests/Mammoth.Tests.csproj | 102 +- Mammoth.Tests/Properties/AssemblyInfo.cs | 51 +- Mammoth.Tests/TestData/empty.docx | Bin 0 -> 3306 bytes Mammoth.Tests/TestData/endnotes.docx | Bin 0 -> 4431 bytes Mammoth.Tests/TestData/external-picture.docx | Bin 0 -> 4120 bytes Mammoth.Tests/TestData/footnote-hyperlink.docx | Bin 0 -> 16271 bytes Mammoth.Tests/TestData/footnotes.docx | Bin 0 -> 15936 bytes .../hyperlinks/word/_rels/document.xml.rels | 10 + .../TestData/hyperlinks/word/document.xml | 18 + Mammoth.Tests/TestData/simple-list.docx | Bin 0 -> 13887 bytes Mammoth.Tests/TestData/simple/word/document.xml | 18 + Mammoth.Tests/TestData/single-paragraph.docx | Bin 0 -> 12773 bytes Mammoth.Tests/TestData/strikethrough.docx | Bin 0 -> 12652 bytes Mammoth.Tests/TestData/tables.docx | Bin 0 -> 13087 bytes Mammoth.Tests/TestData/text-box.docx | Bin 0 -> 15850 bytes .../TestData/tiny-picture-custom-content-type.docx | Bin 0 -> 10876 bytes Mammoth.Tests/TestData/tiny-picture.docx | Bin 0 -> 13699 bytes Mammoth.Tests/TestData/tiny-picture.png | Bin 0 -> 110 bytes Mammoth.Tests/TestData/underline.docx | Bin 0 -> 12797 bytes Mammoth.Tests/TestData/utf8-bom.docx | Bin 0 -> 2836 bytes Mammoth.Tests/TestDocuments/single-paragraph.docx | Bin 12773 -> 0 bytes .../unrecognised-paragraph-styles.docx | Bin 3400 -> 0 bytes Mammoth.Tests/packages.config | 8 +- Mammoth.sln | 64 +- Mammoth/Couscous/Adapters.cs | 99 + Mammoth/Couscous/HorribleHacks.cs | 34 + Mammoth/Couscous/IterableExtensions.cs | 13 + Mammoth/Couscous/JavaStringExtensions.cs | 33 + Mammoth/Couscous/java/io/Closeable.cs | 8 + Mammoth/Couscous/java/io/File.cs | 15 + Mammoth/Couscous/java/io/IOException.cs | 17 + Mammoth/Couscous/java/io/InputStream.cs | 5 + .../Couscous/java/lang/IllegalArgumentException.cs | 8 + .../java/lang/IndexOutOfBoundsException.cs | 7 + Mammoth/Couscous/java/lang/Iterable.cs | 5 + Mammoth/Couscous/java/lang/RuntimeException.cs | 13 + Mammoth/Couscous/java/lang/String.cs | 7 + Mammoth/Couscous/java/lang/StringBuilder.cs | 14 + .../java/lang/UnsupportedOperationException.cs | 7 + Mammoth/Couscous/java/math/BigInteger.cs | 24 + Mammoth/Couscous/java/net/URI.cs | 42 + Mammoth/Couscous/java/net/URISyntaxException.cs | 6 + Mammoth/Couscous/java/net/URL.cs | 28 + Mammoth/Couscous/java/nio/file/Path.cs | 16 + Mammoth/Couscous/java/util/ArrayDeque.cs | 35 + Mammoth/Couscous/java/util/ArrayList.cs | 49 + Mammoth/Couscous/java/util/Arrays.cs | 7 + Mammoth/Couscous/java/util/Collection.cs | 11 + Mammoth/Couscous/java/util/Deque.cs | 10 + Mammoth/Couscous/java/util/HashMap.cs | 69 + Mammoth/Couscous/java/util/HashSet.cs | 34 + Mammoth/Couscous/java/util/Iterator.cs | 6 + Mammoth/Couscous/java/util/List.cs | 8 + Mammoth/Couscous/java/util/Map.cs | 15 + .../Couscous/java/util/NoSuchElementException.cs | 6 + Mammoth/Couscous/java/util/Optional.cs | 103 + Mammoth/Couscous/java/util/Set.cs | 6 + Mammoth/Couscous/java/util/function/BiConsumer.cs | 5 + Mammoth/Couscous/java/util/function/BiFunction.cs | 6 + Mammoth/Couscous/java/util/function/BiPredicate.cs | 6 + Mammoth/Couscous/java/util/function/Consumer.cs | 5 + Mammoth/Couscous/java/util/function/Function.cs | 6 + Mammoth/Couscous/java/util/function/Predicate.cs | 5 + Mammoth/Couscous/java/util/function/Supplier.cs | 5 + .../mammoth/internal/docx/InMemoryDocxFile.cs | 13 + .../mammoth/internal/docx/ZippedDocxFile.cs | 30 + .../internal/styles/parsing/LineParseException.cs | 15 + .../internal/styles/parsing/ParseException.cs | 8 + .../internal/styles/parsing/StyleMapParser.cs | 22 + .../mammoth/internal/util/Base64Encoding.cs | 18 + Mammoth/Couscous/mammoth/internal/util/Casts.cs | 13 + .../Couscous/mammoth/internal/util/Iterables.cs | 60 + Mammoth/Couscous/mammoth/internal/util/Lists.cs | 97 + Mammoth/Couscous/mammoth/internal/util/Maps.cs | 110 + .../mammoth/internal/util/PassThroughException.cs | 29 + Mammoth/Couscous/mammoth/internal/util/Paths.cs | 8 + Mammoth/Couscous/mammoth/internal/util/Sets.cs | 18 + Mammoth/Couscous/mammoth/internal/util/Strings.cs | 18 + .../mammoth/internal/xml/parsing/SimpleSax.cs | 42 + Mammoth/DocumentConverter.cs | 91 +- Mammoth/IResult.cs | 8 + Mammoth/Mammoth.csproj | 146 +- Mammoth/Mammoth.nuspec | 16 - Mammoth/Message.cs | 19 - Mammoth/Properties/AssemblyInfo.cs | 51 +- Mammoth/Result.cs | 19 - Mammoth/SimpleResult.cs | 22 + Mammoth/generated.cs | 3894 +++ Mammoth/mammoth.browser.js | 26610 ------------------- Mammoth/mammoth.edge.js | 18 - Mammoth/packages.config | 4 - README.md | 394 +- makefile | 7 + 98 files changed, 6204 insertions(+), 26989 deletions(-) create mode 100644 Mammoth.Cli/Mammoth.Cli.csproj create mode 100644 Mammoth.Cli/Program.cs create mode 100644 Mammoth.Cli/Properties/AssemblyInfo.cs create mode 100644 Mammoth.Tests/TestData/empty.docx create mode 100644 Mammoth.Tests/TestData/endnotes.docx create mode 100644 Mammoth.Tests/TestData/external-picture.docx create mode 100755 Mammoth.Tests/TestData/footnote-hyperlink.docx create mode 100755 Mammoth.Tests/TestData/footnotes.docx create mode 100644 Mammoth.Tests/TestData/hyperlinks/word/_rels/document.xml.rels create mode 100644 Mammoth.Tests/TestData/hyperlinks/word/document.xml create mode 100755 Mammoth.Tests/TestData/simple-list.docx create mode 100644 Mammoth.Tests/TestData/simple/word/document.xml create mode 100755 Mammoth.Tests/TestData/single-paragraph.docx create mode 100755 Mammoth.Tests/TestData/strikethrough.docx create mode 100755 Mammoth.Tests/TestData/tables.docx create mode 100755 Mammoth.Tests/TestData/text-box.docx create mode 100644 Mammoth.Tests/TestData/tiny-picture-custom-content-type.docx create mode 100755 Mammoth.Tests/TestData/tiny-picture.docx create mode 100644 Mammoth.Tests/TestData/tiny-picture.png create mode 100755 Mammoth.Tests/TestData/underline.docx create mode 100644 Mammoth.Tests/TestData/utf8-bom.docx delete mode 100644 Mammoth.Tests/TestDocuments/single-paragraph.docx delete mode 100644 Mammoth.Tests/TestDocuments/unrecognised-paragraph-styles.docx create mode 100644 Mammoth/Couscous/Adapters.cs create mode 100644 Mammoth/Couscous/HorribleHacks.cs create mode 100644 Mammoth/Couscous/IterableExtensions.cs create mode 100644 Mammoth/Couscous/JavaStringExtensions.cs create mode 100644 Mammoth/Couscous/java/io/Closeable.cs create mode 100644 Mammoth/Couscous/java/io/File.cs create mode 100644 Mammoth/Couscous/java/io/IOException.cs create mode 100644 Mammoth/Couscous/java/io/InputStream.cs create mode 100644 Mammoth/Couscous/java/lang/IllegalArgumentException.cs create mode 100644 Mammoth/Couscous/java/lang/IndexOutOfBoundsException.cs create mode 100644 Mammoth/Couscous/java/lang/Iterable.cs create mode 100644 Mammoth/Couscous/java/lang/RuntimeException.cs create mode 100644 Mammoth/Couscous/java/lang/String.cs create mode 100644 Mammoth/Couscous/java/lang/StringBuilder.cs create mode 100644 Mammoth/Couscous/java/lang/UnsupportedOperationException.cs create mode 100644 Mammoth/Couscous/java/math/BigInteger.cs create mode 100644 Mammoth/Couscous/java/net/URI.cs create mode 100644 Mammoth/Couscous/java/net/URISyntaxException.cs create mode 100644 Mammoth/Couscous/java/net/URL.cs create mode 100644 Mammoth/Couscous/java/nio/file/Path.cs create mode 100644 Mammoth/Couscous/java/util/ArrayDeque.cs create mode 100644 Mammoth/Couscous/java/util/ArrayList.cs create mode 100644 Mammoth/Couscous/java/util/Arrays.cs create mode 100644 Mammoth/Couscous/java/util/Collection.cs create mode 100644 Mammoth/Couscous/java/util/Deque.cs create mode 100644 Mammoth/Couscous/java/util/HashMap.cs create mode 100644 Mammoth/Couscous/java/util/HashSet.cs create mode 100644 Mammoth/Couscous/java/util/Iterator.cs create mode 100644 Mammoth/Couscous/java/util/List.cs create mode 100644 Mammoth/Couscous/java/util/Map.cs create mode 100644 Mammoth/Couscous/java/util/NoSuchElementException.cs create mode 100644 Mammoth/Couscous/java/util/Optional.cs create mode 100644 Mammoth/Couscous/java/util/Set.cs create mode 100644 Mammoth/Couscous/java/util/function/BiConsumer.cs create mode 100644 Mammoth/Couscous/java/util/function/BiFunction.cs create mode 100644 Mammoth/Couscous/java/util/function/BiPredicate.cs create mode 100644 Mammoth/Couscous/java/util/function/Consumer.cs create mode 100644 Mammoth/Couscous/java/util/function/Function.cs create mode 100644 Mammoth/Couscous/java/util/function/Predicate.cs create mode 100644 Mammoth/Couscous/java/util/function/Supplier.cs create mode 100644 Mammoth/Couscous/mammoth/internal/docx/InMemoryDocxFile.cs create mode 100644 Mammoth/Couscous/mammoth/internal/docx/ZippedDocxFile.cs create mode 100644 Mammoth/Couscous/mammoth/internal/styles/parsing/LineParseException.cs create mode 100644 Mammoth/Couscous/mammoth/internal/styles/parsing/ParseException.cs create mode 100644 Mammoth/Couscous/mammoth/internal/styles/parsing/StyleMapParser.cs create mode 100644 Mammoth/Couscous/mammoth/internal/util/Base64Encoding.cs create mode 100644 Mammoth/Couscous/mammoth/internal/util/Casts.cs create mode 100644 Mammoth/Couscous/mammoth/internal/util/Iterables.cs create mode 100644 Mammoth/Couscous/mammoth/internal/util/Lists.cs create mode 100644 Mammoth/Couscous/mammoth/internal/util/Maps.cs create mode 100644 Mammoth/Couscous/mammoth/internal/util/PassThroughException.cs create mode 100644 Mammoth/Couscous/mammoth/internal/util/Paths.cs create mode 100644 Mammoth/Couscous/mammoth/internal/util/Sets.cs create mode 100644 Mammoth/Couscous/mammoth/internal/util/Strings.cs create mode 100644 Mammoth/Couscous/mammoth/internal/xml/parsing/SimpleSax.cs create mode 100644 Mammoth/IResult.cs delete mode 100644 Mammoth/Mammoth.nuspec delete mode 100644 Mammoth/Message.cs delete mode 100644 Mammoth/Result.cs create mode 100644 Mammoth/SimpleResult.cs create mode 100644 Mammoth/generated.cs delete mode 100644 Mammoth/mammoth.browser.js delete mode 100644 Mammoth/mammoth.edge.js delete mode 100644 Mammoth/packages.config create mode 100644 makefile diff --git a/.gitignore b/.gitignore index 2512014..217ab7a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ -*.suo -*.user -/.nuget/*.exe -/packages +/Mammoth/generated.cs /Mammoth/bin /Mammoth/obj -/Mammoth/edge +/Mammoth.Cli/bin +/Mammoth.Cli/obj /Mammoth.Tests/bin /Mammoth.Tests/obj +/packages +*.userprefs diff --git a/Mammoth.Cli/Mammoth.Cli.csproj b/Mammoth.Cli/Mammoth.Cli.csproj new file mode 100644 index 0000000..f7e125e --- /dev/null +++ b/Mammoth.Cli/Mammoth.Cli.csproj @@ -0,0 +1,44 @@ + + + + Debug + AnyCPU + {20602E78-EEBD-407B-B8C3-EDB6254BD663} + Exe + Mammoth.Cli + Mammoth.Cli + v4.5 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + true + + + full + true + bin\Release + prompt + 4 + true + + + + + + + + + + + + {51C5CBD6-8809-4D5E-BABE-1787A16F5ED8} + Mammoth + + + \ No newline at end of file diff --git a/Mammoth.Cli/Program.cs b/Mammoth.Cli/Program.cs new file mode 100644 index 0000000..f45b100 --- /dev/null +++ b/Mammoth.Cli/Program.cs @@ -0,0 +1,11 @@ +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/Mammoth.Cli/Properties/AssemblyInfo.cs b/Mammoth.Cli/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1f83366 --- /dev/null +++ b/Mammoth.Cli/Properties/AssemblyInfo.cs @@ -0,0 +1,27 @@ +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/Mammoth.Tests/DocumentConverterTests.cs b/Mammoth.Tests/DocumentConverterTests.cs index 37cec23..92a3adf 100644 --- a/Mammoth.Tests/DocumentConverterTests.cs +++ b/Mammoth.Tests/DocumentConverterTests.cs @@ -1,24 +1,214 @@ -using NUnit.Framework; - -namespace Mammoth.Tests -{ - public class DocumentConverterTests - { - [Test] - public void SingleWordParagraphIsConvertedToSingleHtmlParagraph() - { - var documentConverter = new DocumentConverter(); - var result = documentConverter.ConvertToHtml("TestDocuments/single-paragraph.docx"); - Assert.AreEqual("

Walking on imported air

", result.Value); - Assert.IsEmpty(result.Messages); - } - - [Test] - public void UnrecognisedStylesAreStatedInMessages() - { - var documentConverter = new DocumentConverter(); - var result = documentConverter.ConvertToHtml("TestDocuments/unrecognised-paragraph-styles.docx"); - Assert.AreEqual("Unrecognised paragraph style: 'Funky' (Style ID: style20)", result.Messages[0].Value); +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"), + "

Walking on imported air

"); + } + + [Fact] + public void CanReadFilesWithUtf8Bom() { + AssertSuccessfulConversion( + ConvertToHtml("utf8-bom.docx"), + "

This XML has a byte order mark.

"); + } + + [Fact] + public void EmptyParagraphsAreIgnoredByDefault() { + AssertSuccessfulConversion( + ConvertToHtml("empty.docx"), + ""); + } + + [Fact] + public void EmptyParagraphsArePreservedIfIgnoreEmptyParagraphsIsFalse() { + AssertSuccessfulConversion( + ConvertToHtml("empty.docx", converter => converter.PreserveEmptyParagraphs()), + "

"); + } + + [Fact] + public void SimpleListIsConvertedToListElements() { + AssertSuccessfulConversion( + ConvertToHtml("simple-list.docx"), + ""); + } + + [Fact] + public void WordTablesAreConvertedToHtmlTables() { + AssertSuccessfulConversion( + ConvertToHtml("tables.docx"), + "

Above

" + + "" + + "" + + "" + + "

Top left

Top right

Bottom left

Bottom right

" + + "

Below

"); + } + + [Fact] + public void InlineImagesAreIncludedInOutput() { + AssertSuccessfulConversion( + ConvertToHtml("tiny-picture.docx"), + "

"); + } + + [Fact] + public void ImagesStoredOutsideOfDocumentAreIncludedInOutput() { + AssertSuccessfulConversion( + ConvertToHtml("external-picture.docx"), + "

"); + } + + [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"), + "

"); + } + + [Fact] + public void FootnotesAreAppendedToText() { + AssertSuccessfulConversion( + ConvertToHtml("footnotes.docx", mammoth => mammoth.IdPrefix("doc-42-")), + "

Ouch" + + "[1]." + + "[2]

" + + "
  1. A tachyon walks into a bar. ↑

  2. " + + "
  3. Fin. ↑

"); + } + + [Fact] + public void EndNotesAreAppendedToText() { + AssertSuccessfulConversion( + ConvertToHtml("endnotes.docx", mammoth => mammoth.IdPrefix("doc-42-")), + "

Ouch" + + "[1]." + + "[2]

" + + "
  1. A tachyon walks into a bar. ↑

  2. " + + "
  3. Fin. ↑

"); + } + + [Fact] + public void RelationshipsAreReadForEachFileContainingBodyXml() { + AssertSuccessfulConversion( + ConvertToHtml("footnote-hyperlink.docx", mammoth => mammoth.IdPrefix("doc-42-")), + + "

[1]

" + + "
  1. Example ↑

"); + } + + [Fact] + public void TextBoxesAreRead() { + AssertSuccessfulConversion( + ConvertToHtml("text-box.docx"), + "

Datum plane

"); + } + + [Fact] + public void CanUseCustomStyleMap() { + AssertSuccessfulConversion( + ConvertToHtml("underline.docx", mammoth => mammoth.AddStyleMap("u => em")), + "

The Sunset Tree

"); + } + + [Fact] + public void MostRecentlyAddedStyleMapTakesPrecedence() { + AssertSuccessfulConversion( + ConvertToHtml("underline.docx", mammoth => mammoth.AddStyleMap("u => em").AddStyleMap("u => strong")), + "

The Sunset Tree

"); + } + + [Fact] + public void RulesFromPreviouslyAddedStyleMapsStillTakeEffectIfNotOverridden() { + AssertSuccessfulConversion( + ConvertToHtml("underline.docx", mammoth => mammoth.AddStyleMap("u => em").AddStyleMap("strike => del")), + "

The Sunset Tree

"); + } + + [Fact] + public void ErrorIsRaisedIfStyleMapCannotBeParsed() { + var exception = Assert.ThrowsAny(() => + 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("

Apple

Banana

", 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 result, string expectedValue) { + if (result.Warnings.Count > 0) { + throw new XunitException("Unexpected warnings: " + string.Join(", ", result.Warnings)); + } + Assert.Equal(expectedValue, result.Value); + } + + private IResult ConvertToHtml(string name) { + return ConvertToHtml(name, converter => converter); + } + + private IResult ConvertToHtml(string name, Func configure) { + return configure(new DocumentConverter()).ConvertToHtml(TestFilePath(name)); + } + + private string TestFilePath(string name) { + return Path.Combine("../../TestData", name); } } } + diff --git a/Mammoth.Tests/Mammoth.Tests.csproj b/Mammoth.Tests/Mammoth.Tests.csproj index 212db46..d561dde 100644 --- a/Mammoth.Tests/Mammoth.Tests.csproj +++ b/Mammoth.Tests/Mammoth.Tests.csproj @@ -1,99 +1,77 @@ - - - + + Debug AnyCPU - {ED442448-256E-4574-BB1C-3303EF29B262} + {E9C3EA8B-FF3B-4E3E-8137-1510465200B5} Library - Properties Mammoth.Tests Mammoth.Tests - v4.0 - 512 - ..\ - true + v4.5 true full false - bin\Debug\ - DEBUG;TRACE + bin\Debug + DEBUG; prompt 4 + false - pdbonly + full true - bin\Release\ - TRACE + bin\Release prompt 4 + false - - ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.dll - False - - - ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.interfaces.dll - False + + + ..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll - - ..\packages\NUnit.2.6.4\lib\nunit.framework.dll + + ..\packages\xunit.extensibility.core.2.1.0\lib\portable-net45+win8+wp8+wpa81\xunit.core.dll - - ..\packages\NUnitTestAdapter.2.0.0\lib\nunit.util.dll - False + + ..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll - - ..\packages\NUnitTestAdapter.2.0.0\lib\NUnit.VisualStudio.TestAdapter.dll - False + + ..\packages\xunit.assert.2.1.0\lib\portable-net45+win8+wp8+wpa81\xunit.assert.dll - - - - - - - - + + + - - PreserveNewest - - - PreserveNewest - + + + + + + + + + + + + + + + + + - {7398c88c-cb94-41c3-bef9-755bcf81f373} + {51C5CBD6-8809-4D5E-BABE-1787A16F5ED8} Mammoth - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - \ No newline at end of file diff --git a/Mammoth.Tests/Properties/AssemblyInfo.cs b/Mammoth.Tests/Properties/AssemblyInfo.cs index c3c901e..79596a3 100644 --- a/Mammoth.Tests/Properties/AssemblyInfo.cs +++ b/Mammoth.Tests/Properties/AssemblyInfo.cs @@ -1,36 +1,27 @@ 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("Mammoth.Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] -[assembly: AssemblyProduct("Mammoth.Tests")] -[assembly: AssemblyCopyright("Copyright © Microsoft 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] +[assembly: AssemblyTitle ("Mammoth.Tests")] +[assembly: AssemblyDescription ("")] +[assembly: AssemblyConfiguration ("")] +[assembly: AssemblyCompany ("")] +[assembly: AssemblyProduct ("")] +[assembly: AssemblyCopyright ("Michael Williamson")] +[assembly: AssemblyTrademark ("")] +[assembly: AssemblyCulture ("")] -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("ba4940f2-3760-4a66-b2a7-861164d661cc")] +// 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("")] -// 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")] diff --git a/Mammoth.Tests/TestData/empty.docx b/Mammoth.Tests/TestData/empty.docx new file mode 100644 index 0000000..e10b869 Binary files /dev/null and b/Mammoth.Tests/TestData/empty.docx differ diff --git a/Mammoth.Tests/TestData/endnotes.docx b/Mammoth.Tests/TestData/endnotes.docx new file mode 100644 index 0000000..1ae4f93 Binary files /dev/null and b/Mammoth.Tests/TestData/endnotes.docx differ diff --git a/Mammoth.Tests/TestData/external-picture.docx b/Mammoth.Tests/TestData/external-picture.docx new file mode 100644 index 0000000..3475626 Binary files /dev/null and b/Mammoth.Tests/TestData/external-picture.docx differ diff --git a/Mammoth.Tests/TestData/footnote-hyperlink.docx b/Mammoth.Tests/TestData/footnote-hyperlink.docx new file mode 100755 index 0000000..208f3dc Binary files /dev/null and b/Mammoth.Tests/TestData/footnote-hyperlink.docx differ diff --git a/Mammoth.Tests/TestData/footnotes.docx b/Mammoth.Tests/TestData/footnotes.docx new file mode 100755 index 0000000..3228e74 Binary files /dev/null and b/Mammoth.Tests/TestData/footnotes.docx differ diff --git a/Mammoth.Tests/TestData/hyperlinks/word/_rels/document.xml.rels b/Mammoth.Tests/TestData/hyperlinks/word/_rels/document.xml.rels new file mode 100644 index 0000000..baa4102 --- /dev/null +++ b/Mammoth.Tests/TestData/hyperlinks/word/_rels/document.xml.rels @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Mammoth.Tests/TestData/hyperlinks/word/document.xml b/Mammoth.Tests/TestData/hyperlinks/word/document.xml new file mode 100644 index 0000000..f1ce575 --- /dev/null +++ b/Mammoth.Tests/TestData/hyperlinks/word/document.xml @@ -0,0 +1,18 @@ + + + + + + + coconuts + + + + + + + + + + + diff --git a/Mammoth.Tests/TestData/simple-list.docx b/Mammoth.Tests/TestData/simple-list.docx new file mode 100755 index 0000000..c2cd5ae Binary files /dev/null and b/Mammoth.Tests/TestData/simple-list.docx differ diff --git a/Mammoth.Tests/TestData/simple/word/document.xml b/Mammoth.Tests/TestData/simple/word/document.xml new file mode 100644 index 0000000..1723398 --- /dev/null +++ b/Mammoth.Tests/TestData/simple/word/document.xml @@ -0,0 +1,18 @@ + + + + + + Hello. + + + + + + + + + + + + diff --git a/Mammoth.Tests/TestData/single-paragraph.docx b/Mammoth.Tests/TestData/single-paragraph.docx new file mode 100755 index 0000000..09caf9a Binary files /dev/null and b/Mammoth.Tests/TestData/single-paragraph.docx differ diff --git a/Mammoth.Tests/TestData/strikethrough.docx b/Mammoth.Tests/TestData/strikethrough.docx new file mode 100755 index 0000000..0d2b713 Binary files /dev/null and b/Mammoth.Tests/TestData/strikethrough.docx differ diff --git a/Mammoth.Tests/TestData/tables.docx b/Mammoth.Tests/TestData/tables.docx new file mode 100755 index 0000000..86009a7 Binary files /dev/null and b/Mammoth.Tests/TestData/tables.docx differ diff --git a/Mammoth.Tests/TestData/text-box.docx b/Mammoth.Tests/TestData/text-box.docx new file mode 100755 index 0000000..2d53703 Binary files /dev/null and b/Mammoth.Tests/TestData/text-box.docx differ diff --git a/Mammoth.Tests/TestData/tiny-picture-custom-content-type.docx b/Mammoth.Tests/TestData/tiny-picture-custom-content-type.docx new file mode 100644 index 0000000..3638f88 Binary files /dev/null and b/Mammoth.Tests/TestData/tiny-picture-custom-content-type.docx differ diff --git a/Mammoth.Tests/TestData/tiny-picture.docx b/Mammoth.Tests/TestData/tiny-picture.docx new file mode 100755 index 0000000..d45bb9e Binary files /dev/null and b/Mammoth.Tests/TestData/tiny-picture.docx differ diff --git a/Mammoth.Tests/TestData/tiny-picture.png b/Mammoth.Tests/TestData/tiny-picture.png new file mode 100644 index 0000000..74cb4ba Binary files /dev/null and b/Mammoth.Tests/TestData/tiny-picture.png differ diff --git a/Mammoth.Tests/TestData/underline.docx b/Mammoth.Tests/TestData/underline.docx new file mode 100755 index 0000000..36604fc Binary files /dev/null and b/Mammoth.Tests/TestData/underline.docx differ diff --git a/Mammoth.Tests/TestData/utf8-bom.docx b/Mammoth.Tests/TestData/utf8-bom.docx new file mode 100644 index 0000000..3881238 Binary files /dev/null and b/Mammoth.Tests/TestData/utf8-bom.docx differ diff --git a/Mammoth.Tests/TestDocuments/single-paragraph.docx b/Mammoth.Tests/TestDocuments/single-paragraph.docx deleted file mode 100644 index 09caf9a..0000000 Binary files a/Mammoth.Tests/TestDocuments/single-paragraph.docx and /dev/null differ diff --git a/Mammoth.Tests/TestDocuments/unrecognised-paragraph-styles.docx b/Mammoth.Tests/TestDocuments/unrecognised-paragraph-styles.docx deleted file mode 100644 index ad4064f..0000000 Binary files a/Mammoth.Tests/TestDocuments/unrecognised-paragraph-styles.docx and /dev/null differ diff --git a/Mammoth.Tests/packages.config b/Mammoth.Tests/packages.config index af221c7..69a4ec4 100644 --- a/Mammoth.Tests/packages.config +++ b/Mammoth.Tests/packages.config @@ -1,5 +1,9 @@  - - + + + + + + \ No newline at end of file diff --git a/Mammoth.sln b/Mammoth.sln index 7749630..630467d 100644 --- a/Mammoth.sln +++ b/Mammoth.sln @@ -1,35 +1,29 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mammoth", "Mammoth\Mammoth.csproj", "{7398C88C-CB94-41C3-BEF9-755BCF81F373}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{76999238-B232-4AB2-BFED-4C5427E7AD1C}" - ProjectSection(SolutionItems) = preProject - .nuget\NuGet.Config = .nuget\NuGet.Config - .nuget\NuGet.exe = .nuget\NuGet.exe - .nuget\NuGet.targets = .nuget\NuGet.targets - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mammoth.Tests", "Mammoth.Tests\Mammoth.Tests.csproj", "{ED442448-256E-4574-BB1C-3303EF29B262}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7398C88C-CB94-41C3-BEF9-755BCF81F373}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7398C88C-CB94-41C3-BEF9-755BCF81F373}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7398C88C-CB94-41C3-BEF9-755BCF81F373}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7398C88C-CB94-41C3-BEF9-755BCF81F373}.Release|Any CPU.Build.0 = Release|Any CPU - {ED442448-256E-4574-BB1C-3303EF29B262}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ED442448-256E-4574-BB1C-3303EF29B262}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ED442448-256E-4574-BB1C-3303EF29B262}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ED442448-256E-4574-BB1C-3303EF29B262}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +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/Mammoth/Couscous/Adapters.cs b/Mammoth/Couscous/Adapters.cs new file mode 100644 index 0000000..c45f35b --- /dev/null +++ b/Mammoth/Couscous/Adapters.cs @@ -0,0 +1,99 @@ +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 IterableToEnumerable(Iterable iterable) { + Iterator iterator = iterable.iterator(); + while (iterator.hasNext()) { + yield return iterator.next(); + } + } + + internal static IDictionary MapToDictionary(Map map) { + return map.AsDictionary(); + } + } + + internal static class ToJava { + internal static Iterable EnumerableToIterable(IEnumerable enumerator) { + return new IterableWrapper(enumerator); + } + + private class IterableWrapper : Iterable { + private readonly IEnumerable _enumerable; + + internal IterableWrapper(IEnumerable enumerable) { + _enumerable = enumerable; + } + + public Iterator iterator() { + return EnumeratorToIterator(_enumerable.GetEnumerator()); + } + } + + internal static Iterator EnumeratorToIterator(IEnumerator enumerator) { + return new EnumeratorToIteratorAdapter(enumerator); + } + + private class EnumeratorToIteratorAdapter : Iterator { + private readonly IEnumerator _enumerator; + private bool _ready; + private bool _hasNext; + + internal EnumeratorToIteratorAdapter(IEnumerator 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 DictionaryToMap(IDictionary dictionary) { + return new HashMap(dictionary); + } + + internal static java.util.List ListToList(IList list) { + return new ArrayList(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/Mammoth/Couscous/HorribleHacks.cs b/Mammoth/Couscous/HorribleHacks.cs new file mode 100644 index 0000000..c97dc0a --- /dev/null +++ b/Mammoth/Couscous/HorribleHacks.cs @@ -0,0 +1,34 @@ +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 first, Optional second) { + return (!first.isPresent() && !second.isPresent()) || (first.isPresent() && second.isPresent() && first.get() == second.get()); + } + + internal static bool equals(this Map firstMap, Map 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/Mammoth/Couscous/IterableExtensions.cs b/Mammoth/Couscous/IterableExtensions.cs new file mode 100644 index 0000000..bac0b43 --- /dev/null +++ b/Mammoth/Couscous/IterableExtensions.cs @@ -0,0 +1,13 @@ +using Mammoth.Couscous.java.lang; +using Mammoth.Couscous.java.util.function; + +namespace Mammoth.Couscous { + internal static class IterableExtensions { + public static void forEach(this Iterable iterable, Consumer consumer) { + var iterator = iterable.iterator(); + while (iterator.hasNext()) { + consumer.accept(iterator.next()); + } + } + } +} diff --git a/Mammoth/Couscous/JavaStringExtensions.cs b/Mammoth/Couscous/JavaStringExtensions.cs new file mode 100644 index 0000000..bf4e73f --- /dev/null +++ b/Mammoth/Couscous/JavaStringExtensions.cs @@ -0,0 +1,33 @@ +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/Mammoth/Couscous/java/io/Closeable.cs b/Mammoth/Couscous/java/io/Closeable.cs new file mode 100644 index 0000000..9dc10c5 --- /dev/null +++ b/Mammoth/Couscous/java/io/Closeable.cs @@ -0,0 +1,8 @@ +using System; + +namespace Mammoth.Couscous.java.io { + internal interface Closeable { + void close(); + } +} + diff --git a/Mammoth/Couscous/java/io/File.cs b/Mammoth/Couscous/java/io/File.cs new file mode 100644 index 0000000..abff40a --- /dev/null +++ b/Mammoth/Couscous/java/io/File.cs @@ -0,0 +1,15 @@ +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/Mammoth/Couscous/java/io/IOException.cs b/Mammoth/Couscous/java/io/IOException.cs new file mode 100644 index 0000000..f7b708e --- /dev/null +++ b/Mammoth/Couscous/java/io/IOException.cs @@ -0,0 +1,17 @@ +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/Mammoth/Couscous/java/io/InputStream.cs b/Mammoth/Couscous/java/io/InputStream.cs new file mode 100644 index 0000000..b474bb8 --- /dev/null +++ b/Mammoth/Couscous/java/io/InputStream.cs @@ -0,0 +1,5 @@ +namespace Mammoth.Couscous.java.io { + internal interface InputStream { + System.IO.Stream Stream { get; } + } +} diff --git a/Mammoth/Couscous/java/lang/IllegalArgumentException.cs b/Mammoth/Couscous/java/lang/IllegalArgumentException.cs new file mode 100644 index 0000000..57ef62b --- /dev/null +++ b/Mammoth/Couscous/java/lang/IllegalArgumentException.cs @@ -0,0 +1,8 @@ +using System; + +namespace Mammoth.Couscous.java.lang { + internal class IllegalArgumentException : RuntimeException { + internal IllegalArgumentException(string message) : base(message) { + } + } +} diff --git a/Mammoth/Couscous/java/lang/IndexOutOfBoundsException.cs b/Mammoth/Couscous/java/lang/IndexOutOfBoundsException.cs new file mode 100644 index 0000000..c56c7c1 --- /dev/null +++ b/Mammoth/Couscous/java/lang/IndexOutOfBoundsException.cs @@ -0,0 +1,7 @@ +using System; + +namespace Mammoth.Couscous.java.lang { + internal class IndexOutOfBoundsException : RuntimeException { + } +} + diff --git a/Mammoth/Couscous/java/lang/Iterable.cs b/Mammoth/Couscous/java/lang/Iterable.cs new file mode 100644 index 0000000..d050b06 --- /dev/null +++ b/Mammoth/Couscous/java/lang/Iterable.cs @@ -0,0 +1,5 @@ +namespace Mammoth.Couscous.java.lang { + internal interface Iterable { + java.util.Iterator iterator(); + } +} diff --git a/Mammoth/Couscous/java/lang/RuntimeException.cs b/Mammoth/Couscous/java/lang/RuntimeException.cs new file mode 100644 index 0000000..cf882aa --- /dev/null +++ b/Mammoth/Couscous/java/lang/RuntimeException.cs @@ -0,0 +1,13 @@ +using System; + +namespace Mammoth.Couscous.java.lang +{ + internal class RuntimeException : Exception { + internal RuntimeException() : base() { + } + + internal RuntimeException(string message) : base(message) { + } + } +} + diff --git a/Mammoth/Couscous/java/lang/String.cs b/Mammoth/Couscous/java/lang/String.cs new file mode 100644 index 0000000..bd0838d --- /dev/null +++ b/Mammoth/Couscous/java/lang/String.cs @@ -0,0 +1,7 @@ +namespace Mammoth.Couscous.java.lang { + internal partial class String { + internal static string join(string separator, Iterable values) { + return string.Join(separator, FromJava.IterableToEnumerable(values)); + } + } +} diff --git a/Mammoth/Couscous/java/lang/StringBuilder.cs b/Mammoth/Couscous/java/lang/StringBuilder.cs new file mode 100644 index 0000000..c894936 --- /dev/null +++ b/Mammoth/Couscous/java/lang/StringBuilder.cs @@ -0,0 +1,14 @@ +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/Mammoth/Couscous/java/lang/UnsupportedOperationException.cs b/Mammoth/Couscous/java/lang/UnsupportedOperationException.cs new file mode 100644 index 0000000..da86874 --- /dev/null +++ b/Mammoth/Couscous/java/lang/UnsupportedOperationException.cs @@ -0,0 +1,7 @@ +using System; + +namespace Mammoth.Couscous.java.lang { + internal class UnsupportedOperationException : RuntimeException { + } +} + diff --git a/Mammoth/Couscous/java/math/BigInteger.cs b/Mammoth/Couscous/java/math/BigInteger.cs new file mode 100644 index 0000000..40ac3d3 --- /dev/null +++ b/Mammoth/Couscous/java/math/BigInteger.cs @@ -0,0 +1,24 @@ +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/Mammoth/Couscous/java/net/URI.cs b/Mammoth/Couscous/java/net/URI.cs new file mode 100644 index 0000000..818d694 --- /dev/null +++ b/Mammoth/Couscous/java/net/URI.cs @@ -0,0 +1,42 @@ +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/Mammoth/Couscous/java/net/URISyntaxException.cs b/Mammoth/Couscous/java/net/URISyntaxException.cs new file mode 100644 index 0000000..7380ff6 --- /dev/null +++ b/Mammoth/Couscous/java/net/URISyntaxException.cs @@ -0,0 +1,6 @@ +namespace Mammoth.Couscous.java.net { + internal class URISyntaxException : System.Exception { + internal URISyntaxException(string message) : base(message) { + } + } +} diff --git a/Mammoth/Couscous/java/net/URL.cs b/Mammoth/Couscous/java/net/URL.cs new file mode 100644 index 0000000..88479e8 --- /dev/null +++ b/Mammoth/Couscous/java/net/URL.cs @@ -0,0 +1,28 @@ +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/Mammoth/Couscous/java/nio/file/Path.cs b/Mammoth/Couscous/java/nio/file/Path.cs new file mode 100644 index 0000000..030f757 --- /dev/null +++ b/Mammoth/Couscous/java/nio/file/Path.cs @@ -0,0 +1,16 @@ +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/Mammoth/Couscous/java/util/ArrayDeque.cs b/Mammoth/Couscous/java/util/ArrayDeque.cs new file mode 100644 index 0000000..df5447d --- /dev/null +++ b/Mammoth/Couscous/java/util/ArrayDeque.cs @@ -0,0 +1,35 @@ +namespace Mammoth.Couscous.java.util { + internal class ArrayDeque : Deque { + private readonly System.Collections.Generic.IList _list = new System.Collections.Generic.List(); + + 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/Mammoth/Couscous/java/util/ArrayList.cs b/Mammoth/Couscous/java/util/ArrayList.cs new file mode 100644 index 0000000..4414123 --- /dev/null +++ b/Mammoth/Couscous/java/util/ArrayList.cs @@ -0,0 +1,49 @@ +using Mammoth.Couscous.java.lang; +using Mammoth.Couscous.java.util; + +namespace Mammoth.Couscous.java.util { + internal class ArrayList : List { + private readonly System.Collections.Generic.IList _list; + + internal ArrayList() : this(new System.Collections.Generic.List()) { + } + + internal ArrayList(System.Collections.Generic.IList list) { + _list = list; + } + + public Iterator 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/Mammoth/Couscous/java/util/Arrays.cs b/Mammoth/Couscous/java/util/Arrays.cs new file mode 100644 index 0000000..093db83 --- /dev/null +++ b/Mammoth/Couscous/java/util/Arrays.cs @@ -0,0 +1,7 @@ +namespace Mammoth.Couscous.java.util { + internal static class Arrays { + internal static List asList(T[] elements) { + return ToJava.ListToList(elements); + } + } +} diff --git a/Mammoth/Couscous/java/util/Collection.cs b/Mammoth/Couscous/java/util/Collection.cs new file mode 100644 index 0000000..a0cae74 --- /dev/null +++ b/Mammoth/Couscous/java/util/Collection.cs @@ -0,0 +1,11 @@ +using Mammoth.Couscous.java.lang; + +namespace Mammoth.Couscous.java.util { + interface Collection : Iterable { + bool isEmpty(); + int size(); + bool contains(object value); + + void add(T value); + } +} diff --git a/Mammoth/Couscous/java/util/Deque.cs b/Mammoth/Couscous/java/util/Deque.cs new file mode 100644 index 0000000..c954fce --- /dev/null +++ b/Mammoth/Couscous/java/util/Deque.cs @@ -0,0 +1,10 @@ +namespace Mammoth.Couscous.java.util { + internal interface Deque { + int size(); + T getFirst(); + T getLast(); + + void add(T value); + T removeLast(); + } +} diff --git a/Mammoth/Couscous/java/util/HashMap.cs b/Mammoth/Couscous/java/util/HashMap.cs new file mode 100644 index 0000000..38e516e --- /dev/null +++ b/Mammoth/Couscous/java/util/HashMap.cs @@ -0,0 +1,69 @@ +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 : Map { + private readonly IDictionary _dictionary; + + internal HashMap() : this(new Dictionary()) { + } + + internal HashMap(IDictionary dictionary) { + _dictionary = dictionary; + } + + public void put(TKey key, TValue value) { + _dictionary[key] = value; + } + + public bool containsKey(TKey key) { + return _dictionary.ContainsKey(key); + } + + public Set> entrySet() { + return new EntrySet(_dictionary); + } + + public Optional _lookup(TKey key) { + if (_dictionary.ContainsKey(key)) { + return new Some(_dictionary[key]); + } else { + return new None(); + } + } + + public IDictionary AsDictionary() { + return _dictionary; + } + + internal class EntrySet : Set> { + private readonly IDictionary _dictionary; + + internal EntrySet(IDictionary dictionary) { + _dictionary = dictionary; + } + + public Iterator> 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 value) { + throw new UnsupportedOperationException(); + } + } + } +} diff --git a/Mammoth/Couscous/java/util/HashSet.cs b/Mammoth/Couscous/java/util/HashSet.cs new file mode 100644 index 0000000..ac10075 --- /dev/null +++ b/Mammoth/Couscous/java/util/HashSet.cs @@ -0,0 +1,34 @@ +using System.Collections.Generic; + +namespace Mammoth.Couscous.java.util { + internal class HashSet : Set { + private readonly ISet _set; + + internal HashSet() : this(new System.Collections.Generic.HashSet()) { + } + + internal HashSet(ISet set) { + _set = set; + } + + public Iterator 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/Mammoth/Couscous/java/util/Iterator.cs b/Mammoth/Couscous/java/util/Iterator.cs new file mode 100644 index 0000000..0ae48b2 --- /dev/null +++ b/Mammoth/Couscous/java/util/Iterator.cs @@ -0,0 +1,6 @@ +namespace Mammoth.Couscous.java.util { + internal interface Iterator { + bool hasNext(); + T next(); + } +} diff --git a/Mammoth/Couscous/java/util/List.cs b/Mammoth/Couscous/java/util/List.cs new file mode 100644 index 0000000..45a9299 --- /dev/null +++ b/Mammoth/Couscous/java/util/List.cs @@ -0,0 +1,8 @@ +using Mammoth.Couscous.java.lang; + +namespace Mammoth.Couscous.java.util { + interface List : Collection { + T get(int index); + T remove(int index); + } +} diff --git a/Mammoth/Couscous/java/util/Map.cs b/Mammoth/Couscous/java/util/Map.cs new file mode 100644 index 0000000..5405c77 --- /dev/null +++ b/Mammoth/Couscous/java/util/Map.cs @@ -0,0 +1,15 @@ +namespace Mammoth.Couscous.java.util { + internal interface Map { + void put(K key, V value); + bool containsKey(K key); + Set> entrySet(); + + Optional _lookup(K key); + System.Collections.Generic.IDictionary AsDictionary(); + } + + internal interface Map__Entry { + K getKey(); + V getValue(); + } +} diff --git a/Mammoth/Couscous/java/util/NoSuchElementException.cs b/Mammoth/Couscous/java/util/NoSuchElementException.cs new file mode 100644 index 0000000..4a1ee9c --- /dev/null +++ b/Mammoth/Couscous/java/util/NoSuchElementException.cs @@ -0,0 +1,6 @@ +using Mammoth.Couscous.java.lang; + +namespace Mammoth.Couscous.java.util { + internal class NoSuchElementException : RuntimeException { + } +} diff --git a/Mammoth/Couscous/java/util/Optional.cs b/Mammoth/Couscous/java/util/Optional.cs new file mode 100644 index 0000000..f295688 --- /dev/null +++ b/Mammoth/Couscous/java/util/Optional.cs @@ -0,0 +1,103 @@ +using System; +using Mammoth.Couscous.java.util.function; + +namespace Mammoth.Couscous.java.util +{ + internal interface Optional + { + bool isPresent(); + Optional map(Function function); + Optional flatMap(Function> function); + T orElse(T value); + T orElseGet(Supplier supplier); + T orElseThrow(Supplier exceptionSupplier) where TException : Exception; + T get(); + void ifPresent(Consumer consumer); + } + + internal class None : Optional { + public bool isPresent() { + return false; + } + + public Optional map(Function function) { + return new None(); + } + + public Optional flatMap(Function> function) { + return new None(); + } + + public T orElse(T value) { + return value; + } + + public T orElseGet(Supplier supplier) { + return supplier.get(); + } + + public T orElseThrow(Supplier exceptionSupplier) where TException : Exception { + throw exceptionSupplier.get(); + } + + public T get() { + throw new NoSuchElementException(); + } + + public void ifPresent(Consumer consumer) { + } + } + + internal class Some : Optional { + private readonly T _value; + + internal Some(T value) { + _value = value; + } + + public bool isPresent() { + return true; + } + + public Optional map(Function function) { + return new Some(function.apply(_value)); + } + + public Optional flatMap(Function> function) { + return function.apply(_value); + } + + public T orElse(T value) { + return _value; + } + + public T orElseGet(Supplier supplier) { + return _value; + } + + public T orElseThrow(Supplier exceptionSupplier) where TException : Exception { + return _value; + } + + public T get() { + return _value; + } + + public void ifPresent(Consumer consumer) { + consumer.accept(_value); + } + } + + internal static class Optional + { + internal static Optional empty() + { + return new None(); + } + + internal static Optional of(T value) + { + return new Some (value); + } + } +} diff --git a/Mammoth/Couscous/java/util/Set.cs b/Mammoth/Couscous/java/util/Set.cs new file mode 100644 index 0000000..34a23ac --- /dev/null +++ b/Mammoth/Couscous/java/util/Set.cs @@ -0,0 +1,6 @@ +using Mammoth.Couscous.java.lang; + +namespace Mammoth.Couscous.java.util { + internal interface Set : Collection { + } +} diff --git a/Mammoth/Couscous/java/util/function/BiConsumer.cs b/Mammoth/Couscous/java/util/function/BiConsumer.cs new file mode 100644 index 0000000..9479a78 --- /dev/null +++ b/Mammoth/Couscous/java/util/function/BiConsumer.cs @@ -0,0 +1,5 @@ +namespace Mammoth.Couscous.java.util.function { + internal interface BiConsumer { + void accept(T1 first, T2 second); + } +} diff --git a/Mammoth/Couscous/java/util/function/BiFunction.cs b/Mammoth/Couscous/java/util/function/BiFunction.cs new file mode 100644 index 0000000..050f85f --- /dev/null +++ b/Mammoth/Couscous/java/util/function/BiFunction.cs @@ -0,0 +1,6 @@ +namespace Mammoth.Couscous.java.util.function +{ + internal interface BiFunction { + U apply(T1 first, T2 second); + } +} \ No newline at end of file diff --git a/Mammoth/Couscous/java/util/function/BiPredicate.cs b/Mammoth/Couscous/java/util/function/BiPredicate.cs new file mode 100644 index 0000000..0419a6e --- /dev/null +++ b/Mammoth/Couscous/java/util/function/BiPredicate.cs @@ -0,0 +1,6 @@ +namespace Mammoth.Couscous.java.util.function +{ + internal interface BiPredicate { + bool test(T first, U second); + } +} \ No newline at end of file diff --git a/Mammoth/Couscous/java/util/function/Consumer.cs b/Mammoth/Couscous/java/util/function/Consumer.cs new file mode 100644 index 0000000..f80d426 --- /dev/null +++ b/Mammoth/Couscous/java/util/function/Consumer.cs @@ -0,0 +1,5 @@ +namespace Mammoth.Couscous.java.util.function { + internal interface Consumer { + void accept(T value); + } +} \ No newline at end of file diff --git a/Mammoth/Couscous/java/util/function/Function.cs b/Mammoth/Couscous/java/util/function/Function.cs new file mode 100644 index 0000000..2b4d3ae --- /dev/null +++ b/Mammoth/Couscous/java/util/function/Function.cs @@ -0,0 +1,6 @@ +namespace Mammoth.Couscous.java.util.function +{ + internal interface Function { + U apply(T arg); + } +} \ No newline at end of file diff --git a/Mammoth/Couscous/java/util/function/Predicate.cs b/Mammoth/Couscous/java/util/function/Predicate.cs new file mode 100644 index 0000000..2023309 --- /dev/null +++ b/Mammoth/Couscous/java/util/function/Predicate.cs @@ -0,0 +1,5 @@ +namespace Mammoth.Couscous.java.util.function { + internal interface Predicate { + bool test(T value); + } +} \ No newline at end of file diff --git a/Mammoth/Couscous/java/util/function/Supplier.cs b/Mammoth/Couscous/java/util/function/Supplier.cs new file mode 100644 index 0000000..eab3ffb --- /dev/null +++ b/Mammoth/Couscous/java/util/function/Supplier.cs @@ -0,0 +1,5 @@ +namespace Mammoth.Couscous.java.util.function { + internal interface Supplier { + T get(); + } +} \ No newline at end of file diff --git a/Mammoth/Couscous/mammoth/internal/docx/InMemoryDocxFile.cs b/Mammoth/Couscous/mammoth/internal/docx/InMemoryDocxFile.cs new file mode 100644 index 0000000..9b7efd0 --- /dev/null +++ b/Mammoth/Couscous/mammoth/internal/docx/InMemoryDocxFile.cs @@ -0,0 +1,13 @@ +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/Mammoth/Couscous/mammoth/internal/docx/ZippedDocxFile.cs b/Mammoth/Couscous/mammoth/internal/docx/ZippedDocxFile.cs new file mode 100644 index 0000000..cf39e63 --- /dev/null +++ b/Mammoth/Couscous/mammoth/internal/docx/ZippedDocxFile.cs @@ -0,0 +1,30 @@ +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 tryGetInputStream(string name) { + var entry = _zipFile.GetEntry(name); + if (entry == null) { + return Optional.empty(); + } else { + return Optional.of(ToJava.StreamToInputStream(entry.Open())); + } + } + + public void close() { + _zipFile.Dispose(); + } + } +} diff --git a/Mammoth/Couscous/mammoth/internal/styles/parsing/LineParseException.cs b/Mammoth/Couscous/mammoth/internal/styles/parsing/LineParseException.cs new file mode 100644 index 0000000..6ca9381 --- /dev/null +++ b/Mammoth/Couscous/mammoth/internal/styles/parsing/LineParseException.cs @@ -0,0 +1,15 @@ +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/Mammoth/Couscous/mammoth/internal/styles/parsing/ParseException.cs b/Mammoth/Couscous/mammoth/internal/styles/parsing/ParseException.cs new file mode 100644 index 0000000..73f349c --- /dev/null +++ b/Mammoth/Couscous/mammoth/internal/styles/parsing/ParseException.cs @@ -0,0 +1,8 @@ +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/Mammoth/Couscous/mammoth/internal/styles/parsing/StyleMapParser.cs b/Mammoth/Couscous/mammoth/internal/styles/parsing/StyleMapParser.cs new file mode 100644 index 0000000..53315f3 --- /dev/null +++ b/Mammoth/Couscous/mammoth/internal/styles/parsing/StyleMapParser.cs @@ -0,0 +1,22 @@ +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 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/Mammoth/Couscous/mammoth/internal/util/Base64Encoding.cs b/Mammoth/Couscous/mammoth/internal/util/Base64Encoding.cs new file mode 100644 index 0000000..24d2f9c --- /dev/null +++ b/Mammoth/Couscous/mammoth/internal/util/Base64Encoding.cs @@ -0,0 +1,18 @@ +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 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/Mammoth/Couscous/mammoth/internal/util/Casts.cs b/Mammoth/Couscous/mammoth/internal/util/Casts.cs new file mode 100644 index 0000000..c342e20 --- /dev/null +++ b/Mammoth/Couscous/mammoth/internal/util/Casts.cs @@ -0,0 +1,13 @@ +using Mammoth.Couscous.java.util; + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util { + internal static class Casts { + internal static Optional tryCast(System.Type type, object value) { + if (value is T) { + return new Some((T) value); + } else { + return new None(); + } + } + } +} diff --git a/Mammoth/Couscous/mammoth/internal/util/Iterables.cs b/Mammoth/Couscous/mammoth/internal/util/Iterables.cs new file mode 100644 index 0000000..b1e1477 --- /dev/null +++ b/Mammoth/Couscous/mammoth/internal/util/Iterables.cs @@ -0,0 +1,60 @@ +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(Iterable iterable, T defaultValue) { + var iterator = iterable.iterator(); + if (iterator.hasNext()) { + return iterator.next(); + } else { + return defaultValue; + } + } + + internal static Optional tryFind(Iterable iterable, Predicate predicate) { + var iterator = iterable.iterator(); + while (iterator.hasNext()) { + T value = iterator.next(); + if (predicate.test(value)) { + return new Some(value); + } + } + return new None(); + } + + internal static Iterable lazyFilter(Iterable iterable, Predicate predicate) { + var enumerable = FromJava.IterableToEnumerable(iterable).Where(predicate.test); + return ToJava.EnumerableToIterable(enumerable); + } + + internal static Iterable lazyFilter(Iterable iterable, System.Type type) { + var enumerable = FromJava.IterableToEnumerable(iterable).OfType(); + return ToJava.EnumerableToIterable(enumerable); + } + + internal static Iterable lazyMap(Iterable iterable, Function function) { + var enumerable = FromJava.IterableToEnumerable(iterable) + .Select(function.apply); + return ToJava.EnumerableToIterable(enumerable); + } + + internal static Iterable lazyFlatMap(Iterable iterable, Function> function) { + var enumerable = FromJava.IterableToEnumerable(iterable) + .SelectMany(element => FromJava.IterableToEnumerable(function.apply(element))); + return ToJava.EnumerableToIterable(enumerable); + } + + internal static Iterable lazyConcat(Iterable first, Iterable second) { + var enumerable = FromJava.IterableToEnumerable(first) + .Concat(FromJava.IterableToEnumerable(second)); + return ToJava.EnumerableToIterable(enumerable); + } + } +} + diff --git a/Mammoth/Couscous/mammoth/internal/util/Lists.cs b/Mammoth/Couscous/mammoth/internal/util/Lists.cs new file mode 100644 index 0000000..b914a34 --- /dev/null +++ b/Mammoth/Couscous/mammoth/internal/util/Lists.cs @@ -0,0 +1,97 @@ +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 list(params T[] values) { + return ToJava.ListToList(values); + } + + internal static List toList(Iterable iterable) { + return ToJava.ListToList(FromJava.IterableToEnumerable(iterable).ToList()); + } + + internal static List eagerMap(Iterable iterable, Function function) { + var result = FromJava.IterableToEnumerable(iterable) + .Select(function.apply) + .ToList(); + return ToJava.ListToList(result); + } + + internal static List eagerFlatMap(Iterable iterable, Function> function) { + var result = FromJava.IterableToEnumerable(iterable) + .SelectMany(element => FromJava.IterableToEnumerable(function.apply(element))) + .ToList(); + return ToJava.ListToList(result); + } + + internal static List cons(T head, Iterable tail) { + var result = new T[] { head } + .Concat(FromJava.IterableToEnumerable(tail)) + .ToList(); + return ToJava.ListToList(result); + } + + internal static List eagerConcat(Iterable first, Iterable second) { + var result = FromJava.IterableToEnumerable(first) + .Concat(FromJava.IterableToEnumerable(second)) + .ToList(); + return ToJava.ListToList(result); + } + + internal static List orderedBy(Iterable iterable, Function getKey) { + var result = FromJava.IterableToEnumerable(iterable) + .OrderBy(getKey.apply) + .ToList(); + return ToJava.ListToList(result); + } + + internal static Optional tryGetLast(List list) { + if (list.isEmpty()) { + return new None(); + } else { + return new Some(list.get(list.size() - 1)); + } + } + + internal static Iterable reversed(List list) { + return new ReversedList(list); + } + + private class ReversedList : Iterable { + private readonly List _list; + + internal ReversedList(List list) { + _list = list; + } + + public Iterator iterator() { + return new ReverseIterator(_list); + } + } + + private class ReverseIterator : Iterator { + private readonly List _list; + private int _nextIndex; + + internal ReverseIterator(List 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/Mammoth/Couscous/mammoth/internal/util/Maps.cs b/Mammoth/Couscous/mammoth/internal/util/Maps.cs new file mode 100644 index 0000000..bee2dac --- /dev/null +++ b/Mammoth/Couscous/mammoth/internal/util/Maps.cs @@ -0,0 +1,110 @@ +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 map() { + return ToJava.DictionaryToMap(new System.Collections.Generic.Dictionary()); + } + + internal static Map map(K key1, V value1) { + return ToJava.DictionaryToMap(new System.Collections.Generic.Dictionary { + {key1, value1} + }); + } + + internal static Map map(K key1, V value1, K key2, V value2) { + return ToJava.DictionaryToMap(new System.Collections.Generic.Dictionary { + {key1, value1}, + {key2, value2} + }); + } + + internal static Map toMap(Iterable iterable, Function> function) { + var dictionary = FromJava.IterableToEnumerable(iterable) + .Select(function.apply) + .ToDictionary(entry => entry.getKey(), entry => entry.getValue()); + return ToJava.DictionaryToMap(dictionary); + + } + + internal static Map toMapWithKey(Iterable iterable, Function function) { + var dictionary = FromJava.IterableToEnumerable(iterable) + .ToDictionary(function.apply); + return ToJava.DictionaryToMap(dictionary); + } + + internal static Map> toMultiMapWithKey(Iterable iterable, Function 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 lookup(Map map, K key) { + return map._lookup(key); + } + + internal static Map eagerMapKeys(Map map, Function function) { + var dictionary = FromJava.MapToDictionary(map) + .ToDictionary( + entry => function.apply(entry.Key), + entry => entry.Value); + return ToJava.DictionaryToMap(dictionary); + } + + internal static Map eagerMapValues(Map map, Function function) { + var dictionary = FromJava.MapToDictionary(map) + .ToDictionary( + entry => entry.Key, + entry => function.apply(entry.Value)); + return ToJava.DictionaryToMap(dictionary); + } + + internal static Map__Entry entry(K key, V value) { + return new Entry(key, value); + } + + private class Entry : Map__Entry { + 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 builder() { + return new Builder(); + } + + internal class Builder { + private readonly System.Collections.Generic.IDictionary _values = new System.Collections.Generic.Dictionary(); + + internal Builder put(K key, V value) { + _values[key] = value; + return this; + } + + internal Map build() { + return ToJava.DictionaryToMap(_values); + } + } + } +} diff --git a/Mammoth/Couscous/mammoth/internal/util/PassThroughException.cs b/Mammoth/Couscous/mammoth/internal/util/PassThroughException.cs new file mode 100644 index 0000000..88597e3 --- /dev/null +++ b/Mammoth/Couscous/mammoth/internal/util/PassThroughException.cs @@ -0,0 +1,29 @@ +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(SupplierWithException supplier) { + try { + return supplier.get(); + } catch (IOException exception) { + throw new PassThroughException(exception); + } + } + + internal static T unwrap(SupplierWithException supplier) { + try { + return supplier.get(); + } catch (PassThroughException exception) { + throw exception._exception; + } + } + + private readonly IOException _exception; + + internal PassThroughException(IOException exception) { + _exception = exception; + } + } +} + diff --git a/Mammoth/Couscous/mammoth/internal/util/Paths.cs b/Mammoth/Couscous/mammoth/internal/util/Paths.cs new file mode 100644 index 0000000..ca876eb --- /dev/null +++ b/Mammoth/Couscous/mammoth/internal/util/Paths.cs @@ -0,0 +1,8 @@ +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/Mammoth/Couscous/mammoth/internal/util/Sets.cs b/Mammoth/Couscous/mammoth/internal/util/Sets.cs new file mode 100644 index 0000000..bfce619 --- /dev/null +++ b/Mammoth/Couscous/mammoth/internal/util/Sets.cs @@ -0,0 +1,18 @@ +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 set(T[] values) { + return new HashSet(new System.Collections.Generic.HashSet(values)); + } + + internal static Set toSet(Iterable iterable) { + return new HashSet(new System.Collections.Generic.HashSet(FromJava.IterableToEnumerable(iterable))); + } + } +} + diff --git a/Mammoth/Couscous/mammoth/internal/util/Strings.cs b/Mammoth/Couscous/mammoth/internal/util/Strings.cs new file mode 100644 index 0000000..65f5e0b --- /dev/null +++ b/Mammoth/Couscous/mammoth/internal/util/Strings.cs @@ -0,0 +1,18 @@ +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/Mammoth/Couscous/mammoth/internal/xml/parsing/SimpleSax.cs b/Mammoth/Couscous/mammoth/internal/xml/parsing/SimpleSax.cs new file mode 100644 index 0000000..65f63c3 --- /dev/null +++ b/Mammoth/Couscous/mammoth/internal/xml/parsing/SimpleSax.cs @@ -0,0 +1,42 @@ +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(); + 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/Mammoth/DocumentConverter.cs b/Mammoth/DocumentConverter.cs index 6057cbd..eb8c939 100644 --- a/Mammoth/DocumentConverter.cs +++ b/Mammoth/DocumentConverter.cs @@ -1,42 +1,57 @@ -using EdgeJs; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Reflection; -using System.Threading.Tasks; - -namespace Mammoth -{ - public class DocumentConverter - { - public Result ConvertToHtml(string path) - { - var mammothJs = ReadResource("Mammoth.mammoth.browser.js") + ReadResource("Mammoth.mammoth.edge.js"); - - var f = Edge.Func(mammothJs); - var result = f(File.ReadAllBytes(path)); - Task.WaitAll(result); - - return ReadResult(result.Result); - } - - private Result ReadResult(dynamic result) - { - var rawMessages = (dynamic[])result.messages; - var messages = rawMessages.Select(message => Message.Warning((string)message.message)).ToList(); - return new Result(result.value, messages); - } - - private static string ReadResource(string resourceName) - { - var currentAssembly = Assembly.GetExecutingAssembly(); - using (var stream = currentAssembly.GetManifestResourceStream(resourceName)) - { - using (var reader = new StreamReader(stream)) - { - return reader.ReadToEnd(); - } - } +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 ConvertToHtml(Stream stream) { + return new InternalDocumentConverter(options) + .convertToHtml(ToJava.StreamToInputStream(stream)) + .ToResult(); + } + + public IResult ConvertToHtml(string path) { + return new InternalDocumentConverter(options) + .convertToHtml(new Couscous.java.io.File(path)) + .ToResult(); + } + + public IResult ExtractRawText(Stream stream) { + return new InternalDocumentConverter(options) + .extractRawText(ToJava.StreamToInputStream(stream)) + .ToResult(); + } + + public IResult ExtractRawText(string path) { + return new InternalDocumentConverter(options) + .extractRawText(new Couscous.java.io.File(path)) + .ToResult(); } } } diff --git a/Mammoth/IResult.cs b/Mammoth/IResult.cs new file mode 100644 index 0000000..7088f3a --- /dev/null +++ b/Mammoth/IResult.cs @@ -0,0 +1,8 @@ +using System.Collections.Generic; + +namespace Mammoth { + public interface IResult { + T Value { get; } + ISet Warnings { get; } + } +} diff --git a/Mammoth/Mammoth.csproj b/Mammoth/Mammoth.csproj index fb10c38..6e2c473 100644 --- a/Mammoth/Mammoth.csproj +++ b/Mammoth/Mammoth.csproj @@ -1,95 +1,107 @@ - - - + + Debug AnyCPU - {7398C88C-CB94-41C3-BEF9-755BCF81F373} + {51C5CBD6-8809-4D5E-BABE-1787A16F5ED8} Library - Properties Mammoth Mammoth - v4.0 - 512 - ..\ - true + v4.5 true full false - bin\Debug\ - DEBUG;TRACE + bin\Debug + DEBUG; prompt 4 + false - pdbonly + full true - bin\Release\ - TRACE + bin\Release prompt 4 + false - - ..\packages\Edge.js.0.10.0\lib\EdgeJs.dll - - - - - - + + - - - - - - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - PreserveNewest - - - PreserveNewest - - - + + + + + + + - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file + diff --git a/Mammoth/Mammoth.nuspec b/Mammoth/Mammoth.nuspec deleted file mode 100644 index 9716654..0000000 --- a/Mammoth/Mammoth.nuspec +++ /dev/null @@ -1,16 +0,0 @@ - - - - $id$ - $version$ - $title$ - $author$ - $author$ - http://opensource.org/licenses/BSD-2-Clause - https://github.com/mwilliamson/dotnet-mammoth - false - $description$ - Copyright 2015 Michael Williamson - docx html office word - - \ No newline at end of file diff --git a/Mammoth/Message.cs b/Mammoth/Message.cs deleted file mode 100644 index 6aa782b..0000000 --- a/Mammoth/Message.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Mammoth -{ - public class Message - { - public static Message Warning(string value) - { - return new Message(value); - } - - private readonly string _value; - - private Message(string value) - { - _value = value; - } - - public string Value { get { return _value; } } - } -} diff --git a/Mammoth/Properties/AssemblyInfo.cs b/Mammoth/Properties/AssemblyInfo.cs index 6fb6bcc..adf69fc 100644 --- a/Mammoth/Properties/AssemblyInfo.cs +++ b/Mammoth/Properties/AssemblyInfo.cs @@ -1,36 +1,27 @@ 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("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")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] +[assembly: AssemblyTitle ("Mammoth")] +[assembly: AssemblyDescription ("")] +[assembly: AssemblyConfiguration ("")] +[assembly: AssemblyCompany ("")] +[assembly: AssemblyProduct ("")] +[assembly: AssemblyCopyright ("Michael Williamson")] +[assembly: AssemblyTrademark ("")] +[assembly: AssemblyCulture ("")] -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("0afd8667-fffe-4889-958e-fbb6023e04aa")] +// 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("")] -// 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("0.0.1.0")] -[assembly: AssemblyFileVersion("0.0.1.0")] diff --git a/Mammoth/Result.cs b/Mammoth/Result.cs deleted file mode 100644 index 7cb3277..0000000 --- a/Mammoth/Result.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections.Generic; - -namespace Mammoth -{ - public class Result - { - private readonly T _value; - private readonly IList _messages; - - public Result(T value, IList messages) - { - _value = value; - _messages = messages; - } - - public T Value { get { return _value; } } - public IList Messages { get { return _messages; } } - } -} diff --git a/Mammoth/SimpleResult.cs b/Mammoth/SimpleResult.cs new file mode 100644 index 0000000..f20cd42 --- /dev/null +++ b/Mammoth/SimpleResult.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using Mammoth.Couscous; +using Mammoth.Couscous.org.zwobble.mammoth.@internal.results; + +namespace Mammoth { + internal static class SimpleResult { + internal static IResult ToResult(this InternalResult result) { + var warnings = new HashSet(FromJava.IterableToEnumerable(result.getWarnings())); + return new SimpleResult(result.getValue(), warnings); + } + } + + internal class SimpleResult : IResult { + public T Value { get; } + public ISet Warnings { get; } + + internal SimpleResult(T value, ISet warnings) { + Value = value; + Warnings = warnings; + } + } +} diff --git a/Mammoth/generated.cs b/Mammoth/generated.cs new file mode 100644 index 0000000..d7aff9b --- /dev/null +++ b/Mammoth/generated.cs @@ -0,0 +1,3894 @@ +namespace Mammoth.Couscous.org.zwobble.mammoth { + internal interface Result { + T getValue(); + Mammoth.Couscous.java.util.Set getWarnings(); + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal { + internal class InternalDocumentConverter_Anonymous_1 : Mammoth.Couscous.java.util.function.Function> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter _this_org__zwobble__mammoth__internal__InternalDocumentConverter; + internal InternalDocumentConverter_Anonymous_1(Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter this_org__zwobble__mammoth__internal__InternalDocumentConverter) { + this._this_org__zwobble__mammoth__internal__InternalDocumentConverter = this_org__zwobble__mammoth__internal__InternalDocumentConverter; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile zipFile) { + return (this._this_org__zwobble__mammoth__internal__InternalDocumentConverter).convertToHtml(Mammoth.Couscous.java.util.Optional.empty(), zipFile); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal { + internal class InternalDocumentConverter_Anonymous_0 : Mammoth.Couscous.org.zwobble.mammoth.@internal.util.SupplierWithException, Mammoth.Couscous.java.io.IOException> { + internal Mammoth.Couscous.java.io.InputStream _stream; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter _this_org__zwobble__mammoth__internal__InternalDocumentConverter; + internal InternalDocumentConverter_Anonymous_0(Mammoth.Couscous.java.io.InputStream stream, Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter this_org__zwobble__mammoth__internal__InternalDocumentConverter) { + this._stream = stream; + this._this_org__zwobble__mammoth__internal__InternalDocumentConverter = this_org__zwobble__mammoth__internal__InternalDocumentConverter; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult get() { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter.withDocxFile>(this._stream, new Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter_Anonymous_1(this._this_org__zwobble__mammoth__internal__InternalDocumentConverter)); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal { + internal class InternalDocumentConverter_Anonymous_3 : Mammoth.Couscous.java.util.function.Function> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter _this_org__zwobble__mammoth__internal__InternalDocumentConverter; + internal Mammoth.Couscous.java.io.File _file; + internal InternalDocumentConverter_Anonymous_3(Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter this_org__zwobble__mammoth__internal__InternalDocumentConverter, Mammoth.Couscous.java.io.File file) { + this._this_org__zwobble__mammoth__internal__InternalDocumentConverter = this_org__zwobble__mammoth__internal__InternalDocumentConverter; + this._file = file; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile zipFile) { + return (this._this_org__zwobble__mammoth__internal__InternalDocumentConverter).convertToHtml(Mammoth.Couscous.java.util.Optional.of((this._file).toPath()), zipFile); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal { + internal class InternalDocumentConverter_Anonymous_2 : Mammoth.Couscous.org.zwobble.mammoth.@internal.util.SupplierWithException, Mammoth.Couscous.java.io.IOException> { + internal Mammoth.Couscous.java.io.File _file; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter _this_org__zwobble__mammoth__internal__InternalDocumentConverter; + internal InternalDocumentConverter_Anonymous_2(Mammoth.Couscous.java.io.File file, Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter this_org__zwobble__mammoth__internal__InternalDocumentConverter) { + this._file = file; + this._this_org__zwobble__mammoth__internal__InternalDocumentConverter = this_org__zwobble__mammoth__internal__InternalDocumentConverter; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult get() { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter.withDocxFile>(this._file, new Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter_Anonymous_3(this._this_org__zwobble__mammoth__internal__InternalDocumentConverter, this._file)); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal { + internal class InternalDocumentConverter_Anonymous_4 : Mammoth.Couscous.java.util.function.Function, string> { + public string apply(Mammoth.Couscous.java.util.List arg0) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.write(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal { + internal class InternalDocumentConverter_Anonymous_5 : Mammoth.Couscous.java.util.function.Function, Mammoth.Couscous.java.util.List> { + public Mammoth.Couscous.java.util.List apply(Mammoth.Couscous.java.util.List arg0) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.collapse(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal { + internal class InternalDocumentConverter_Anonymous_6 : Mammoth.Couscous.java.util.function.Function, Mammoth.Couscous.java.util.List> { + public Mammoth.Couscous.java.util.List apply(Mammoth.Couscous.java.util.List arg0) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.stripEmpty(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal { + internal class InternalDocumentConverter_Anonymous_7 : Mammoth.Couscous.java.util.function.Function>> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter _this_org__zwobble__mammoth__internal__InternalDocumentConverter; + internal InternalDocumentConverter_Anonymous_7(Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter this_org__zwobble__mammoth__internal__InternalDocumentConverter) { + this._this_org__zwobble__mammoth__internal__InternalDocumentConverter = this_org__zwobble__mammoth__internal__InternalDocumentConverter; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult> apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Document nodes) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml.convertToHtml(nodes, (this._this_org__zwobble__mammoth__internal__InternalDocumentConverter)._options); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal { + internal class InternalDocumentConverter_Anonymous_9 : Mammoth.Couscous.java.util.function.Function> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter _this_org__zwobble__mammoth__internal__InternalDocumentConverter; + internal InternalDocumentConverter_Anonymous_9(Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter this_org__zwobble__mammoth__internal__InternalDocumentConverter) { + this._this_org__zwobble__mammoth__internal__InternalDocumentConverter = this_org__zwobble__mammoth__internal__InternalDocumentConverter; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile zipFile) { + return (this._this_org__zwobble__mammoth__internal__InternalDocumentConverter).extractRawText(Mammoth.Couscous.java.util.Optional.empty(), zipFile); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal { + internal class InternalDocumentConverter_Anonymous_8 : Mammoth.Couscous.org.zwobble.mammoth.@internal.util.SupplierWithException, Mammoth.Couscous.java.io.IOException> { + internal Mammoth.Couscous.java.io.InputStream _stream; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter _this_org__zwobble__mammoth__internal__InternalDocumentConverter; + internal InternalDocumentConverter_Anonymous_8(Mammoth.Couscous.java.io.InputStream stream, Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter this_org__zwobble__mammoth__internal__InternalDocumentConverter) { + this._stream = stream; + this._this_org__zwobble__mammoth__internal__InternalDocumentConverter = this_org__zwobble__mammoth__internal__InternalDocumentConverter; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult get() { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter.withDocxFile>(this._stream, new Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter_Anonymous_9(this._this_org__zwobble__mammoth__internal__InternalDocumentConverter)); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal { + internal class InternalDocumentConverter_Anonymous_11 : Mammoth.Couscous.java.util.function.Function> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter _this_org__zwobble__mammoth__internal__InternalDocumentConverter; + internal Mammoth.Couscous.java.io.File _file; + internal InternalDocumentConverter_Anonymous_11(Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter this_org__zwobble__mammoth__internal__InternalDocumentConverter, Mammoth.Couscous.java.io.File file) { + this._this_org__zwobble__mammoth__internal__InternalDocumentConverter = this_org__zwobble__mammoth__internal__InternalDocumentConverter; + this._file = file; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile zipFile) { + return (this._this_org__zwobble__mammoth__internal__InternalDocumentConverter).extractRawText(Mammoth.Couscous.java.util.Optional.of((this._file).toPath()), zipFile); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal { + internal class InternalDocumentConverter_Anonymous_10 : Mammoth.Couscous.org.zwobble.mammoth.@internal.util.SupplierWithException, Mammoth.Couscous.java.io.IOException> { + internal Mammoth.Couscous.java.io.File _file; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter _this_org__zwobble__mammoth__internal__InternalDocumentConverter; + internal InternalDocumentConverter_Anonymous_10(Mammoth.Couscous.java.io.File file, Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter this_org__zwobble__mammoth__internal__InternalDocumentConverter) { + this._file = file; + this._this_org__zwobble__mammoth__internal__InternalDocumentConverter = this_org__zwobble__mammoth__internal__InternalDocumentConverter; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult get() { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter.withDocxFile>(this._file, new Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter_Anonymous_11(this._this_org__zwobble__mammoth__internal__InternalDocumentConverter, this._file)); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal { + internal class InternalDocumentConverter_Anonymous_12 : Mammoth.Couscous.java.util.function.Function { + public string apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Document arg0) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter.extractRawTextOfChildren(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal { + internal class InternalDocumentConverter_Anonymous_13 : Mammoth.Couscous.java.util.function.Function { + public string apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement node) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter.extractRawText(node); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal { + internal class InternalDocumentConverter_Anonymous_15 : Mammoth.Couscous.java.util.function.Function> { + public Mammoth.Couscous.java.util.List apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.HasChildren arg0) { + return arg0.getChildren(); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal { + internal class InternalDocumentConverter_Anonymous_16 : Mammoth.Couscous.java.util.function.Function { + public string apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Paragraph paragraph) { + return "\n\n"; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal { + internal class InternalDocumentConverter_Anonymous_14 : Mammoth.Couscous.java.util.function.Supplier { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement _node; + internal InternalDocumentConverter_Anonymous_14(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement node) { + this._node = node; + } + public string get() { + Mammoth.Couscous.java.util.List children = ((Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Casts.tryCast(typeof(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.HasChildren), this._node)).map>(new Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter_Anonymous_15())).orElse(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list()); + string suffix = ((Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Casts.tryCast(typeof(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Paragraph), this._node)).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter_Anonymous_16())).orElse(""); + return Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter.extractRawText(children) + suffix; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal { + internal class InternalDocumentConverter_Anonymous_17 : Mammoth.Couscous.java.util.function.Function { + public string apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Text arg0) { + return arg0.getValue(); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal { + internal class InternalDocumentConverter { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtmlOptions _options; + internal InternalDocumentConverter(Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtmlOptions options) { + this._options = options; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult convertToHtml(Mammoth.Couscous.java.io.InputStream stream) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.PassThroughException.unwrap>(new Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter_Anonymous_0(stream, this)); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult convertToHtml(Mammoth.Couscous.java.io.File file) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.PassThroughException.unwrap>(new Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter_Anonymous_2(file, this)); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult convertToHtml(Mammoth.Couscous.java.util.Optional path, Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile zipFile) { + return ((((Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader.readDocument(path, zipFile)).flatMap>(new Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter_Anonymous_7(this))).map>(new Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter_Anonymous_6())).map>(new Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter_Anonymous_5())).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter_Anonymous_4()); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult extractRawText(Mammoth.Couscous.java.io.InputStream stream) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.PassThroughException.unwrap>(new Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter_Anonymous_8(stream, this)); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult extractRawText(Mammoth.Couscous.java.io.File file) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.PassThroughException.unwrap>(new Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter_Anonymous_10(file, this)); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult extractRawText(Mammoth.Couscous.java.util.Optional path, Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile zipFile) { + return (Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader.readDocument(path, zipFile)).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter_Anonymous_12()); + } + public static T withDocxFile(Mammoth.Couscous.java.io.File file, Mammoth.Couscous.java.util.function.Function function) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile zipFile = new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ZippedDocxFile(file); + try { + return function.apply(zipFile); + } finally { + zipFile.close(); + } + } + public static T withDocxFile(Mammoth.Couscous.java.io.InputStream stream, Mammoth.Couscous.java.util.function.Function function) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile zipFile = Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.InMemoryDocxFile.fromStream(stream); + try { + return function.apply(zipFile); + } finally { + zipFile.close(); + } + } + public static string extractRawTextOfChildren(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.HasChildren parent) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter.extractRawText(parent.getChildren()); + } + public static string extractRawText(Mammoth.Couscous.java.util.List nodes) { + return java.lang.String.join("", Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Iterables.lazyMap(nodes, new Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter_Anonymous_13())); + } + public static string extractRawText(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement node) { + return ((Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Casts.tryCast(typeof(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Text), node)).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter_Anonymous_17())).orElseGet(new Mammoth.Couscous.org.zwobble.mammoth.@internal.InternalDocumentConverter_Anonymous_14(node)); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion { + internal class DocumentToHtml_Anonymous_18 : Mammoth.Couscous.java.util.function.Function { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Document _document; + internal DocumentToHtml_Anonymous_18(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Document document) { + this._document = document; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Note apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteReference reference) { + return (((this._document).getNotes()).findNote(reference.getNoteType(), reference.getNoteId())).get(); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion { + internal class DocumentToHtml_Anonymous_19 : Mammoth.Couscous.java.util.function.Function { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml _this_org__zwobble__mammoth__internal__conversion__DocumentToHtml; + internal DocumentToHtml_Anonymous_19(Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml this_org__zwobble__mammoth__internal__conversion__DocumentToHtml) { + this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml = this_org__zwobble__mammoth__internal__conversion__DocumentToHtml; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Note arg0) { + return (this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml).convertToHtml(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion { + internal class DocumentToHtml_Anonymous_20 : Mammoth.Couscous.java.util.function.Function> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml _this_org__zwobble__mammoth__internal__conversion__DocumentToHtml; + internal DocumentToHtml_Anonymous_20(Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml this_org__zwobble__mammoth__internal__conversion__DocumentToHtml) { + this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml = this_org__zwobble__mammoth__internal__conversion__DocumentToHtml; + } + public Mammoth.Couscous.java.lang.Iterable apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement arg0) { + return (this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml).convertToHtml(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion { + internal class DocumentToHtml_Anonymous_22 : Mammoth.Couscous.java.util.function.Supplier { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Paragraph _paragraph; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml _this_org__zwobble__mammoth__internal__conversion__DocumentToHtml; + internal DocumentToHtml_Anonymous_22(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Paragraph paragraph, Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml this_org__zwobble__mammoth__internal__conversion__DocumentToHtml) { + this._paragraph = paragraph; + this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml = this_org__zwobble__mammoth__internal__conversion__DocumentToHtml; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath get() { + if (((this._paragraph).getStyle()).isPresent()) { + ((this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml)._warnings).add("Unrecognised paragraph style: " + (((this._paragraph).getStyle()).get()).describe()); + } + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath.element("p"); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion { + internal class DocumentToHtml_Anonymous_23 : Mammoth.Couscous.java.util.function.Supplier { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Run _run; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml _this_org__zwobble__mammoth__internal__conversion__DocumentToHtml; + internal DocumentToHtml_Anonymous_23(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Run run, Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml this_org__zwobble__mammoth__internal__conversion__DocumentToHtml) { + this._run = run; + this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml = this_org__zwobble__mammoth__internal__conversion__DocumentToHtml; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath get() { + if (((this._run).getStyle()).isPresent()) { + ((this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml)._warnings).add("Unrecognised run style: " + (((this._run).getStyle()).get()).describe()); + } + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath._EMPTY; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion { + internal class DocumentToHtml_Anonymous_25 : Mammoth.Couscous.org.zwobble.mammoth.@internal.util.SupplierWithException { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Image _image; + internal DocumentToHtml_Anonymous_25(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Image image) { + this._image = image; + } + public Mammoth.Couscous.java.io.InputStream get() { + return (this._image).open(); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion { + internal class DocumentToHtml_Anonymous_26 : Mammoth.Couscous.java.util.function.Consumer { + internal Mammoth.Couscous.java.util.Map _attributes; + internal DocumentToHtml_Anonymous_26(Mammoth.Couscous.java.util.Map attributes) { + this._attributes = attributes; + } + public void accept(string altText) { + (this._attributes).put("alt", altText); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion { + internal class DocumentToHtml_Anonymous_24 : Mammoth.Couscous.java.util.function.Function> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Image _image; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml _this_org__zwobble__mammoth__internal__conversion__DocumentToHtml; + internal DocumentToHtml_Anonymous_24(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Image image, Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml this_org__zwobble__mammoth__internal__conversion__DocumentToHtml) { + this._image = image; + this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml = this_org__zwobble__mammoth__internal__conversion__DocumentToHtml; + } + public Mammoth.Couscous.java.util.List apply(string contentType) { + try { + Mammoth.Couscous.java.util.Map attributes = new Mammoth.Couscous.java.util.HashMap(); + string base64 = Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Base64Encoding.streamToBase64(new Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml_Anonymous_25(this._image)); + string src = (("data:" + contentType) + ";base64,") + base64; + attributes.put("src", src); + ((this._image).getAltText()).ifPresent(new Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml_Anonymous_26(attributes)); + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.selfClosingElement("img", attributes)); + } catch (Mammoth.Couscous.java.io.IOException exception) { + ((this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml)._warnings).add(exception.getMessage()); + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(); + } + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion { + internal class DocumentToHtml_Anonymous_21 : Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElementVisitor> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml _this_org__zwobble__mammoth__internal__conversion__DocumentToHtml; + internal DocumentToHtml_Anonymous_21(Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml this_org__zwobble__mammoth__internal__conversion__DocumentToHtml) { + this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml = this_org__zwobble__mammoth__internal__conversion__DocumentToHtml; + } + public Mammoth.Couscous.java.util.List visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Paragraph paragraph) { + Mammoth.Couscous.java.util.List content = (this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml).convertChildrenToHtml(paragraph); + Mammoth.Couscous.java.util.List children = (this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml)._preserveEmptyParagraphs ? Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.cons(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html._FORCE_WRITE, content) : content; + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath mapping = (((this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml)._styleMap).getParagraphHtmlPath(paragraph)).orElseGet(new Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml_Anonymous_22(paragraph, this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml)); + return mapping.wrap(children); + } + public Mammoth.Couscous.java.util.List visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Run run) { + Mammoth.Couscous.java.util.List nodes = (this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml).convertChildrenToHtml(run); + if (run.isStrikethrough()) { + nodes = ((((this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml)._styleMap).getStrikethrough()).orElse(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath.collapsibleElement("s"))).wrap(nodes); + } + if (run.isUnderline()) { + nodes = ((((this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml)._styleMap).getUnderline()).orElse(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath._EMPTY)).wrap(nodes); + } + if (run.getVerticalAlignment() == Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.VerticalAlignment._SUBSCRIPT) { + nodes = Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.collapsibleElement("sub", nodes)); + } + if (run.getVerticalAlignment() == Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.VerticalAlignment._SUPERSCRIPT) { + nodes = Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.collapsibleElement("sup", nodes)); + } + if (run.isItalic()) { + nodes = ((((this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml)._styleMap).getItalic()).orElse(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath.collapsibleElement("em"))).wrap(nodes); + } + if (run.isBold()) { + nodes = ((((this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml)._styleMap).getBold()).orElse(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath.collapsibleElement("strong"))).wrap(nodes); + } + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath mapping = (((this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml)._styleMap).getRunHtmlPath(run)).orElseGet(new Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml_Anonymous_23(run, this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml)); + return mapping.wrap(nodes); + } + public Mammoth.Couscous.java.util.List visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Text text) { + if ((text.getValue()).isEmpty()) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(); + } else { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.text(text.getValue())); + } + } + public Mammoth.Couscous.java.util.List visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Tab tab) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.text("\t")); + } + public Mammoth.Couscous.java.util.List visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.LineBreak lineBreak) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.selfClosingElement("br")); + } + public Mammoth.Couscous.java.util.List visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Table table) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.element("table", (this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml).convertChildrenToHtml(table))); + } + public Mammoth.Couscous.java.util.List visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.TableRow tableRow) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.element("tr", (this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml).convertChildrenToHtml(tableRow))); + } + public Mammoth.Couscous.java.util.List visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.TableCell tableCell) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.element("td", Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.cons(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html._FORCE_WRITE, (this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml).convertChildrenToHtml(tableCell)))); + } + public Mammoth.Couscous.java.util.List visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Hyperlink hyperlink) { + Mammoth.Couscous.java.util.Map attributes = Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map("href", this.generateHref(hyperlink)); + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.collapsibleElement("a", attributes, (this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml).convertChildrenToHtml(hyperlink))); + } + public string generateHref(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Hyperlink hyperlink) { + if ((hyperlink.getHref()).isPresent()) { + return (hyperlink.getHref()).get(); + } else if ((hyperlink.getAnchor()).isPresent()) { + return "#" + (this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml).generateId((hyperlink.getAnchor()).get()); + } else { + return ""; + } + } + public Mammoth.Couscous.java.util.List visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Bookmark bookmark) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.element("a", Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map("id", (this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml).generateId(bookmark.getName())), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html._FORCE_WRITE))); + } + public Mammoth.Couscous.java.util.List visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteReference noteReference) { + ((this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml)._noteReferences).add(noteReference); + string noteAnchor = (this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml).generateNoteHtmlId(noteReference.getNoteType(), noteReference.getNoteId()); + string noteReferenceAnchor = (this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml).generateNoteRefHtmlId(noteReference.getNoteType(), noteReference.getNoteId()); + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.element("sup", Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.element("a", Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map("href", "#" + noteAnchor, "id", noteReferenceAnchor), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.text(("[" + ((this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml)._noteReferences).size()) + "]")))))); + } + public Mammoth.Couscous.java.util.List visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Image image) { + return ((image.getContentType()).map>(new Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml_Anonymous_24(image, this._this_org__zwobble__mammoth__internal__conversion__DocumentToHtml))).orElse(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list()); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion { + internal class DocumentToHtml { + internal string _idPrefix; + internal bool _preserveEmptyParagraphs; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMap _styleMap; + internal Mammoth.Couscous.java.util.List _noteReferences; + internal Mammoth.Couscous.java.util.Set _warnings; + internal DocumentToHtml(Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtmlOptions options) { + this._noteReferences = new Mammoth.Couscous.java.util.ArrayList(); + this._warnings = new Mammoth.Couscous.java.util.HashSet(); + this._idPrefix = options.idPrefix(); + this._preserveEmptyParagraphs = options.shouldPreserveEmptyParagraphs(); + this._styleMap = options.styleMap(); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult> convertToHtml(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Document document, Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtmlOptions options) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml documentConverter = new Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml(options); + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult>(documentConverter.convertToHtml(document), documentConverter._warnings); + } + public static Mammoth.Couscous.java.util.List findNotes(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Document document, Mammoth.Couscous.java.lang.Iterable noteReferences) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.eagerMap(noteReferences, new Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml_Anonymous_18(document)); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult> convertToHtml(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement element, Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtmlOptions options) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml documentConverter = new Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml(options); + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult>(documentConverter.convertToHtml(element), documentConverter._warnings); + } + public Mammoth.Couscous.java.util.List convertToHtml(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Document document) { + Mammoth.Couscous.java.util.List mainBody = this.convertChildrenToHtml(document); + Mammoth.Couscous.java.util.List notes = Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml.findNotes(document, this._noteReferences); + if (notes.isEmpty()) { + return mainBody; + } else { + Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode noteNode = Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.element("ol", Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.eagerMap(notes, new Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml_Anonymous_19(this))); + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.eagerConcat(mainBody, Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(noteNode)); + } + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode convertToHtml(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Note note) { + string id = this.generateNoteHtmlId(note.getNoteType(), note.getId()); + string referenceId = this.generateNoteRefHtmlId(note.getNoteType(), note.getId()); + Mammoth.Couscous.java.util.List noteBody = this.convertToHtml(note.getBody()); + Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode backLink = Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.collapsibleElement("p", Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.text(" "), Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.element("a", Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map("href", "#" + referenceId), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.text("↑"))))); + return Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.element("li", Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map("id", id), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.eagerConcat(noteBody, Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(backLink))); + } + public Mammoth.Couscous.java.util.List convertToHtml(Mammoth.Couscous.java.util.List elements) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.eagerFlatMap(elements, new Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml_Anonymous_20(this)); + } + public Mammoth.Couscous.java.util.List convertChildrenToHtml(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.HasChildren element) { + return this.convertToHtml(element.getChildren()); + } + public Mammoth.Couscous.java.util.List convertToHtml(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement element) { + return element.accept>(new Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtml_Anonymous_21(this)); + } + public string generateNoteHtmlId(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType noteType, string noteId) { + return this.generateId((this.noteTypeToIdFragment(noteType) + "-") + noteId); + } + public string generateNoteRefHtmlId(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType noteType, string noteId) { + return this.generateId((this.noteTypeToIdFragment(noteType) + "-ref-") + noteId); + } + public string noteTypeToIdFragment(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType noteType) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType _couscous_tmp_0 = noteType; + if (_couscous_tmp_0.equals(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType._FOOTNOTE)) { + return "footnote"; + } else if (_couscous_tmp_0.equals(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType._ENDNOTE)) { + return "endnote"; + } else { + throw new Mammoth.Couscous.java.lang.UnsupportedOperationException(); + } + } + public string generateId(string bookmarkName) { + return this._idPrefix + bookmarkName; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion { + internal class DocumentToHtmlOptions { + internal static Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtmlOptions _DEFAULT; + internal string _idPrefix; + internal bool _preserveEmptyParagraphs; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMap _styleMap; + internal bool _disableDefaultStyleMap; + static DocumentToHtmlOptions() { + Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtmlOptions._DEFAULT = new Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtmlOptions("", false, Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMap._EMPTY, false); + } + internal DocumentToHtmlOptions(string idPrefix, bool preserveEmptyParagraphs, Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMap styleMap, bool disableDefaultStyleMap) { + this._idPrefix = idPrefix; + this._preserveEmptyParagraphs = preserveEmptyParagraphs; + this._styleMap = styleMap; + this._disableDefaultStyleMap = disableDefaultStyleMap; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtmlOptions idPrefix(string prefix) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtmlOptions(prefix, this._preserveEmptyParagraphs, this._styleMap, this._disableDefaultStyleMap); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtmlOptions preserveEmptyParagraphs() { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtmlOptions(this._idPrefix, true, this._styleMap, this._disableDefaultStyleMap); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtmlOptions addStyleMap(string styleMap) { + return this.addStyleMap(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.StyleMapParser.parse(styleMap)); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtmlOptions addStyleMap(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMap styleMap) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtmlOptions(this._idPrefix, this._preserveEmptyParagraphs, (this._styleMap).update(styleMap), this._disableDefaultStyleMap); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtmlOptions disableDefaultStyleMap() { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.conversion.DocumentToHtmlOptions(this._idPrefix, this._preserveEmptyParagraphs, this._styleMap, true); + } + public string idPrefix() { + return this._idPrefix; + } + public bool shouldPreserveEmptyParagraphs() { + return this._preserveEmptyParagraphs; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMap styleMap() { + return this._disableDefaultStyleMap ? this._styleMap : (Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.DefaultStyles._DEFAULT_STYLE_MAP).update(this._styleMap); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class Bookmark : Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement { + internal string _name; + internal Bookmark(string name) { + this._name = name; + } + public string getName() { + return this._name; + } + public T accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElementVisitor visitor) { + return visitor.visit(this); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class Document : Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.HasChildren { + internal Mammoth.Couscous.java.util.List _children; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Notes _notes; + internal Document(Mammoth.Couscous.java.util.List children, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Notes notes) { + this._children = children; + this._notes = notes; + } + public Mammoth.Couscous.java.util.List getChildren() { + return this._children; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Notes getNotes() { + return this._notes; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal interface DocumentElement { + T accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElementVisitor visitor); + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal interface DocumentElementVisitor { + T visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Paragraph paragraph); + T visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Run run); + T visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Text text); + T visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Tab tab); + T visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.LineBreak lineBreak); + T visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Table table); + T visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.TableRow tableRow); + T visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.TableCell tableCell); + T visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Hyperlink hyperlink); + T visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Bookmark bookmark); + T visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteReference noteReference); + T visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Image image); + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class Documents { + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal interface HasChildren { + Mammoth.Couscous.java.util.List getChildren(); + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class Hyperlink : Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.HasChildren { + internal Mammoth.Couscous.java.util.Optional _href; + internal Mammoth.Couscous.java.util.Optional _anchor; + internal Mammoth.Couscous.java.util.List _children; + internal Hyperlink(Mammoth.Couscous.java.util.Optional href, Mammoth.Couscous.java.util.Optional anchor, Mammoth.Couscous.java.util.List children) { + this._href = href; + this._anchor = anchor; + this._children = children; + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Hyperlink href(string href, Mammoth.Couscous.java.util.List children) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Hyperlink(Mammoth.Couscous.java.util.Optional.of(href), Mammoth.Couscous.java.util.Optional.empty(), children); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Hyperlink anchor(string anchor, Mammoth.Couscous.java.util.List children) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Hyperlink(Mammoth.Couscous.java.util.Optional.empty(), Mammoth.Couscous.java.util.Optional.of(anchor), children); + } + public Mammoth.Couscous.java.util.Optional getHref() { + return this._href; + } + public Mammoth.Couscous.java.util.Optional getAnchor() { + return this._anchor; + } + public Mammoth.Couscous.java.util.List getChildren() { + return this._children; + } + public T accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElementVisitor visitor) { + return visitor.visit(this); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class Image : Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement { + internal Mammoth.Couscous.java.util.Optional _altText; + internal Mammoth.Couscous.java.util.Optional _contentType; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.util.InputStreamSupplier _open; + internal Image(Mammoth.Couscous.java.util.Optional altText, Mammoth.Couscous.java.util.Optional contentType, Mammoth.Couscous.org.zwobble.mammoth.@internal.util.InputStreamSupplier open) { + this._altText = altText; + this._contentType = contentType; + this._open = open; + } + public Mammoth.Couscous.java.util.Optional getAltText() { + return this._altText; + } + public Mammoth.Couscous.java.util.Optional getContentType() { + return this._contentType; + } + public Mammoth.Couscous.java.io.InputStream open() { + return (this._open).open(); + } + public T accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElementVisitor visitor) { + return visitor.visit(this); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class LineBreak : Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement { + internal static Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.LineBreak _LINE_BREAK; + static LineBreak() { + Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.LineBreak._LINE_BREAK = new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.LineBreak(); + } + public T accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElementVisitor visitor) { + return visitor.visit(this); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class Note { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType _noteType; + internal string _id; + internal Mammoth.Couscous.java.util.List _body; + internal Note(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType noteType, string id, Mammoth.Couscous.java.util.List body) { + this._noteType = noteType; + this._id = id; + this._body = body; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType getNoteType() { + return this._noteType; + } + public string getId() { + return this._id; + } + public Mammoth.Couscous.java.util.List getBody() { + return this._body; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class NoteReference : Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType _noteType; + internal string _noteId; + internal NoteReference(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType noteType, string noteId) { + this._noteType = noteType; + this._noteId = noteId; + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteReference footnoteReference(string noteId) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteReference(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType._FOOTNOTE, noteId); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteReference endnoteReference(string noteId) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteReference(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType._ENDNOTE, noteId); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType getNoteType() { + return this._noteType; + } + public string getNoteId() { + return this._noteId; + } + public T accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElementVisitor visitor) { + return visitor.visit(this); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal enum NoteType { + _FOOTNOTE, _ENDNOTE + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class Notes_Anonymous_27 : Mammoth.Couscous.java.util.function.Function { + public Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Note arg0) { + return arg0.getNoteType(); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class Notes_Anonymous_29 : Mammoth.Couscous.java.util.function.Function { + public string apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Note arg0) { + return arg0.getId(); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class Notes_Anonymous_28 : Mammoth.Couscous.java.util.function.Function, Mammoth.Couscous.java.util.Map> { + public Mammoth.Couscous.java.util.Map apply(Mammoth.Couscous.java.util.List notesOfType) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.toMapWithKey(notesOfType, new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Notes_Anonymous_29()); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class Notes_Anonymous_30 : Mammoth.Couscous.java.util.function.Function, Mammoth.Couscous.java.util.Optional> { + internal string _noteId; + internal Notes_Anonymous_30(string noteId) { + this._noteId = noteId; + } + public Mammoth.Couscous.java.util.Optional apply(Mammoth.Couscous.java.util.Map notesOfType) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.lookup(notesOfType, this._noteId); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class Notes { + internal static Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Notes _EMPTY; + internal Mammoth.Couscous.java.util.Map> _notes; + static Notes() { + Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Notes._EMPTY = new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Notes(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list()); + } + internal Notes(Mammoth.Couscous.java.util.List notes) { + this._notes = Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.eagerMapValues, Mammoth.Couscous.java.util.Map>(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.toMultiMapWithKey(notes, new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Notes_Anonymous_27()), new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Notes_Anonymous_28()); + } + public Mammoth.Couscous.java.util.Optional findNote(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType noteType, string noteId) { + return (Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.lookup>(this._notes, noteType)).flatMap(new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Notes_Anonymous_30(noteId)); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class NumberingLevel { + internal string _levelIndex; + internal bool _isOrdered; + internal NumberingLevel(string levelIndex, bool isOrdered) { + this._levelIndex = levelIndex; + this._isOrdered = isOrdered; + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NumberingLevel ordered(string levelIndex) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NumberingLevel(levelIndex, true); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NumberingLevel unordered(string levelIndex) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NumberingLevel(levelIndex, false); + } + public string getLevelIndex() { + return this._levelIndex; + } + public bool isOrdered() { + return this._isOrdered; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class Paragraph : Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.HasChildren { + internal Mammoth.Couscous.java.util.Optional _style; + internal Mammoth.Couscous.java.util.Optional _numbering; + internal Mammoth.Couscous.java.util.List _children; + internal Paragraph(Mammoth.Couscous.java.util.Optional style, Mammoth.Couscous.java.util.Optional numbering, Mammoth.Couscous.java.util.List children) { + this._style = style; + this._numbering = numbering; + this._children = children; + } + public Mammoth.Couscous.java.util.Optional getStyle() { + return this._style; + } + public Mammoth.Couscous.java.util.Optional getNumbering() { + return this._numbering; + } + public Mammoth.Couscous.java.util.List getChildren() { + return this._children; + } + public T accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElementVisitor visitor) { + return visitor.visit(this); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class Run : Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.HasChildren { + internal bool _isBold; + internal bool _isItalic; + internal bool _isUnderline; + internal bool _isStrikethrough; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.VerticalAlignment _verticalAlignment; + internal Mammoth.Couscous.java.util.Optional _style; + internal Mammoth.Couscous.java.util.List _children; + internal Run(bool isBold, bool isItalic, bool isUnderline, bool isStrikethrough, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.VerticalAlignment verticalAlignment, Mammoth.Couscous.java.util.Optional style, Mammoth.Couscous.java.util.List children) { + this._isBold = isBold; + this._isItalic = isItalic; + this._isUnderline = isUnderline; + this._isStrikethrough = isStrikethrough; + this._verticalAlignment = verticalAlignment; + this._style = style; + this._children = children; + } + public bool isBold() { + return this._isBold; + } + public bool isItalic() { + return this._isItalic; + } + public bool isUnderline() { + return this._isUnderline; + } + public bool isStrikethrough() { + return this._isStrikethrough; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.VerticalAlignment getVerticalAlignment() { + return this._verticalAlignment; + } + public Mammoth.Couscous.java.util.Optional getStyle() { + return this._style; + } + public Mammoth.Couscous.java.util.List getChildren() { + return this._children; + } + public T accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElementVisitor visitor) { + return visitor.visit(this); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class Style_Anonymous_31 : Mammoth.Couscous.java.util.function.Function { + internal string _styleIdDescription; + internal Style_Anonymous_31(string styleIdDescription) { + this._styleIdDescription = styleIdDescription; + } + public string apply(string name) { + return ((name + " (") + this._styleIdDescription) + ")"; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class Style { + internal string _styleId; + internal Mammoth.Couscous.java.util.Optional _name; + internal Style(string styleId, Mammoth.Couscous.java.util.Optional name) { + this._styleId = styleId; + this._name = name; + } + public string getStyleId() { + return this._styleId; + } + public Mammoth.Couscous.java.util.Optional getName() { + return this._name; + } + public string describe() { + string styleIdDescription = "Style ID: " + this._styleId; + return ((this._name).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Style_Anonymous_31(styleIdDescription))).orElse(styleIdDescription); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class Tab : Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement { + internal static Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Tab _TAB; + static Tab() { + Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Tab._TAB = new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Tab(); + } + public T accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElementVisitor visitor) { + return visitor.visit(this); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class Table : Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.HasChildren { + internal Mammoth.Couscous.java.util.List _children; + internal Table(Mammoth.Couscous.java.util.List children) { + this._children = children; + } + public Mammoth.Couscous.java.util.List getChildren() { + return this._children; + } + public T accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElementVisitor visitor) { + return visitor.visit(this); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class TableCell : Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.HasChildren { + internal Mammoth.Couscous.java.util.List _children; + internal TableCell(Mammoth.Couscous.java.util.List children) { + this._children = children; + } + public Mammoth.Couscous.java.util.List getChildren() { + return this._children; + } + public T accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElementVisitor visitor) { + return visitor.visit(this); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class TableRow : Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.HasChildren { + internal Mammoth.Couscous.java.util.List _children; + internal TableRow(Mammoth.Couscous.java.util.List children) { + this._children = children; + } + public Mammoth.Couscous.java.util.List getChildren() { + return this._children; + } + public T accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElementVisitor visitor) { + return visitor.visit(this); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal class Text : Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement { + internal string _value; + internal Text(string value) { + this._value = value; + } + public string getValue() { + return this._value; + } + public T accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElementVisitor visitor) { + return visitor.visit(this); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.documents { + internal enum VerticalAlignment { + _SUPERSCRIPT, _SUBSCRIPT, _BASELINE + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class BodyXmlReader_Anonymous_32 : Mammoth.Couscous.java.util.function.Function, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement> { + public Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement apply(Mammoth.Couscous.java.util.List arg0) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Table(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class BodyXmlReader_Anonymous_33 : Mammoth.Couscous.java.util.function.Function, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement> { + public Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement apply(Mammoth.Couscous.java.util.List arg0) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.TableRow(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class BodyXmlReader_Anonymous_34 : Mammoth.Couscous.java.util.function.Function, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement> { + public Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement apply(Mammoth.Couscous.java.util.List arg0) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.TableCell(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class BodyXmlReader_Anonymous_35 : Mammoth.Couscous.java.util.function.BiFunction, Mammoth.Couscous.java.util.List, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader _this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementLike _properties; + internal BodyXmlReader_Anonymous_35(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader this_org__zwobble__mammoth__internal__docx__BodyXmlReader, Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementLike properties) { + this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader = this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + this._properties = properties; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement apply(Mammoth.Couscous.java.util.Optional style, Mammoth.Couscous.java.util.List children) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Run((this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader).isBold(this._properties), (this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader).isItalic(this._properties), (this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader).isUnderline(this._properties), (this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader).isStrikethrough(this._properties), (this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader).readVerticalAlignment(this._properties), style, children); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class BodyXmlReader_Anonymous_36 : Mammoth.Couscous.java.util.function.Function> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader _this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + internal BodyXmlReader_Anonymous_36(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader this_org__zwobble__mammoth__internal__docx__BodyXmlReader) { + this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader = this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + } + public Mammoth.Couscous.java.util.Optional apply(string arg0) { + return ((this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader)._styles).findCharacterStyleById(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class BodyXmlReader_Anonymous_37 : Mammoth.Couscous.java.util.function.Function { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader _this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + internal BodyXmlReader_Anonymous_37(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader this_org__zwobble__mammoth__internal__docx__BodyXmlReader) { + this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader = this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement arg0) { + return (this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader).readElement(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class BodyXmlReader_Anonymous_38 : Mammoth.Couscous.java.util.function.BiFunction, Mammoth.Couscous.java.util.List, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement> { + internal Mammoth.Couscous.java.util.Optional _numbering; + internal BodyXmlReader_Anonymous_38(Mammoth.Couscous.java.util.Optional numbering) { + this._numbering = numbering; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement apply(Mammoth.Couscous.java.util.Optional style, Mammoth.Couscous.java.util.List children) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Paragraph(style, this._numbering, children); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class BodyXmlReader_Anonymous_39 : Mammoth.Couscous.java.util.function.Function> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader _this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + internal BodyXmlReader_Anonymous_39(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader this_org__zwobble__mammoth__internal__docx__BodyXmlReader) { + this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader = this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + } + public Mammoth.Couscous.java.util.Optional apply(string arg0) { + return ((this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader)._styles).findParagraphStyleById(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class BodyXmlReader_Anonymous_40 : Mammoth.Couscous.java.util.function.Function>> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader _this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + internal string _styleType; + internal Mammoth.Couscous.java.util.function.Function> _findStyleById; + internal BodyXmlReader_Anonymous_40(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader this_org__zwobble__mammoth__internal__docx__BodyXmlReader, string styleType, Mammoth.Couscous.java.util.function.Function> findStyleById) { + this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader = this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + this._styleType = styleType; + this._findStyleById = findStyleById; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult> apply(string styleId) { + return (this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader).findStyleById(this._styleType, styleId, this._findStyleById); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class BodyXmlReader_Anonymous_41 : Mammoth.Couscous.java.util.function.BiFunction> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader _this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + internal BodyXmlReader_Anonymous_41(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader this_org__zwobble__mammoth__internal__docx__BodyXmlReader) { + this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader = this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + } + public Mammoth.Couscous.java.util.Optional apply(string arg0, string arg1) { + return ((this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader)._numbering).findLevel(arg0, arg1); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class BodyXmlReader_Anonymous_42 : Mammoth.Couscous.java.util.function.Function, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement> { + internal Mammoth.Couscous.java.util.Optional _anchor; + internal BodyXmlReader_Anonymous_42(Mammoth.Couscous.java.util.Optional anchor) { + this._anchor = anchor; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement apply(Mammoth.Couscous.java.util.List children) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Hyperlink.anchor((this._anchor).get(), children); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class BodyXmlReader_Anonymous_43 : Mammoth.Couscous.java.util.function.Function, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader _this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + internal Mammoth.Couscous.java.util.Optional _relationshipId; + internal BodyXmlReader_Anonymous_43(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader this_org__zwobble__mammoth__internal__docx__BodyXmlReader, Mammoth.Couscous.java.util.Optional relationshipId) { + this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader = this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + this._relationshipId = relationshipId; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement apply(Mammoth.Couscous.java.util.List children) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Hyperlink.href((((this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader)._relationships).findRelationshipById((this._relationshipId).get())).getTarget(), children); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class BodyXmlReader_Anonymous_44 : Mammoth.Couscous.org.zwobble.mammoth.@internal.util.InputStreamSupplier { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader _this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + internal string _imagePath; + internal BodyXmlReader_Anonymous_44(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader this_org__zwobble__mammoth__internal__docx__BodyXmlReader, string imagePath) { + this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader = this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + this._imagePath = imagePath; + } + public Mammoth.Couscous.java.io.InputStream open() { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFiles.getInputStream((this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader)._file, this._imagePath); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class BodyXmlReader_Anonymous_45 : Mammoth.Couscous.java.util.function.Function { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader _this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + internal Mammoth.Couscous.java.util.Optional _altText; + internal BodyXmlReader_Anonymous_45(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader this_org__zwobble__mammoth__internal__docx__BodyXmlReader, Mammoth.Couscous.java.util.Optional altText) { + this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader = this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + this._altText = altText; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement blip) { + return (this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader).readBlip(blip, this._altText); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class BodyXmlReader_Anonymous_46 : Mammoth.Couscous.org.zwobble.mammoth.@internal.util.InputStreamSupplier { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader _this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + internal string _imagePath; + internal BodyXmlReader_Anonymous_46(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader this_org__zwobble__mammoth__internal__docx__BodyXmlReader, string imagePath) { + this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader = this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + this._imagePath = imagePath; + } + public Mammoth.Couscous.java.io.InputStream open() { + return ((this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader)._fileReader).getInputStream(this._imagePath); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class BodyXmlReader_Anonymous_47 : Mammoth.Couscous.org.zwobble.mammoth.@internal.util.InputStreamSupplier { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader _this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + internal string _imagePath; + internal BodyXmlReader_Anonymous_47(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader this_org__zwobble__mammoth__internal__docx__BodyXmlReader, string imagePath) { + this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader = this_org__zwobble__mammoth__internal__docx__BodyXmlReader; + this._imagePath = imagePath; + } + public Mammoth.Couscous.java.io.InputStream open() { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFiles.getInputStream((this._this_org__zwobble__mammoth__internal__docx__BodyXmlReader)._file, this._imagePath); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class BodyXmlReader { + internal static Mammoth.Couscous.java.util.Set _IMAGE_TYPES_SUPPORTED_BY_BROWSERS; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Styles _styles; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Numbering _numbering; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Relationships _relationships; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypes _contentTypes; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile _file; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.FileReader _fileReader; + static BodyXmlReader() { + Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader._IMAGE_TYPES_SUPPORTED_BY_BROWSERS = Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Sets.set(new string[] {"image/png", "image/gif", "image/jpeg", "image/svg+xml", "image/tiff"}); + } + internal BodyXmlReader(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Styles styles, Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Numbering numbering, Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Relationships relationships, Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypes contentTypes, Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile file, Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.FileReader fileReader) { + this._styles = styles; + this._numbering = numbering; + this._relationships = relationships; + this._contentTypes = contentTypes; + this._file = file; + this._fileReader = fileReader; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult readElement(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + string _couscous_tmp_1 = element.getName(); + if (_couscous_tmp_1.Equals("w:t")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult.success(new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Text(element.innerText())); + } else if (_couscous_tmp_1.Equals("w:r")) { + return this.readRun(element); + } else if (_couscous_tmp_1.Equals("w:p")) { + return this.readParagraph(element); + } else if (_couscous_tmp_1.Equals("w:tab")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult.success(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Tab._TAB); + } else if (_couscous_tmp_1.Equals("w:br")) { + return this.readBreak(element); + } else if (_couscous_tmp_1.Equals("w:tbl")) { + return (this.readElements(element.children())).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader_Anonymous_32()); + } else if (_couscous_tmp_1.Equals("w:tr")) { + return (this.readElements(element.children())).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader_Anonymous_33()); + } else if (_couscous_tmp_1.Equals("w:tc")) { + return (this.readElements(element.children())).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader_Anonymous_34()); + } else if (_couscous_tmp_1.Equals("w:hyperlink")) { + return this.readHyperlink(element); + } else if (_couscous_tmp_1.Equals("w:bookmarkStart")) { + return this.readBookmark(element); + } else if (_couscous_tmp_1.Equals("w:footnoteReference")) { + return this.readNoteReference(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType._FOOTNOTE, element); + } else if (_couscous_tmp_1.Equals("w:endnoteReference")) { + return this.readNoteReference(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType._ENDNOTE, element); + } else if (_couscous_tmp_1.Equals("w:pict")) { + return this.readPict(element); + } else if (_couscous_tmp_1.Equals("v:imagedata")) { + return this.readImagedata(element); + } else if (_couscous_tmp_1.Equals("wp:inline")) { + return this.readInline(element); + } else if (_couscous_tmp_1.Equals("wp:anchor")) { + return this.readInline(element); + } else if (_couscous_tmp_1.Equals("w:ins")) { + return this.readElements(element.children()); + } else if (_couscous_tmp_1.Equals("w:smartTag")) { + return this.readElements(element.children()); + } else if (_couscous_tmp_1.Equals("w:drawing")) { + return this.readElements(element.children()); + } else if (_couscous_tmp_1.Equals("v:roundrect")) { + return this.readElements(element.children()); + } else if (_couscous_tmp_1.Equals("v:shape")) { + return this.readElements(element.children()); + } else if (_couscous_tmp_1.Equals("v:textbox")) { + return this.readElements(element.children()); + } else if (_couscous_tmp_1.Equals("w:txbxContent")) { + return this.readElements(element.children()); + } else if (_couscous_tmp_1.Equals("office-word:wrap")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult._EMPTY_SUCCESS; + } else if (_couscous_tmp_1.Equals("v:shadow")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult._EMPTY_SUCCESS; + } else if (_couscous_tmp_1.Equals("v:shapetype")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult._EMPTY_SUCCESS; + } else if (_couscous_tmp_1.Equals("w:bookmarkEnd")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult._EMPTY_SUCCESS; + } else if (_couscous_tmp_1.Equals("w:sectPr")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult._EMPTY_SUCCESS; + } else if (_couscous_tmp_1.Equals("w:proofErr")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult._EMPTY_SUCCESS; + } else if (_couscous_tmp_1.Equals("w:lastRenderedPageBreak")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult._EMPTY_SUCCESS; + } else if (_couscous_tmp_1.Equals("w:commentRangeStart")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult._EMPTY_SUCCESS; + } else if (_couscous_tmp_1.Equals("w:commentRangeEnd")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult._EMPTY_SUCCESS; + } else if (_couscous_tmp_1.Equals("w:commentReference")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult._EMPTY_SUCCESS; + } else if (_couscous_tmp_1.Equals("w:del")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult._EMPTY_SUCCESS; + } else if (_couscous_tmp_1.Equals("w:footnoteRef")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult._EMPTY_SUCCESS; + } else if (_couscous_tmp_1.Equals("w:endnoteRef")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult._EMPTY_SUCCESS; + } else if (_couscous_tmp_1.Equals("w:pPr")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult._EMPTY_SUCCESS; + } else if (_couscous_tmp_1.Equals("w:rPr")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult._EMPTY_SUCCESS; + } else if (_couscous_tmp_1.Equals("w:tblPr")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult._EMPTY_SUCCESS; + } else if (_couscous_tmp_1.Equals("w:tblGrid")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult._EMPTY_SUCCESS; + } else if (_couscous_tmp_1.Equals("w:tcPr")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult._EMPTY_SUCCESS; + } else { + string warning = "An unrecognised element was ignored: " + element.getName(); + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult.emptyWithWarning(warning); + } + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult readRun(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementLike properties = element.findChildOrEmpty("w:rPr"); + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult.map>(this.readRunStyle(properties), this.readElements(element.children()), new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader_Anonymous_35(this, properties)); + } + public bool isBold(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementLike properties) { + return properties.hasChild("w:b"); + } + public bool isItalic(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementLike properties) { + return properties.hasChild("w:i"); + } + public bool isUnderline(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementLike properties) { + return properties.hasChild("w:u"); + } + public bool isStrikethrough(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementLike properties) { + return properties.hasChild("w:strike"); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.VerticalAlignment readVerticalAlignment(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementLike properties) { + string verticalAlignment = (this.readVal(properties, "w:vertAlign")).orElse(""); + string _couscous_tmp_2 = verticalAlignment; + if (_couscous_tmp_2.Equals("superscript")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.VerticalAlignment._SUPERSCRIPT; + } else if (_couscous_tmp_2.Equals("subscript")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.VerticalAlignment._SUBSCRIPT; + } else { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.VerticalAlignment._BASELINE; + } + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult> readRunStyle(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementLike properties) { + return this.readStyle(properties, "w:rStyle", "Run", new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader_Anonymous_36(this)); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult readElements(Mammoth.Couscous.java.lang.Iterable nodes) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult.flatMap(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Iterables.lazyFilter(nodes, typeof(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement)), new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader_Anonymous_37(this)); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult readParagraph(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementLike properties = element.findChildOrEmpty("w:pPr"); + Mammoth.Couscous.java.util.Optional numbering = this.readNumbering(properties); + return (Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult.map>(this.readParagraphStyle(properties), this.readElements(element.children()), new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader_Anonymous_38(numbering))).appendExtra(); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult> readParagraphStyle(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementLike properties) { + return this.readStyle(properties, "w:pStyle", "Paragraph", new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader_Anonymous_39(this)); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult> readStyle(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementLike properties, string styleTagName, string styleType, Mammoth.Couscous.java.util.function.Function> findStyleById) { + return ((this.readVal(properties, styleTagName)).map>>(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader_Anonymous_40(this, styleType, findStyleById))).orElse(Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult.empty()); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult> findStyleById(string styleType, string styleId, Mammoth.Couscous.java.util.function.Function> findStyleById) { + Mammoth.Couscous.java.util.Optional style = findStyleById.apply(styleId); + if (style.isPresent()) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult.success>(style); + } else { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult>(Mammoth.Couscous.java.util.Optional.of(new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Style(styleId, Mammoth.Couscous.java.util.Optional.empty())), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(((styleType + " style with ID ") + styleId) + " was referenced but not defined in the document")); + } + } + public Mammoth.Couscous.java.util.Optional readNumbering(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementLike properties) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementLike numberingProperties = properties.findChildOrEmpty("w:numPr"); + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Optionals.flatMap(this.readVal(numberingProperties, "w:numId"), this.readVal(numberingProperties, "w:ilvl"), new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader_Anonymous_41(this)); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult readBreak(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + string breakType = (element.getAttributeOrNone("w:type")).orElse(""); + if (breakType.Equals("")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult.success(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.LineBreak._LINE_BREAK); + } else { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult.emptyWithWarning("Unsupported break type: " + breakType); + } + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult readHyperlink(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + Mammoth.Couscous.java.util.Optional relationshipId = element.getAttributeOrNone("r:id"); + Mammoth.Couscous.java.util.Optional anchor = element.getAttributeOrNone("w:anchor"); + Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult childrenResult = this.readElements(element.children()); + if (relationshipId.isPresent()) { + return childrenResult.map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader_Anonymous_43(this, relationshipId)); + } else if (anchor.isPresent()) { + return childrenResult.map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader_Anonymous_42(anchor)); + } else { + return childrenResult; + } + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult readBookmark(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + string name = element.getAttribute("w:name"); + if (name.Equals("_GoBack")) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult._EMPTY_SUCCESS; + } else { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult.success(new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Bookmark(name)); + } + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult readNoteReference(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType noteType, Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + string noteId = element.getAttribute("w:id"); + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult.success(new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteReference(noteType, noteId)); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult readPict(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + return (this.readElements(element.children())).toExtra(); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult readImagedata(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + Mammoth.Couscous.java.util.Optional title = element.getAttributeOrNone("o:title"); + string relationshipId = element.getAttribute("r:id"); + string imagePath = this.relationshipIdToDocxPath(relationshipId); + return this.readImage(imagePath, title, new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader_Anonymous_44(this, imagePath)); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult readInline(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + Mammoth.Couscous.java.util.Optional altText = (element.findChildOrEmpty("wp:docPr")).getAttributeOrNone("descr"); + Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementList blips = ((((element.findChildren("a:graphic")).findChildren("a:graphicData")).findChildren("pic:pic")).findChildren("pic:blipFill")).findChildren("a:blip"); + return this.readBlips(blips, altText); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult readBlips(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementList blips, Mammoth.Couscous.java.util.Optional altText) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult.flatMap(blips, new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader_Anonymous_45(this, altText)); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult readBlip(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement blip, Mammoth.Couscous.java.util.Optional altText) { + Mammoth.Couscous.java.util.Optional embedRelationshipId = blip.getAttributeOrNone("r:embed"); + Mammoth.Couscous.java.util.Optional linkRelationshipId = blip.getAttributeOrNone("r:link"); + if (embedRelationshipId.isPresent()) { + string imagePath = this.relationshipIdToDocxPath(embedRelationshipId.get()); + return this.readImage(imagePath, altText, new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader_Anonymous_47(this, imagePath)); + } else if (linkRelationshipId.isPresent()) { + string imagePath = ((this._relationships).findRelationshipById(linkRelationshipId.get())).getTarget(); + return this.readImage(imagePath, altText, new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader_Anonymous_46(this, imagePath)); + } else { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult._EMPTY_SUCCESS; + } + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult readImage(string imagePath, Mammoth.Couscous.java.util.Optional altText, Mammoth.Couscous.org.zwobble.mammoth.@internal.util.InputStreamSupplier open) { + Mammoth.Couscous.java.util.Optional contentType = (this._contentTypes).findContentType(imagePath); + Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Image image = new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Image(altText, contentType, open); + string contentTypeString = contentType.orElse("(unknown)"); + if ((Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader._IMAGE_TYPES_SUPPORTED_BY_BROWSERS).contains(contentTypeString)) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult.success(image); + } else { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult.withWarning(image, ("Image of type " + contentTypeString) + " is unlikely to display in web browsers"); + } + } + public string relationshipIdToDocxPath(string relationshipId) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Relationship relationship = (this._relationships).findRelationshipById(relationshipId); + return "word/" + Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Strings.trimLeft(relationship.getTarget(), 47); + } + public Mammoth.Couscous.java.util.Optional readVal(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementLike element, string name) { + return (element.findChildOrEmpty(name)).getAttributeOrNone("w:val"); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class ContentTypes_Anonymous_48 : Mammoth.Couscous.java.util.function.Function { + public string apply(string imageType) { + return "image/" + imageType; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class ContentTypes { + internal static Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypes _DEFAULT; + internal static Mammoth.Couscous.java.util.Map _imageExtensions; + internal Mammoth.Couscous.java.util.Map _extensionDefaults; + internal Mammoth.Couscous.java.util.Map _overrides; + static ContentTypes() { + Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypes._DEFAULT = new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypes(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map(), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map()); + Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypes._imageExtensions = ((((((((Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.builder()).put("png", "png")).put("gif", "gif")).put("jpeg", "jpeg")).put("jpg", "jpeg")).put("bmp", "bmp")).put("tif", "tiff")).put("tiff", "tiff")).build(); + } + internal ContentTypes(Mammoth.Couscous.java.util.Map extensionDefaults, Mammoth.Couscous.java.util.Map overrides) { + this._extensionDefaults = extensionDefaults; + this._overrides = overrides; + } + public Mammoth.Couscous.java.util.Optional findContentType(string path) { + if ((this._overrides).containsKey(path)) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.lookup(this._overrides, path); + } else { + string extension = Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Paths.getExtension(path); + if ((this._extensionDefaults).containsKey(extension)) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.lookup(this._extensionDefaults, extension); + } else { + return (Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.lookup(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypes._imageExtensions, extension.ToLower())).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypes_Anonymous_48()); + } + } + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class ContentTypesXml_Anonymous_49 : Mammoth.Couscous.java.util.function.Function> { + public Mammoth.Couscous.java.util.Map__Entry apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement arg0) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypesXml.readDefault(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class ContentTypesXml_Anonymous_50 : Mammoth.Couscous.java.util.function.Function> { + public Mammoth.Couscous.java.util.Map__Entry apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement arg0) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypesXml.readOverride(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class ContentTypesXml { + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypes readContentTypesXmlElement(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypes(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypesXml.readDefaults(element.findChildren("content-types:Default")), Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypesXml.readOverrides(element.findChildren("content-types:Override"))); + } + public static Mammoth.Couscous.java.util.Map readDefaults(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementList children) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.toMap(children, new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypesXml_Anonymous_49()); + } + public static Mammoth.Couscous.java.util.Map__Entry readDefault(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.entry(element.getAttribute("Extension"), element.getAttribute("ContentType")); + } + public static Mammoth.Couscous.java.util.Map readOverrides(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementList children) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.toMap(children, new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypesXml_Anonymous_50()); + } + public static Mammoth.Couscous.java.util.Map__Entry readOverride(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.entry(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Strings.trimLeft(element.getAttribute("PartName"), 47), element.getAttribute("ContentType")); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal interface DocumentReader__BodyReaders { + Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader forName(string name); + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class DocumentReader_Anonymous_51 : Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader__BodyReaders { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile _zipFile; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Styles _styles; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Numbering _numbering; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypes _contentTypes; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.FileReader _fileReader; + internal DocumentReader_Anonymous_51(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile zipFile, Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Styles styles, Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Numbering numbering, Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypes contentTypes, Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.FileReader fileReader) { + this._zipFile = zipFile; + this._styles = styles; + this._numbering = numbering; + this._contentTypes = contentTypes; + this._fileReader = fileReader; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader forName(string name) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Relationships relationships = Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader.readRelationships(this._zipFile, name); + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader(this._styles, this._numbering, relationships, this._contentTypes, this._zipFile, this._fileReader); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class DocumentReader_Anonymous_52 : Mammoth.Couscous.java.util.function.Function> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader__BodyReaders _bodyReaders; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile _zipFile; + internal DocumentReader_Anonymous_52(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader__BodyReaders bodyReaders, Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile zipFile) { + this._bodyReaders = bodyReaders; + this._zipFile = zipFile; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Notes notes) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentXmlReader reader = new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentXmlReader((this._bodyReaders).forName("document"), notes); + return reader.readElement(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader.parseOfficeXml(this._zipFile, "word/document.xml")); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class DocumentReader_Anonymous_53 : Mammoth.Couscous.java.util.function.Function, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Notes> { + public Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Notes apply(Mammoth.Couscous.java.util.List arg0) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Notes(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class DocumentReader_Anonymous_54 : Mammoth.Couscous.java.util.function.Function>> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader__BodyReaders _bodyReaders; + internal DocumentReader_Anonymous_54(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader__BodyReaders bodyReaders) { + this._bodyReaders = bodyReaders; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult> apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement arg0) { + return (Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NotesXmlReader.footnote((this._bodyReaders).forName("footnotes"))).readElement(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class DocumentReader_Anonymous_55 : Mammoth.Couscous.java.util.function.Function>> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader__BodyReaders _bodyReaders; + internal DocumentReader_Anonymous_55(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader__BodyReaders bodyReaders) { + this._bodyReaders = bodyReaders; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult> apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement arg0) { + return (Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NotesXmlReader.endnote((this._bodyReaders).forName("endnotes"))).readElement(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class DocumentReader_Anonymous_56 : Mammoth.Couscous.java.util.function.BiFunction, Mammoth.Couscous.java.util.List, Mammoth.Couscous.java.util.List> { + public Mammoth.Couscous.java.util.List apply(Mammoth.Couscous.java.util.List arg0, Mammoth.Couscous.java.util.List arg1) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.eagerConcat(arg0, arg1); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class DocumentReader_Anonymous_57 : Mammoth.Couscous.java.util.function.Function { + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Styles apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement arg0) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.StylesXml.readStylesXmlElement(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class DocumentReader_Anonymous_58 : Mammoth.Couscous.java.util.function.Function { + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Numbering apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement arg0) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NumberingXml.readNumberingXmlElement(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class DocumentReader_Anonymous_59 : Mammoth.Couscous.java.util.function.Function { + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypes apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement arg0) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypesXml.readContentTypesXmlElement(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class DocumentReader_Anonymous_60 : Mammoth.Couscous.java.util.function.Function { + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Relationships apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement arg0) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.RelationshipsXml.readRelationshipsXmlElement(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class DocumentReader_Anonymous_62 : Mammoth.Couscous.java.util.function.Function { + public Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement apply(Mammoth.Couscous.java.io.InputStream arg0) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.OfficeXml.parseXml(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class DocumentReader_Anonymous_61 : Mammoth.Couscous.org.zwobble.mammoth.@internal.util.SupplierWithException, Mammoth.Couscous.java.io.IOException> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile _zipFile; + internal string _name; + internal DocumentReader_Anonymous_61(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile zipFile, string name) { + this._zipFile = zipFile; + this._name = name; + } + public Mammoth.Couscous.java.util.Optional get() { + return ((this._zipFile).tryGetInputStream(this._name)).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader_Anonymous_62()); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class DocumentReader_Anonymous_63 : Mammoth.Couscous.java.util.function.Supplier { + internal string _name; + internal DocumentReader_Anonymous_63(string name) { + this._name = name; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.util.PassThroughException get() { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.util.PassThroughException(new Mammoth.Couscous.java.io.IOException("Missing entry in file: " + this._name)); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class DocumentReader { + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult readDocument(Mammoth.Couscous.java.util.Optional path, Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile zipFile) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Styles styles = Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader.readStyles(zipFile); + Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Numbering numbering = Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader.readNumbering(zipFile); + Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypes contentTypes = Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader.readContentTypes(zipFile); + Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.FileReader fileReader = new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.PathRelativeFileReader(path); + Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader__BodyReaders bodyReaders = new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader_Anonymous_51(zipFile, styles, numbering, contentTypes, fileReader); + return (Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader.readNotes(zipFile, bodyReaders)).flatMap(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader_Anonymous_52(bodyReaders, zipFile)); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult readNotes(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile file, Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader__BodyReaders bodyReaders) { + return (Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult.map, Mammoth.Couscous.java.util.List, Mammoth.Couscous.java.util.List>(((Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader.tryParseOfficeXml(file, "word/footnotes.xml")).map>>(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader_Anonymous_54(bodyReaders))).orElse(Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult.success>(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list())), ((Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader.tryParseOfficeXml(file, "word/endnotes.xml")).map>>(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader_Anonymous_55(bodyReaders))).orElse(Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult.success>(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list())), new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader_Anonymous_56())).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader_Anonymous_53()); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Styles readStyles(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile file) { + return ((Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader.tryParseOfficeXml(file, "word/styles.xml")).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader_Anonymous_57())).orElse(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Styles._EMPTY); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Numbering readNumbering(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile file) { + return ((Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader.tryParseOfficeXml(file, "word/numbering.xml")).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader_Anonymous_58())).orElse(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Numbering._EMPTY); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypes readContentTypes(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile file) { + return ((Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader.tryParseOfficeXml(file, "[Content_Types].xml")).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader_Anonymous_59())).orElse(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ContentTypes._DEFAULT); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Relationships readRelationships(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile zipFile, string name) { + return ((Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader.tryParseOfficeXml(zipFile, ("word/_rels/" + name) + ".xml.rels")).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader_Anonymous_60())).orElse(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Relationships._EMPTY); + } + public static Mammoth.Couscous.java.util.Optional tryParseOfficeXml(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile zipFile, string name) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.PassThroughException.wrap>(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader_Anonymous_61(zipFile, name)); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement parseOfficeXml(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile zipFile, string name) { + return (Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader.tryParseOfficeXml(zipFile, name)).orElseThrow(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentReader_Anonymous_63(name)); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class DocumentXmlReader_Anonymous_64 : Mammoth.Couscous.java.util.function.Function, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Document> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentXmlReader _this_org__zwobble__mammoth__internal__docx__DocumentXmlReader; + internal DocumentXmlReader_Anonymous_64(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentXmlReader this_org__zwobble__mammoth__internal__docx__DocumentXmlReader) { + this._this_org__zwobble__mammoth__internal__docx__DocumentXmlReader = this_org__zwobble__mammoth__internal__docx__DocumentXmlReader; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Document apply(Mammoth.Couscous.java.util.List children) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Document(children, (this._this_org__zwobble__mammoth__internal__docx__DocumentXmlReader)._notes); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class DocumentXmlReader { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader _bodyReader; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Notes _notes; + internal DocumentXmlReader(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader bodyReader, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Notes notes) { + this._bodyReader = bodyReader; + this._notes = notes; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult readElement(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement body = element.findChild("w:body"); + return (((this._bodyReader).readElements(body.children())).toResult()).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocumentXmlReader_Anonymous_64(this)); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal interface DocxFile : Mammoth.Couscous.java.io.Closeable { + Mammoth.Couscous.java.util.Optional tryGetInputStream(string name); + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class DocxFiles_Anonymous_65 : Mammoth.Couscous.java.util.function.Supplier { + internal string _name; + internal DocxFiles_Anonymous_65(string name) { + this._name = name; + } + public Mammoth.Couscous.java.io.IOException get() { + return new Mammoth.Couscous.java.io.IOException("Missing entry in file: " + this._name); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class DocxFiles { + public static Mammoth.Couscous.java.io.InputStream getInputStream(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFile file, string name) { + return (file.tryGetInputStream(name)).orElseThrow(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.DocxFiles_Anonymous_65(name)); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal interface FileReader { + Mammoth.Couscous.java.io.InputStream getInputStream(string uri); + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class NotesXmlReader_Anonymous_66 : Mammoth.Couscous.java.util.function.Predicate { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NotesXmlReader _this_org__zwobble__mammoth__internal__docx__NotesXmlReader; + internal NotesXmlReader_Anonymous_66(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NotesXmlReader this_org__zwobble__mammoth__internal__docx__NotesXmlReader) { + this._this_org__zwobble__mammoth__internal__docx__NotesXmlReader = this_org__zwobble__mammoth__internal__docx__NotesXmlReader; + } + public bool test(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement arg0) { + return (this._this_org__zwobble__mammoth__internal__docx__NotesXmlReader).isNoteElement(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class NotesXmlReader_Anonymous_67 : Mammoth.Couscous.java.util.function.Function> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NotesXmlReader _this_org__zwobble__mammoth__internal__docx__NotesXmlReader; + internal NotesXmlReader_Anonymous_67(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NotesXmlReader this_org__zwobble__mammoth__internal__docx__NotesXmlReader) { + this._this_org__zwobble__mammoth__internal__docx__NotesXmlReader = this_org__zwobble__mammoth__internal__docx__NotesXmlReader; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement arg0) { + return (this._this_org__zwobble__mammoth__internal__docx__NotesXmlReader).readNoteElement(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class NotesXmlReader_Anonymous_68 : Mammoth.Couscous.java.util.function.Function { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NotesXmlReader _this_org__zwobble__mammoth__internal__docx__NotesXmlReader; + internal NotesXmlReader_Anonymous_68(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NotesXmlReader this_org__zwobble__mammoth__internal__docx__NotesXmlReader) { + this._this_org__zwobble__mammoth__internal__docx__NotesXmlReader = this_org__zwobble__mammoth__internal__docx__NotesXmlReader; + } + public bool apply(string type) { + return !(this._this_org__zwobble__mammoth__internal__docx__NotesXmlReader).isSeparatorType(type); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class NotesXmlReader_Anonymous_69 : Mammoth.Couscous.java.util.function.Function, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Note> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NotesXmlReader _this_org__zwobble__mammoth__internal__docx__NotesXmlReader; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement _element; + internal NotesXmlReader_Anonymous_69(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NotesXmlReader this_org__zwobble__mammoth__internal__docx__NotesXmlReader, Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + this._this_org__zwobble__mammoth__internal__docx__NotesXmlReader = this_org__zwobble__mammoth__internal__docx__NotesXmlReader; + this._element = element; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Note apply(Mammoth.Couscous.java.util.List children) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Note((this._this_org__zwobble__mammoth__internal__docx__NotesXmlReader)._noteType, (this._element).getAttribute("w:id"), children); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class NotesXmlReader { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader _bodyReader; + internal string _tagName; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType _noteType; + internal NotesXmlReader(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader bodyReader, string tagName, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType noteType) { + this._bodyReader = bodyReader; + this._tagName = tagName; + this._noteType = noteType; + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NotesXmlReader footnote(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader bodyReader) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NotesXmlReader(bodyReader, "footnote", Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType._FOOTNOTE); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NotesXmlReader endnote(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.BodyXmlReader bodyReader) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NotesXmlReader(bodyReader, "endnote", Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NoteType._ENDNOTE); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult> readElement(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + Mammoth.Couscous.java.lang.Iterable elements = Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Iterables.lazyFilter(element.findChildren("w:" + this._tagName), new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NotesXmlReader_Anonymous_66(this)); + return Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult.flatMap(elements, new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NotesXmlReader_Anonymous_67(this)); + } + public bool isNoteElement(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + return ((element.getAttributeOrNone("w:type")).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NotesXmlReader_Anonymous_68(this))).orElse(true); + } + public bool isSeparatorType(string type) { + return type.Equals("continuationSeparator") || type.Equals("separator"); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult readNoteElement(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + return (((this._bodyReader).readElements(element.children())).toResult()).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NotesXmlReader_Anonymous_69(this, element)); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class Numbering_Anonymous_70 : Mammoth.Couscous.java.util.function.Function, Mammoth.Couscous.java.util.Optional> { + internal string _level; + internal Numbering_Anonymous_70(string level) { + this._level = level; + } + public Mammoth.Couscous.java.util.Optional apply(Mammoth.Couscous.java.util.Map levels) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.lookup(levels, this._level); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class Numbering { + internal static Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Numbering _EMPTY; + internal Mammoth.Couscous.java.util.Map> _numbering; + static Numbering() { + Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Numbering._EMPTY = new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Numbering(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map>()); + } + internal Numbering(Mammoth.Couscous.java.util.Map> numbering) { + this._numbering = numbering; + } + public Mammoth.Couscous.java.util.Optional findLevel(string numId, string level) { + return (Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.lookup>(this._numbering, numId)).flatMap(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Numbering_Anonymous_70(level)); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class NumberingXml_Anonymous_71 : Mammoth.Couscous.java.util.function.Function>> { + public Mammoth.Couscous.java.util.Map__Entry> apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement arg0) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NumberingXml.readAbstractNum(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class NumberingXml_Anonymous_72 : Mammoth.Couscous.java.util.function.Function> { + public Mammoth.Couscous.java.util.Map__Entry apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement arg0) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NumberingXml.readAbstractNumLevel(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class NumberingXml_Anonymous_73 : Mammoth.Couscous.java.util.function.Function>> { + internal Mammoth.Couscous.java.util.Map> _abstractNums; + internal NumberingXml_Anonymous_73(Mammoth.Couscous.java.util.Map> abstractNums) { + this._abstractNums = abstractNums; + } + public Mammoth.Couscous.java.util.Map__Entry> apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement numElement) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NumberingXml.readNum(numElement, this._abstractNums); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class NumberingXml { + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Numbering readNumberingXmlElement(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + Mammoth.Couscous.java.util.Map> abstractNums = Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NumberingXml.readAbstractNums(element.findChildren("w:abstractNum")); + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Numbering(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NumberingXml.readNums(element.findChildren("w:num"), abstractNums)); + } + public static Mammoth.Couscous.java.util.Map> readAbstractNums(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementList children) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.toMap>(children, new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NumberingXml_Anonymous_71()); + } + public static Mammoth.Couscous.java.util.Map__Entry> readAbstractNum(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + string abstractNumId = element.getAttribute("w:abstractNumId"); + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.entry>(abstractNumId, Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NumberingXml.readAbstractNumLevels(element)); + } + public static Mammoth.Couscous.java.util.Map readAbstractNumLevels(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.toMap(element.findChildren("w:lvl"), new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NumberingXml_Anonymous_72()); + } + public static Mammoth.Couscous.java.util.Map__Entry readAbstractNumLevel(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + string levelIndex = element.getAttribute("w:ilvl"); + Mammoth.Couscous.java.util.Optional numFmt = (element.findChildOrEmpty("w:numFmt")).getAttributeOrNone("w:val"); + bool isOrdered = !numFmt.equals(Mammoth.Couscous.java.util.Optional.of("bullet")); + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.entry(levelIndex, new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NumberingLevel(levelIndex, isOrdered)); + } + public static Mammoth.Couscous.java.util.Map> readNums(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementList numElements, Mammoth.Couscous.java.util.Map> abstractNums) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.toMap>(numElements, new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.NumberingXml_Anonymous_73(abstractNums)); + } + public static Mammoth.Couscous.java.util.Map__Entry> readNum(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement numElement, Mammoth.Couscous.java.util.Map> abstractNums) { + string numId = numElement.getAttribute("w:numId"); + string abstractNumId = (numElement.findChild("w:abstractNumId")).getAttribute("w:val"); + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.entry>(numId, (Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.lookup>(abstractNums, abstractNumId)).get()); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class OfficeXml_Anonymous_75 : Mammoth.Couscous.java.util.function.Function> { + public Mammoth.Couscous.java.lang.Iterable apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlNode arg0) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.OfficeXml.collapseAlternateContent(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class OfficeXml_Anonymous_74 : Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlNodeVisitor> { + public Mammoth.Couscous.java.util.List visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + if ((element.getName()).Equals("mc:AlternateContent")) { + return (element.findChild("mc:Fallback")).getChildren(); + } else { + Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement collapsedElement = new Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement(element.getName(), element.getAttributes(), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.eagerFlatMap(element.children(), new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.OfficeXml_Anonymous_75())); + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(collapsedElement); + } + } + public Mammoth.Couscous.java.util.List visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlTextNode textNode) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(textNode); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class OfficeXml { + internal static Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.NamespacePrefixes _XML_NAMESPACES; + static OfficeXml() { + Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.OfficeXml._XML_NAMESPACES = (((((((((((Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.NamespacePrefixes.builder()).put("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main")).put("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing")).put("a", "http://schemas.openxmlformats.org/drawingml/2006/main")).put("pic", "http://schemas.openxmlformats.org/drawingml/2006/picture")).put("content-types", "http://schemas.openxmlformats.org/package/2006/content-types")).put("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships")).put("relationships", "http://schemas.openxmlformats.org/package/2006/relationships")).put("v", "urn:schemas-microsoft-com:vml")).put("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006")).put("office-word", "urn:schemas-microsoft-com:office:word")).build(); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement parseXml(Mammoth.Couscous.java.io.InputStream inputStream) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.XmlParser parser = new Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.XmlParser(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.OfficeXml._XML_NAMESPACES); + return (Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement) (Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.OfficeXml.collapseAlternateContent(parser.parseStream(inputStream))).get(0); + } + public static Mammoth.Couscous.java.util.List collapseAlternateContent(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlNode node) { + return node.accept>(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.OfficeXml_Anonymous_74()); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class PathRelativeFileReader : Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.FileReader { + internal Mammoth.Couscous.java.util.Optional _path; + internal PathRelativeFileReader(Mammoth.Couscous.java.util.Optional path) { + this._path = path; + } + public Mammoth.Couscous.java.io.InputStream getInputStream(string uri) { + try { + Mammoth.Couscous.java.util.Optional absoluteUri = Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.PathRelativeFileReader.asAbsoluteUri(uri); + if (absoluteUri.isPresent()) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.PathRelativeFileReader.open(absoluteUri.get()); + } else if ((this._path).isPresent()) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.PathRelativeFileReader.open((((this._path).get()).toUri()).resolve(uri)); + } else { + throw new Mammoth.Couscous.java.io.IOException("path of document is unknown, but is required for relative URI"); + } + } catch (Mammoth.Couscous.java.io.IOException exception) { + throw new Mammoth.Couscous.java.io.IOException((("could not open external image '" + uri) + "': ") + exception.getMessage()); + } + } + public static Mammoth.Couscous.java.io.InputStream open(Mammoth.Couscous.java.net.URI uri) { + return (uri.toURL()).openStream(); + } + public static Mammoth.Couscous.java.util.Optional asAbsoluteUri(string uriString) { + try { + Mammoth.Couscous.java.net.URI uri = new Mammoth.Couscous.java.net.URI(uriString); + return uri.isAbsolute() ? Mammoth.Couscous.java.util.Optional.of(uri) : Mammoth.Couscous.java.util.Optional.empty(); + } catch (Mammoth.Couscous.java.net.URISyntaxException exception) { + return Mammoth.Couscous.java.util.Optional.empty(); + } + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class ReadResult_Anonymous_76 : Mammoth.Couscous.java.util.function.Function> { + public Mammoth.Couscous.java.lang.Iterable apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult result) { + return result._elements; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class ReadResult_Anonymous_77 : Mammoth.Couscous.java.util.function.Function> { + public Mammoth.Couscous.java.lang.Iterable apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult result) { + return result._extra; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class ReadResult_Anonymous_78 : Mammoth.Couscous.java.util.function.Function> { + public Mammoth.Couscous.java.lang.Iterable apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult result) { + return result._warnings; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class ReadResult { + internal static Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult _EMPTY_SUCCESS; + internal Mammoth.Couscous.java.util.List _elements; + internal Mammoth.Couscous.java.util.List _extra; + internal Mammoth.Couscous.java.lang.Iterable _warnings; + static ReadResult() { + Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult._EMPTY_SUCCESS = Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult.success(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list()); + } + internal ReadResult(Mammoth.Couscous.java.util.List elements, Mammoth.Couscous.java.util.List extra, Mammoth.Couscous.java.lang.Iterable warnings) { + this._elements = elements; + this._extra = extra; + this._warnings = warnings; + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult flatMap(Mammoth.Couscous.java.lang.Iterable iterable, Mammoth.Couscous.java.util.function.Function function) { + Mammoth.Couscous.java.util.List results = Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.eagerMap(iterable, function); + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.eagerFlatMap(results, new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult_Anonymous_76()), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.eagerFlatMap(results, new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult_Anonymous_77()), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Iterables.lazyFlatMap(results, new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult_Anonymous_78())); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult map(Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult first, Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult second, Mammoth.Couscous.java.util.function.BiFunction, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement> function) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(function.apply(first.getValue(), second._elements)), second._extra, Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Iterables.lazyConcat(first.getWarnings(), second._warnings)); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult success(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement element) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult.success(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(element)); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult success(Mammoth.Couscous.java.util.List elements) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult(elements, Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list()); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult emptyWithWarning(string warning) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(warning)); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult withWarning(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement element, string warning) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(element), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(warning)); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult map(Mammoth.Couscous.java.util.function.Function, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.DocumentElement> function) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(function.apply(this._elements)), this._extra, this._warnings); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult toExtra() { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.eagerConcat(this._extra, this._elements), this._warnings); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult appendExtra() { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.ReadResult(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.eagerConcat(this._elements, this._extra), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(), this._warnings); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult> toResult() { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult>(this._elements, this._warnings); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class Relationship { + internal string _target; + internal Relationship(string target) { + this._target = target; + } + public string getTarget() { + return this._target; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class Relationships_Anonymous_79 : Mammoth.Couscous.java.util.function.Supplier { + internal string _id; + internal Relationships_Anonymous_79(string id) { + this._id = id; + } + public Mammoth.Couscous.java.lang.RuntimeException get() { + return new Mammoth.Couscous.java.lang.RuntimeException(("Could not find relationship '" + this._id) + "'"); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class Relationships { + internal static Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Relationships _EMPTY; + internal Mammoth.Couscous.java.util.Map _relationships; + static Relationships() { + Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Relationships._EMPTY = new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Relationships(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map()); + } + internal Relationships(Mammoth.Couscous.java.util.Map relationships) { + this._relationships = relationships; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Relationship findRelationshipById(string id) { + return (Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.lookup(this._relationships, id)).orElseThrow(new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Relationships_Anonymous_79(id)); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class RelationshipsXml_Anonymous_80 : Mammoth.Couscous.java.util.function.Function> { + public Mammoth.Couscous.java.util.Map__Entry apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement arg0) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.RelationshipsXml.readRelationship(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class RelationshipsXml { + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Relationships readRelationshipsXmlElement(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Relationships(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.toMap(element.findChildren("relationships:Relationship"), new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.RelationshipsXml_Anonymous_80())); + } + public static Mammoth.Couscous.java.util.Map__Entry readRelationship(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.entry(element.getAttribute("Id"), new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Relationship(element.getAttribute("Target"))); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class Styles { + internal static Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Styles _EMPTY; + internal Mammoth.Couscous.java.util.Map _paragraphStyles; + internal Mammoth.Couscous.java.util.Map _characterStyles; + static Styles() { + Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Styles._EMPTY = new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Styles(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map(), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map()); + } + internal Styles(Mammoth.Couscous.java.util.Map paragraphStyles, Mammoth.Couscous.java.util.Map characterStyles) { + this._paragraphStyles = paragraphStyles; + this._characterStyles = characterStyles; + } + public Mammoth.Couscous.java.util.Optional findParagraphStyleById(string id) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.lookup(this._paragraphStyles, id); + } + public Mammoth.Couscous.java.util.Optional findCharacterStyleById(string id) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.lookup(this._characterStyles, id); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class StylesXml_Anonymous_81 : Mammoth.Couscous.java.util.function.Predicate { + internal string _styleType; + internal StylesXml_Anonymous_81(string styleType) { + this._styleType = styleType; + } + public bool test(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement styleElement) { + return (styleElement.getAttribute("w:type")).Equals(this._styleType); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class StylesXml_Anonymous_82 : Mammoth.Couscous.java.util.function.Function> { + public Mammoth.Couscous.java.util.Map__Entry apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement arg0) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.StylesXml.readStyle(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class StylesXml { + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Styles readStylesXmlElement(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementList styleElements = element.findChildren("w:style"); + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.Styles(Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.StylesXml.readStyles(styleElements, "paragraph"), Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.StylesXml.readStyles(styleElements, "character")); + } + public static Mammoth.Couscous.java.util.Map readStyles(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementList styleElements, string styleType) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.toMap(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Iterables.lazyFilter(styleElements, new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.StylesXml_Anonymous_81(styleType)), new Mammoth.Couscous.org.zwobble.mammoth.@internal.docx.StylesXml_Anonymous_82()); + } + public static Mammoth.Couscous.java.util.Map__Entry readStyle(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + string styleId = element.getAttribute("w:styleId"); + Mammoth.Couscous.java.util.Optional styleName = (element.findChildOrEmpty("w:name")).getAttributeOrNone("w:val"); + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.entry(styleId, new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Style(styleId, styleName)); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.html { + internal class Html_Anonymous_83 : Mammoth.Couscous.java.util.function.Consumer { + internal Mammoth.Couscous.java.lang.StringBuilder _builder; + internal Html_Anonymous_83(Mammoth.Couscous.java.lang.StringBuilder builder) { + this._builder = builder; + } + public void accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode node) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlWriter.write(node, this._builder); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.html { + internal class Html_Anonymous_84 : Mammoth.Couscous.java.util.function.Function> { + public Mammoth.Couscous.java.lang.Iterable apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode node) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.stripEmpty(node); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.html { + internal class Html_Anonymous_85 : Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode__Mapper> { + public Mammoth.Couscous.java.util.List visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlElement element) { + Mammoth.Couscous.java.util.List children = Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.stripEmpty(element.getChildren()); + if (children.isEmpty()) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(); + } else { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(new Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlElement(element.getTagNames(), element.getAttributes(), children, element.isCollapsible())); + } + } + public Mammoth.Couscous.java.util.List visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlSelfClosingElement element) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(element); + } + public Mammoth.Couscous.java.util.List visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlTextNode node) { + if ((node.getValue()).isEmpty()) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(); + } else { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(node); + } + } + public Mammoth.Couscous.java.util.List visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlForceWrite forceWrite) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(forceWrite); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.html { + internal class Html_Anonymous_86 : Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode__Mapper { + public Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlElement element) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlElement(element.getTagNames(), element.getAttributes(), Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.collapse(element.getChildren()), element.isCollapsible()); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlSelfClosingElement element) { + return element; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlTextNode node) { + return node; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlForceWrite forceWrite) { + return forceWrite; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.html { + internal class Html_Anonymous_87 : Mammoth.Couscous.java.util.function.Function> { + public Mammoth.Couscous.java.util.Optional apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode last) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Casts.tryCast(typeof(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlElement), last); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.html { + internal class Html_Anonymous_88 : Mammoth.Couscous.java.util.function.BiFunction { + public bool apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlElement last, Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlElement next) { + if (next.isCollapsible() && Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.isMatch(last, next)) { + Mammoth.Couscous.java.util.Iterator _couscous_tmp_4 = (next.getChildren()).iterator(); + while (_couscous_tmp_4.hasNext()) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode child = _couscous_tmp_4.next(); + Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.collapsingAdd(last.getChildren(), child); + } + return true; + } else { + return false; + } + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.html { + internal class Html { + internal static Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode _FORCE_WRITE; + static Html() { + Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html._FORCE_WRITE = Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlForceWrite._FORCE_WRITE; + } + public static string write(Mammoth.Couscous.java.util.List nodes) { + Mammoth.Couscous.java.lang.StringBuilder builder = new Mammoth.Couscous.java.lang.StringBuilder(); + nodes.forEach(new Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html_Anonymous_83(builder)); + return builder.toString(); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode text(string value) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlTextNode(value); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode element(string tagName) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.element(tagName, Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list()); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode element(string tagName, Mammoth.Couscous.java.util.Map attributes) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.element(tagName, attributes, Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list()); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode element(string tagName, Mammoth.Couscous.java.util.List children) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.element(tagName, Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map(), children); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode element(string tagName, Mammoth.Couscous.java.util.Map attributes, Mammoth.Couscous.java.util.List children) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlElement(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(tagName), attributes, children, false); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode collapsibleElement(string tagName) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.collapsibleElement(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(tagName)); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode collapsibleElement(Mammoth.Couscous.java.util.List tagNames) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.collapsibleElement(tagNames, Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map(), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list()); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode collapsibleElement(string tagName, Mammoth.Couscous.java.util.List children) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.collapsibleElement(tagName, Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map(), children); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode collapsibleElement(string tagName, Mammoth.Couscous.java.util.Map attributes, Mammoth.Couscous.java.util.List children) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.collapsibleElement(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(tagName), attributes, children); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode collapsibleElement(Mammoth.Couscous.java.util.List tagNames, Mammoth.Couscous.java.util.Map attributes, Mammoth.Couscous.java.util.List children) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlElement(tagNames, attributes, children, true); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode selfClosingElement(string tagName) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.selfClosingElement(tagName, Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map()); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode selfClosingElement(string tagName, Mammoth.Couscous.java.util.Map attributes) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlSelfClosingElement(tagName, attributes); + } + public static Mammoth.Couscous.java.util.List stripEmpty(Mammoth.Couscous.java.util.List nodes) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.eagerFlatMap(nodes, new Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html_Anonymous_84()); + } + public static Mammoth.Couscous.java.util.List stripEmpty(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode node) { + return node.accept>(new Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html_Anonymous_85()); + } + public static Mammoth.Couscous.java.util.List collapse(Mammoth.Couscous.java.util.List nodes) { + Mammoth.Couscous.java.util.List collapsed = new Mammoth.Couscous.java.util.ArrayList(); + Mammoth.Couscous.java.util.Iterator _couscous_tmp_3 = nodes.iterator(); + while (_couscous_tmp_3.hasNext()) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode node = _couscous_tmp_3.next(); + Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.collapsingAdd(collapsed, node); + } + return collapsed; + } + public static void collapsingAdd(Mammoth.Couscous.java.util.List collapsed, Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode node) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode collapsedNode = Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.collapse(node); + if (!Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html.tryCollapse(collapsed, collapsedNode)) { + collapsed.add(collapsedNode); + } + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode collapse(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode node) { + return node.accept(new Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html_Anonymous_86()); + } + public static bool tryCollapse(Mammoth.Couscous.java.util.List collapsed, Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode node) { + return (Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Optionals.map((Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.tryGetLast(collapsed)).flatMap(new Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html_Anonymous_87()), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Casts.tryCast(typeof(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlElement), node), new Mammoth.Couscous.org.zwobble.mammoth.@internal.html.Html_Anonymous_88())).orElse(false); + } + public static bool isMatch(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlElement first, Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlElement second) { + return (second.getTagNames()).contains(first.getTagName()) && (first.getAttributes()).equals(second.getAttributes()); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.html { + internal class HtmlElement : Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode { + internal Mammoth.Couscous.java.util.List _tagNames; + internal Mammoth.Couscous.java.util.Map _attributes; + internal Mammoth.Couscous.java.util.List _children; + internal bool _collapsible; + internal HtmlElement(Mammoth.Couscous.java.util.List tagNames, Mammoth.Couscous.java.util.Map attributes, Mammoth.Couscous.java.util.List children, bool collapsible) { + this._tagNames = tagNames; + this._attributes = attributes; + this._children = children; + this._collapsible = collapsible; + } + public Mammoth.Couscous.java.util.List getTagNames() { + return this._tagNames; + } + public string getTagName() { + return (this._tagNames).get(0); + } + public Mammoth.Couscous.java.util.Map getAttributes() { + return this._attributes; + } + public Mammoth.Couscous.java.util.List getChildren() { + return this._children; + } + public bool isCollapsible() { + return this._collapsible; + } + public void accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode__Visitor visitor) { + visitor.visit(this); + } + public T accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode__Mapper visitor) { + return visitor.visit(this); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.html { + internal class HtmlForceWrite : Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode { + internal static Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlForceWrite _FORCE_WRITE; + static HtmlForceWrite() { + Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlForceWrite._FORCE_WRITE = new Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlForceWrite(); + } + public void accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode__Visitor visitor) { + visitor.visit(this); + } + public T accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode__Mapper visitor) { + return visitor.visit(this); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.html { + internal interface HtmlNode__Visitor { + void visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlElement element); + void visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlSelfClosingElement element); + void visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlTextNode node); + void visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlForceWrite forceWrite); + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.html { + internal interface HtmlNode__Mapper { + T visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlElement element); + T visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlSelfClosingElement element); + T visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlTextNode node); + T visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlForceWrite forceWrite); + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.html { + internal interface HtmlNode { + void accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode__Visitor visitor); + T accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode__Mapper visitor); + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.html { + internal class HtmlSelfClosingElement : Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode { + internal string _tagName; + internal Mammoth.Couscous.java.util.Map _attributes; + internal HtmlSelfClosingElement(string tagName, Mammoth.Couscous.java.util.Map attributes) { + this._tagName = tagName; + this._attributes = attributes; + } + public string getTagName() { + return this._tagName; + } + public Mammoth.Couscous.java.util.Map getAttributes() { + return this._attributes; + } + public void accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode__Visitor visitor) { + visitor.visit(this); + } + public T accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode__Mapper visitor) { + return visitor.visit(this); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.html { + internal class HtmlTextNode : Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode { + internal string _value; + internal HtmlTextNode(string value) { + this._value = value; + } + public string getValue() { + return this._value; + } + public void accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode__Visitor visitor) { + visitor.visit(this); + } + public T accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode__Mapper visitor) { + return visitor.visit(this); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.html { + internal class HtmlWriter_Anonymous_90 : Mammoth.Couscous.java.util.function.Consumer { + internal Mammoth.Couscous.java.lang.StringBuilder _builder; + internal HtmlWriter_Anonymous_90(Mammoth.Couscous.java.lang.StringBuilder builder) { + this._builder = builder; + } + public void accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode child) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlWriter.write(child, this._builder); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.html { + internal class HtmlWriter_Anonymous_89 : Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode__Visitor { + internal Mammoth.Couscous.java.lang.StringBuilder _builder; + internal HtmlWriter_Anonymous_89(Mammoth.Couscous.java.lang.StringBuilder builder) { + this._builder = builder; + } + public void visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlElement element) { + ((this._builder).append("<")).append(element.getTagName()); + Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlWriter.generateAttributes(element.getAttributes(), this._builder); + (this._builder).append(">"); + (element.getChildren()).forEach(new Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlWriter_Anonymous_90(this._builder)); + (((this._builder).append(""); + } + public void visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlSelfClosingElement element) { + ((this._builder).append("<")).append(element.getTagName()); + Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlWriter.generateAttributes(element.getAttributes(), this._builder); + (this._builder).append(" />"); + } + public void visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlTextNode node) { + (this._builder).append(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlWriter.escapeText(node.getValue())); + } + public void visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlForceWrite forceWrite) { + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.html { + internal class HtmlWriter_Anonymous_91 : Mammoth.Couscous.java.util.function.Function, string> { + public string apply(Mammoth.Couscous.java.util.Map__Entry arg0) { + return arg0.getKey(); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.html { + internal class HtmlWriter { + public static void write(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlNode node, Mammoth.Couscous.java.lang.StringBuilder builder) { + node.accept(new Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlWriter_Anonymous_89(builder)); + } + public static void generateAttributes(Mammoth.Couscous.java.util.Map attributes, Mammoth.Couscous.java.lang.StringBuilder builder) { + Mammoth.Couscous.java.util.Iterator> _couscous_tmp_5 = (Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.orderedBy, string>(attributes.entrySet(), new Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlWriter_Anonymous_91())).iterator(); + while (_couscous_tmp_5.hasNext()) { + Mammoth.Couscous.java.util.Map__Entry attribute = _couscous_tmp_5.next(); + ((((builder.append(" ")).append(attribute.getKey())).append("=\"")).append(Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlWriter.escapeAttributeValue(attribute.getValue()))).append("\""); + } + } + public static string escapeText(string text) { + return ((text.replace("&", "&")).replace("<", "<")).replace(">", ">"); + } + public static string escapeAttributeValue(string value) { + return (Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlWriter.escapeText(value)).replace("\"", """); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.results { + internal static class InternalResult_Anonymous_92 { + } +} +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.results { + internal class InternalResult_Anonymous_92 : Mammoth.Couscous.java.util.function.Function, R> { + public R apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult result) { + return result._value; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.results { + internal static class InternalResult_Anonymous_93 { + } +} +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.results { + internal class InternalResult_Anonymous_93 : Mammoth.Couscous.java.util.function.Function, Mammoth.Couscous.java.lang.Iterable> { + public Mammoth.Couscous.java.lang.Iterable apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult result) { + return result._warnings; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.results { + internal static class InternalResult_Anonymous_94 { + } +} +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.results { + internal class InternalResult_Anonymous_94 : Mammoth.Couscous.org.zwobble.mammoth.Result { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult _this_org__zwobble__mammoth__internal__results__InternalResult; + internal Mammoth.Couscous.java.util.Set _warnings; + internal InternalResult_Anonymous_94(Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult this_org__zwobble__mammoth__internal__results__InternalResult, Mammoth.Couscous.java.util.Set warnings) { + this._this_org__zwobble__mammoth__internal__results__InternalResult = this_org__zwobble__mammoth__internal__results__InternalResult; + this._warnings = warnings; + } + public T getValue() { + return (this._this_org__zwobble__mammoth__internal__results__InternalResult)._value; + } + public Mammoth.Couscous.java.util.Set getWarnings() { + return this._warnings; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.results { + internal static class InternalResult { + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult> flatMap(Mammoth.Couscous.java.lang.Iterable iterable, Mammoth.Couscous.java.util.function.Function> function) { + Mammoth.Couscous.java.util.List> results = Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.eagerMap>(iterable, function); + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult>(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.eagerMap, R>(results, new Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult_Anonymous_92()), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Iterables.lazyFlatMap, string>(results, new Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult_Anonymous_93())); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult map(Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult first, Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult second, Mammoth.Couscous.java.util.function.BiFunction function) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult(function.apply(first._value, second._value), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Iterables.lazyConcat(first._warnings, second._warnings)); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult> empty() { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult>(Mammoth.Couscous.java.util.Optional.empty(), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list()); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult success(T value) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult(value, Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list()); + } + } +} +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.results { + internal class InternalResult { + internal T _value; + internal Mammoth.Couscous.java.lang.Iterable _warnings; + internal InternalResult(T value, Mammoth.Couscous.java.lang.Iterable warnings) { + this._value = value; + this._warnings = warnings; + } + public T getValue() { + return this._value; + } + public Mammoth.Couscous.java.lang.Iterable getWarnings() { + return this._warnings; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult map(Mammoth.Couscous.java.util.function.Function function) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult(function.apply(this._value), this._warnings); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult flatMap(Mammoth.Couscous.java.util.function.Function> function) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult intermediateResult = function.apply(this._value); + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult(intermediateResult._value, Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Iterables.lazyConcat(this._warnings, intermediateResult._warnings)); + } + public Mammoth.Couscous.org.zwobble.mammoth.Result toResult() { + Mammoth.Couscous.java.util.Set warnings = Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Sets.toSet(this._warnings); + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.results.InternalResult_Anonymous_94(this, warnings); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal class DefaultStyles { + internal static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMap _DEFAULT_STYLE_MAP; + static DefaultStyles() { + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.DefaultStyles._DEFAULT_STYLE_MAP = Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.StyleMapParser.parseStyleMappings(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(new string[] {"p.Heading1 => h1:fresh", "p.Heading2 => h2:fresh", "p.Heading3 => h3:fresh", "p.Heading4 => h4:fresh", "p[style-name='Heading 1'] => h1:fresh", "p[style-name='Heading 2'] => h2:fresh", "p[style-name='Heading 3'] => h3:fresh", "p[style-name='Heading 4'] => h4:fresh", "p[style-name='heading 1'] => h1:fresh", "p[style-name='heading 2'] => h2:fresh", "p[style-name='heading 3'] => h3:fresh", "p[style-name='heading 4'] => h4:fresh", "p[style-name='heading 4'] => h4:fresh", "r[style-name='Strong'] => strong", "p[style-name='footnote text'] => p", "r[style-name='footnote reference'] =>", "p[style-name='endnote text'] => p", "r[style-name='endnote reference'] =>", "p[style-name='Footnote'] => p", "r[style-name='Footnote anchor'] =>", "p[style-name='Endnote'] => p", "r[style-name='Endnote anchor'] =>", "p:unordered-list(1) => ul > li:fresh", "p:unordered-list(2) => ul|ol > li > ul > li:fresh", "p:unordered-list(3) => ul|ol > li > ul|ol > li > ul > li:fresh", "p:unordered-list(4) => ul|ol > li > ul|ol > li > ul|ol > li > ul > li:fresh", "p:unordered-list(5) => ul|ol > li > ul|ol > li > ul|ol > li > ul|ol > li > ul > li:fresh", "p:ordered-list(1) => ol > li:fresh", "p:ordered-list(2) => ul|ol > li > ol > li:fresh", "p:ordered-list(3) => ul|ol > li > ul|ol > li > ol > li:fresh", "p:ordered-list(4) => ul|ol > li > ul|ol > li > ul|ol > li > ol > li:fresh", "p:ordered-list(5) => ul|ol > li > ul|ol > li > ul|ol > li > ul|ol > li > ol > li:fresh", "r[style-name='Hyperlink'] =>", "p[style-name='Normal'] => p:fresh"})); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal interface DocumentElementMatcher { + bool matches(T element); + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal class DocumentElementMatching_Anonymous_95 : Mammoth.Couscous.java.util.function.Function { + public string apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Style arg0) { + return arg0.getStyleId(); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal class DocumentElementMatching_Anonymous_96 : Mammoth.Couscous.java.util.function.BiPredicate { + public bool test(string arg0, string arg1) { + return arg0.Equals(arg1); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal class DocumentElementMatching_Anonymous_97 : Mammoth.Couscous.java.util.function.Function> { + public Mammoth.Couscous.java.util.Optional apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Style arg0) { + return arg0.getName(); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal class DocumentElementMatching_Anonymous_98 : Mammoth.Couscous.java.util.function.BiPredicate { + public bool test(string arg0, string arg1) { + return arg0.equalsIgnoreCase(arg1); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal static class DocumentElementMatching_Anonymous_100 { + } +} +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal class DocumentElementMatching_Anonymous_100 : Mammoth.Couscous.java.util.function.Function { + internal Mammoth.Couscous.java.util.function.BiPredicate _areEqual; + internal T _requiredValue; + internal DocumentElementMatching_Anonymous_100(Mammoth.Couscous.java.util.function.BiPredicate areEqual, T requiredValue) { + this._areEqual = areEqual; + this._requiredValue = requiredValue; + } + public bool apply(T actualValue) { + return (this._areEqual).test(this._requiredValue, actualValue); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal static class DocumentElementMatching_Anonymous_99 { + } +} +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal class DocumentElementMatching_Anonymous_99 : Mammoth.Couscous.java.util.function.Function { + internal Mammoth.Couscous.java.util.Optional _actual; + internal Mammoth.Couscous.java.util.function.BiPredicate _areEqual; + internal DocumentElementMatching_Anonymous_99(Mammoth.Couscous.java.util.Optional actual, Mammoth.Couscous.java.util.function.BiPredicate areEqual) { + this._actual = actual; + this._areEqual = areEqual; + } + public bool apply(T requiredValue) { + return ((this._actual).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.DocumentElementMatching_Anonymous_100(this._areEqual, requiredValue))).orElse(false); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal class DocumentElementMatching { + public static bool matchesStyle(Mammoth.Couscous.java.util.Optional styleId, Mammoth.Couscous.java.util.Optional styleName, Mammoth.Couscous.java.util.Optional style) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.DocumentElementMatching.matchesStyleId(styleId, style) && Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.DocumentElementMatching.matchesStyleName(styleName, style); + } + public static bool matchesStyleId(Mammoth.Couscous.java.util.Optional styleId, Mammoth.Couscous.java.util.Optional style) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.DocumentElementMatching.matches(styleId, style.map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.DocumentElementMatching_Anonymous_95()), new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.DocumentElementMatching_Anonymous_96()); + } + public static bool matchesStyleName(Mammoth.Couscous.java.util.Optional styleName, Mammoth.Couscous.java.util.Optional style) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.DocumentElementMatching.matches(styleName, style.flatMap(new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.DocumentElementMatching_Anonymous_97()), new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.DocumentElementMatching_Anonymous_98()); + } + public static bool matches(Mammoth.Couscous.java.util.Optional required, Mammoth.Couscous.java.util.Optional actual, Mammoth.Couscous.java.util.function.BiPredicate areEqual) { + return (required.map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.DocumentElementMatching_Anonymous_99(actual, areEqual))).orElse(true); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal class HtmlPath { + internal static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath _EMPTY; + internal Mammoth.Couscous.java.util.List _elements; + static HtmlPath() { + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath._EMPTY = new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list()); + } + internal HtmlPath(Mammoth.Couscous.java.util.List elements) { + this._elements = elements; + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath element(string tagName) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath.element(tagName, Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map()); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath element(string tagName, Mammoth.Couscous.java.util.Map attributes) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPathElement(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(tagName), attributes, false))); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath collapsibleElement(string tagName) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath.collapsibleElement(tagName, Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map()); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath collapsibleElement(Mammoth.Couscous.java.util.List tagNames) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath.collapsibleElement(tagNames, Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map()); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath collapsibleElement(string tagName, Mammoth.Couscous.java.util.Map attributes) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath.collapsibleElement(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(tagName), attributes); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath collapsibleElement(Mammoth.Couscous.java.util.List tagNames, Mammoth.Couscous.java.util.Map attributes) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPathElement(tagNames, attributes, true))); + } + public Mammoth.Couscous.java.util.List wrap(Mammoth.Couscous.java.util.List nodes) { + Mammoth.Couscous.java.util.Iterator _couscous_tmp_6 = (Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.reversed(this._elements)).iterator(); + while (_couscous_tmp_6.hasNext()) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPathElement element = _couscous_tmp_6.next(); + nodes = element.wrap(nodes); + } + return nodes; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal class HtmlPathElement { + internal Mammoth.Couscous.java.util.List _tagNames; + internal Mammoth.Couscous.java.util.Map _attributes; + internal bool _isCollapsible; + internal HtmlPathElement(Mammoth.Couscous.java.util.List tagNames, Mammoth.Couscous.java.util.Map attributes, bool isCollapsible) { + this._tagNames = tagNames; + this._attributes = attributes; + this._isCollapsible = isCollapsible; + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPathElement fresh(string tagName) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPathElement(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(tagName), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map(), false); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPathElement collapsible(string tagName) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPathElement.collapsible(tagName, Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map()); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPathElement collapsible(string tagName, Mammoth.Couscous.java.util.Map attributes) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPathElement(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(tagName), attributes, true); + } + public Mammoth.Couscous.java.util.List wrap(Mammoth.Couscous.java.util.List nodes) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list(new Mammoth.Couscous.org.zwobble.mammoth.@internal.html.HtmlElement(this._tagNames, this._attributes, nodes, this._isCollapsible)); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal class ParagraphMatcher_Anonymous_101 : Mammoth.Couscous.java.util.function.BiPredicate { + public bool test(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NumberingLevel first, Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NumberingLevel second) { + return first.isOrdered() == second.isOrdered() && (first.getLevelIndex()).equalsIgnoreCase(second.getLevelIndex()); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal class ParagraphMatcher : Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.DocumentElementMatcher { + internal static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.ParagraphMatcher _ANY; + internal Mammoth.Couscous.java.util.Optional _styleId; + internal Mammoth.Couscous.java.util.Optional _styleName; + internal Mammoth.Couscous.java.util.Optional _numbering; + static ParagraphMatcher() { + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.ParagraphMatcher._ANY = new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.ParagraphMatcher(Mammoth.Couscous.java.util.Optional.empty(), Mammoth.Couscous.java.util.Optional.empty(), Mammoth.Couscous.java.util.Optional.empty()); + } + internal ParagraphMatcher(Mammoth.Couscous.java.util.Optional styleId, Mammoth.Couscous.java.util.Optional styleName, Mammoth.Couscous.java.util.Optional numbering) { + this._styleId = styleId; + this._styleName = styleName; + this._numbering = numbering; + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.ParagraphMatcher styleId(string styleId) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.ParagraphMatcher(Mammoth.Couscous.java.util.Optional.of(styleId), Mammoth.Couscous.java.util.Optional.empty(), Mammoth.Couscous.java.util.Optional.empty()); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.ParagraphMatcher styleName(string styleName) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.ParagraphMatcher(Mammoth.Couscous.java.util.Optional.empty(), Mammoth.Couscous.java.util.Optional.of(styleName), Mammoth.Couscous.java.util.Optional.empty()); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.ParagraphMatcher orderedList(string level) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.ParagraphMatcher(Mammoth.Couscous.java.util.Optional.empty(), Mammoth.Couscous.java.util.Optional.empty(), Mammoth.Couscous.java.util.Optional.of(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NumberingLevel.ordered(level))); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.ParagraphMatcher unorderedList(string level) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.ParagraphMatcher(Mammoth.Couscous.java.util.Optional.empty(), Mammoth.Couscous.java.util.Optional.empty(), Mammoth.Couscous.java.util.Optional.of(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NumberingLevel.unordered(level))); + } + public bool matches(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Paragraph paragraph) { + return this.matchesStyle(paragraph) && this.matchesNumbering(paragraph); + } + public bool matchesStyle(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Paragraph paragraph) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.DocumentElementMatching.matchesStyle(this._styleId, this._styleName, paragraph.getStyle()); + } + public bool matchesNumbering(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Paragraph paragraph) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.DocumentElementMatching.matches(this._numbering, paragraph.getNumbering(), new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.ParagraphMatcher_Anonymous_101()); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal class RunMatcher : Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.DocumentElementMatcher { + internal static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.RunMatcher _ANY; + internal Mammoth.Couscous.java.util.Optional _styleId; + internal Mammoth.Couscous.java.util.Optional _styleName; + static RunMatcher() { + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.RunMatcher._ANY = new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.RunMatcher(Mammoth.Couscous.java.util.Optional.empty(), Mammoth.Couscous.java.util.Optional.empty()); + } + internal RunMatcher(Mammoth.Couscous.java.util.Optional styleId, Mammoth.Couscous.java.util.Optional styleName) { + this._styleId = styleId; + this._styleName = styleName; + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.RunMatcher styleId(string styleId) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.RunMatcher(Mammoth.Couscous.java.util.Optional.of(styleId), Mammoth.Couscous.java.util.Optional.empty()); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.RunMatcher styleName(string styleName) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.RunMatcher(Mammoth.Couscous.java.util.Optional.empty(), Mammoth.Couscous.java.util.Optional.of(styleName)); + } + public bool matches(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Run run) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.DocumentElementMatching.matchesStyle(this._styleId, this._styleName, run.getStyle()); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal class StyleMap_Anonymous_102 : Mammoth.Couscous.java.util.function.Function, Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath> { + public Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapping arg0) { + return arg0.getHtmlPath(); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal class StyleMap_Anonymous_103 : Mammoth.Couscous.java.util.function.Predicate> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Paragraph _paragraph; + internal StyleMap_Anonymous_103(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Paragraph paragraph) { + this._paragraph = paragraph; + } + public bool test(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapping styleMapping) { + return styleMapping.matches(this._paragraph); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal class StyleMap_Anonymous_104 : Mammoth.Couscous.java.util.function.Function, Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath> { + public Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapping arg0) { + return arg0.getHtmlPath(); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal class StyleMap_Anonymous_105 : Mammoth.Couscous.java.util.function.Predicate> { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Run _run; + internal StyleMap_Anonymous_105(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Run run) { + this._run = run; + } + public bool test(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapping styleMapping) { + return styleMapping.matches(this._run); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal class StyleMap { + internal static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMap _EMPTY; + internal Mammoth.Couscous.java.util.Optional _bold; + internal Mammoth.Couscous.java.util.Optional _italic; + internal Mammoth.Couscous.java.util.Optional _underline; + internal Mammoth.Couscous.java.util.Optional _strikethrough; + internal Mammoth.Couscous.java.util.List> _paragraphStyles; + internal Mammoth.Couscous.java.util.List> _runStyles; + static StyleMap() { + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMap._EMPTY = (new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapBuilder()).build(); + } + internal StyleMap(Mammoth.Couscous.java.util.Optional bold, Mammoth.Couscous.java.util.Optional italic, Mammoth.Couscous.java.util.Optional underline, Mammoth.Couscous.java.util.Optional strikethrough, Mammoth.Couscous.java.util.List> paragraphStyles, Mammoth.Couscous.java.util.List> runStyles) { + this._bold = bold; + this._italic = italic; + this._underline = underline; + this._strikethrough = strikethrough; + this._paragraphStyles = paragraphStyles; + this._runStyles = runStyles; + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapBuilder builder() { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapBuilder(); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMap update(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMap styleMap) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMap(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Optionals.first(styleMap._bold, this._bold), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Optionals.first(styleMap._italic, this._italic), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Optionals.first(styleMap._underline, this._underline), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Optionals.first(styleMap._strikethrough, this._strikethrough), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.eagerConcat>(styleMap._paragraphStyles, this._paragraphStyles), Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.eagerConcat>(styleMap._runStyles, this._runStyles)); + } + public Mammoth.Couscous.java.util.Optional getBold() { + return this._bold; + } + public Mammoth.Couscous.java.util.Optional getItalic() { + return this._italic; + } + public Mammoth.Couscous.java.util.Optional getUnderline() { + return this._underline; + } + public Mammoth.Couscous.java.util.Optional getStrikethrough() { + return this._strikethrough; + } + public Mammoth.Couscous.java.util.Optional getParagraphHtmlPath(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Paragraph paragraph) { + return (Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Iterables.tryFind>(this._paragraphStyles, new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMap_Anonymous_103(paragraph))).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMap_Anonymous_102()); + } + public Mammoth.Couscous.java.util.Optional getRunHtmlPath(Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.Run run) { + return (Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Iterables.tryFind>(this._runStyles, new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMap_Anonymous_105(run))).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMap_Anonymous_104()); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal class StyleMapBuilder { + internal Mammoth.Couscous.java.util.Optional _underline; + internal Mammoth.Couscous.java.util.Optional _strikethrough; + internal Mammoth.Couscous.java.util.Optional _bold; + internal Mammoth.Couscous.java.util.Optional _italic; + internal Mammoth.Couscous.java.util.List> _paragraphStyles; + internal Mammoth.Couscous.java.util.List> _runStyles; + internal StyleMapBuilder() { + this._paragraphStyles = new Mammoth.Couscous.java.util.ArrayList>(); + this._runStyles = new Mammoth.Couscous.java.util.ArrayList>(); + this._bold = Mammoth.Couscous.java.util.Optional.empty(); + this._underline = Mammoth.Couscous.java.util.Optional.empty(); + this._strikethrough = Mammoth.Couscous.java.util.Optional.empty(); + this._italic = Mammoth.Couscous.java.util.Optional.empty(); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapBuilder bold(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath path) { + this._bold = Mammoth.Couscous.java.util.Optional.of(path); + return this; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapBuilder italic(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath path) { + this._italic = Mammoth.Couscous.java.util.Optional.of(path); + return this; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapBuilder underline(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath path) { + this._underline = Mammoth.Couscous.java.util.Optional.of(path); + return this; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapBuilder strikethrough(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath path) { + this._strikethrough = Mammoth.Couscous.java.util.Optional.of(path); + return this; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapBuilder mapParagraph(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.ParagraphMatcher matcher, Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath path) { + (this._paragraphStyles).add(new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapping(matcher, path)); + return this; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapBuilder mapRun(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.RunMatcher matcher, Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath path) { + (this._runStyles).add(new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapping(matcher, path)); + return this; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMap build() { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMap(this._bold, this._italic, this._underline, this._strikethrough, this._paragraphStyles, this._runStyles); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal static class StyleMapping { + } +} +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles { + internal class StyleMapping { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.DocumentElementMatcher _matcher; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath _htmlPath; + internal StyleMapping(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.DocumentElementMatcher matcher, Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath htmlPath) { + this._matcher = matcher; + this._htmlPath = htmlPath; + } + public bool matches(T element) { + return (this._matcher).matches(element); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath getHtmlPath() { + return this._htmlPath; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing { + internal class DocumentMatcherParser_Anonymous_106 : Mammoth.Couscous.java.util.function.BiConsumer { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.ParagraphMatcher _paragraph; + internal DocumentMatcherParser_Anonymous_106(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.ParagraphMatcher paragraph) { + this._paragraph = paragraph; + } + public void accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapBuilder builder, Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath path) { + builder.mapParagraph(this._paragraph, path); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing { + internal class DocumentMatcherParser_Anonymous_107 : Mammoth.Couscous.java.util.function.BiConsumer { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.RunMatcher _run; + internal DocumentMatcherParser_Anonymous_107(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.RunMatcher run) { + this._run = run; + } + public void accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapBuilder builder, Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath path) { + builder.mapRun(this._run, path); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing { + internal class DocumentMatcherParser_Anonymous_108 : Mammoth.Couscous.java.util.function.BiConsumer { + public void accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapBuilder arg0, Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath arg1) { + arg0.bold(arg1); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing { + internal class DocumentMatcherParser_Anonymous_109 : Mammoth.Couscous.java.util.function.BiConsumer { + public void accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapBuilder arg0, Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath arg1) { + arg0.italic(arg1); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing { + internal class DocumentMatcherParser_Anonymous_110 : Mammoth.Couscous.java.util.function.BiConsumer { + public void accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapBuilder arg0, Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath arg1) { + arg0.underline(arg1); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing { + internal class DocumentMatcherParser_Anonymous_111 : Mammoth.Couscous.java.util.function.BiConsumer { + public void accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapBuilder arg0, Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath arg1) { + arg0.strikethrough(arg1); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing { + internal class DocumentMatcherParser { + public static Mammoth.Couscous.java.util.function.BiConsumer parse(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenIterator tokens) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.Token identifier = tokens.next(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._IDENTIFIER); + string _couscous_tmp_7 = identifier.getValue(); + if (_couscous_tmp_7.Equals("p")) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.ParagraphMatcher paragraph = Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.DocumentMatcherParser.parseParagraphMatcher(tokens); + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.DocumentMatcherParser_Anonymous_106(paragraph); + } else if (_couscous_tmp_7.Equals("r")) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.RunMatcher run = Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.DocumentMatcherParser.parseRunMatcher(tokens); + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.DocumentMatcherParser_Anonymous_107(run); + } else if (_couscous_tmp_7.Equals("b")) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.DocumentMatcherParser_Anonymous_108(); + } else if (_couscous_tmp_7.Equals("i")) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.DocumentMatcherParser_Anonymous_109(); + } else if (_couscous_tmp_7.Equals("u")) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.DocumentMatcherParser_Anonymous_110(); + } else if (_couscous_tmp_7.Equals("strike")) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.DocumentMatcherParser_Anonymous_111(); + } else { + throw new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.LineParseException(identifier, "Unrecognised document element: " + identifier); + } + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.ParagraphMatcher parseParagraphMatcher(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenIterator tokens) { + Mammoth.Couscous.java.util.Optional styleId = Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.DocumentMatcherParser.parseStyleId(tokens); + Mammoth.Couscous.java.util.Optional styleName = Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.DocumentMatcherParser.parseStyleName(tokens); + Mammoth.Couscous.java.util.Optional numbering = Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.DocumentMatcherParser.parseNumbering(tokens); + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.ParagraphMatcher(styleId, styleName, numbering); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.RunMatcher parseRunMatcher(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenIterator tokens) { + Mammoth.Couscous.java.util.Optional styleId = Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.DocumentMatcherParser.parseStyleId(tokens); + Mammoth.Couscous.java.util.Optional styleName = Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.DocumentMatcherParser.parseStyleName(tokens); + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.RunMatcher(styleId, styleName); + } + public static Mammoth.Couscous.java.util.Optional parseStyleId(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenIterator tokens) { + if (tokens.peekTokenType() == Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._DOT) { + tokens.skip(); + return Mammoth.Couscous.java.util.Optional.of(tokens.nextValue(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._IDENTIFIER)); + } else { + return Mammoth.Couscous.java.util.Optional.empty(); + } + } + public static Mammoth.Couscous.java.util.Optional parseStyleName(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenIterator tokens) { + if (tokens.peekTokenType() == Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._OPEN_SQUARE_BRACKET) { + tokens.skip(); + tokens.skip(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._IDENTIFIER, "style-name"); + tokens.skip(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._EQUALS); + string value = tokens.nextValue(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._STRING); + tokens.skip(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._CLOSE_SQUARE_BRACKET); + return Mammoth.Couscous.java.util.Optional.of(value.Substring(1, (value.Length - 1) - 1)); + } else { + return Mammoth.Couscous.java.util.Optional.empty(); + } + } + public static Mammoth.Couscous.java.util.Optional parseNumbering(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenIterator tokens) { + if (tokens.peekTokenType() == Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._COLON) { + tokens.skip(); + bool isOrdered = Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.DocumentMatcherParser.parseListType(tokens); + tokens.skip(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._OPEN_PAREN); + string level = ((new Mammoth.Couscous.java.math.BigInteger(tokens.nextValue(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._INTEGER))).subtract(Mammoth.Couscous.java.math.BigInteger._ONE)).toString(); + tokens.skip(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._CLOSE_PAREN); + return Mammoth.Couscous.java.util.Optional.of(new Mammoth.Couscous.org.zwobble.mammoth.@internal.documents.NumberingLevel(level, isOrdered)); + } else { + return Mammoth.Couscous.java.util.Optional.empty(); + } + } + public static bool parseListType(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenIterator tokens) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.Token listType = tokens.next(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._IDENTIFIER); + string _couscous_tmp_8 = listType.getValue(); + if (_couscous_tmp_8.Equals("ordered-list")) { + return true; + } else if (_couscous_tmp_8.Equals("unordered-list")) { + return false; + } else { + throw new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.LineParseException(listType, "Unrecognised list type: " + listType); + } + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing { + internal class HtmlPathParser { + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath parse(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenIterator tokens) { + Mammoth.Couscous.java.util.List elements = new Mammoth.Couscous.java.util.ArrayList(); + if (tokens.peekTokenType() == Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._IDENTIFIER) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPathElement element = Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.HtmlPathParser.parseElement(tokens); + elements.add(element); + while (tokens.peekTokenType() == Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._WHITESPACE && tokens.peekTokenType(1) == Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._GREATER_THAN) { + tokens.skip(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._WHITESPACE); + tokens.skip(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._GREATER_THAN); + tokens.skip(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._WHITESPACE); + elements.add(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.HtmlPathParser.parseElement(tokens)); + } + } + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath(elements); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPathElement parseElement(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenIterator tokens) { + Mammoth.Couscous.java.util.List tagNames = Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.HtmlPathParser.parseTagNames(tokens); + Mammoth.Couscous.java.util.List classNames = Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.HtmlPathParser.parseClassNames(tokens); + Mammoth.Couscous.java.util.Map attributes = classNames.isEmpty() ? Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map() : Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map("class", java.lang.String.join(" ", classNames)); + bool isFresh = Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.HtmlPathParser.parseIsFresh(tokens); + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPathElement(tagNames, attributes, !isFresh); + } + public static Mammoth.Couscous.java.util.List parseTagNames(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenIterator tokens) { + Mammoth.Couscous.java.util.List tagNames = new Mammoth.Couscous.java.util.ArrayList(); + tagNames.add(tokens.nextValue(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._IDENTIFIER)); + while (tokens.peekTokenType() == Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._CHOICE) { + tokens.skip(); + tagNames.add(tokens.nextValue(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._IDENTIFIER)); + } + return tagNames; + } + public static Mammoth.Couscous.java.util.List parseClassNames(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenIterator tokens) { + Mammoth.Couscous.java.util.List classNames = new Mammoth.Couscous.java.util.ArrayList(); + while (tokens.peekTokenType() == Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._DOT) { + tokens.skip(); + classNames.add(tokens.nextValue(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._IDENTIFIER)); + } + return classNames; + } + public static bool parseIsFresh(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenIterator tokens) { + if (tokens.peekTokenType() == Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._COLON) { + tokens.skip(); + tokens.skip(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._IDENTIFIER, "fresh"); + return true; + } else { + return false; + } + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing { + internal class StyleMapParser_Anonymous_112 : Mammoth.Couscous.java.util.function.Consumer { + internal Mammoth.Couscous.java.util.function.BiConsumer _documentMatcher; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath _htmlPath; + internal StyleMapParser_Anonymous_112(Mammoth.Couscous.java.util.function.BiConsumer documentMatcher, Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath htmlPath) { + this._documentMatcher = documentMatcher; + this._htmlPath = htmlPath; + } + public void accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapBuilder styleMap) { + (this._documentMatcher).accept(styleMap, this._htmlPath); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing { + internal class StyleMapParser { + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMap parse(string input) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.StyleMapParser.parseStyleMappings(Mammoth.Couscous.java.util.Arrays.asList(input.split("\\r?\\n"))); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMap parseStyleMappings(Mammoth.Couscous.java.util.List lines) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapBuilder styleMap = Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMap.builder(); + int lineIndex = 0; + while (lineIndex < lines.size()) { + string line = lines.get(lineIndex); + try { + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.StyleMapParser.handleLine(styleMap, line); + } catch (Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.LineParseException exception) { + throw new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.ParseException(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.StyleMapParser.generateErrorMessage(line, lineIndex + 1, exception.getToken(), exception.getMessage())); + } + lineIndex = lineIndex + 1; + } + return styleMap.build(); + } + public static void handleLine(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.StyleMapBuilder styleMap, string line) { + if (line.startsWith("#")) { + return; + } + line = line.trim(); + if (line.isEmpty()) { + return; + } + (Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.StyleMapParser.parseStyleMapping(line)).accept(styleMap); + } + public static Mammoth.Couscous.java.util.function.Consumer parseStyleMapping(string line) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenIterator tokens = new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenIterator(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.StyleMappingTokeniser.tokenise(line)); + Mammoth.Couscous.java.util.function.BiConsumer documentMatcher = Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.DocumentMatcherParser.parse(tokens); + tokens.skip(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._WHITESPACE); + tokens.skip(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._ARROW); + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath htmlPath = Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.StyleMapParser.parseHtmlPath(tokens); + tokens.skip(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._EOF); + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.StyleMapParser_Anonymous_112(documentMatcher, htmlPath); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath parseHtmlPath(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenIterator tokens) { + if (tokens.peekTokenType() == Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._EOF) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.HtmlPath._EMPTY; + } else { + tokens.skip(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._WHITESPACE); + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.HtmlPathParser.parse(tokens); + } + } + public static string generateErrorMessage(string line, int lineNumber, Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.Token token, string message) { + return ((((((((("error reading style map at line " + lineNumber) + ", character ") + (token.getCharacterIndex() + 1)) + ": ") + message) + "\n\n") + line) + "\n") + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.StyleMapParser.repeatString(" ", token.getCharacterIndex())) + "^"; + } + public static string repeatString(string value, int times) { + Mammoth.Couscous.java.lang.StringBuilder builder = new Mammoth.Couscous.java.lang.StringBuilder(); + int i = 0; + while (i < times) { + builder.append(value); + i = i + 1; + } + return builder.toString(); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing { + internal class StyleMappingTokeniser { + public static Mammoth.Couscous.java.util.List tokenise(string line) { + Mammoth.Couscous.java.util.List tokens = new Mammoth.Couscous.java.util.ArrayList(); + int index = 0; + while (index < line.Length) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.Token token = Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.StyleMappingTokeniser.nextToken(line, index); + tokens.add(token); + index = index + (token.getValue()).Length; + } + tokens.add(new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.Token(index, Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._EOF, "")); + return tokens; + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.Token nextToken(string line, int startIndex) { + char nextChar = line.charAt(startIndex); + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType tokenType = Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.StyleMappingTokeniser.tokenType(nextChar); + int index = 0; + if ((nextChar == 61 && startIndex + 1 < line.Length) && line.charAt(startIndex + 1) == 62) { + tokenType = Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._ARROW; + index = startIndex + 2; + } else { + index = Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.StyleMappingTokeniser.seekEndOfToken(line, startIndex + 1, tokenType); + if (tokenType == Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._STRING && index == line.Length + 1) { + tokenType = Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._UNTERMINATED_STRING; + index = index - 1; + } + } + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.Token(startIndex, tokenType, line.Substring(startIndex, index - startIndex)); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType tokenType(char nextChar) { + if (Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.StyleMappingTokeniser.isAlphabetic(nextChar)) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._IDENTIFIER; + } else if (Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.StyleMappingTokeniser.isWhitespace(nextChar)) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._WHITESPACE; + } else if (Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.StyleMappingTokeniser.isNumeric(nextChar)) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._INTEGER; + } else { + char _couscous_tmp_9 = nextChar; + if (_couscous_tmp_9.equals(39)) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._STRING; + } else if (_couscous_tmp_9.equals(46)) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._DOT; + } else if (_couscous_tmp_9.equals(58)) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._COLON; + } else if (_couscous_tmp_9.equals(62)) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._GREATER_THAN; + } else if (_couscous_tmp_9.equals(61)) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._EQUALS; + } else if (_couscous_tmp_9.equals(40)) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._OPEN_PAREN; + } else if (_couscous_tmp_9.equals(41)) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._CLOSE_PAREN; + } else if (_couscous_tmp_9.equals(91)) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._OPEN_SQUARE_BRACKET; + } else if (_couscous_tmp_9.equals(93)) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._CLOSE_SQUARE_BRACKET; + } else if (_couscous_tmp_9.equals(124)) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._CHOICE; + } else { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._UNKNOWN; + } + } + } + public static int seekEndOfToken(string line, int index, Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType tokenType) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType _couscous_tmp_10 = tokenType; + if (_couscous_tmp_10.equals(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._WHITESPACE)) { + while (index < line.Length && Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.StyleMappingTokeniser.isWhitespace(line.charAt(index))) { + index = index + 1; + } + return index; + } else if (_couscous_tmp_10.equals(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._IDENTIFIER)) { + while (index < line.Length && Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.StyleMappingTokeniser.isIdentifierCharacter(line.charAt(index))) { + index = index + 1; + } + return index; + } else if (_couscous_tmp_10.equals(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._INTEGER)) { + while (index < line.Length && Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.StyleMappingTokeniser.isNumeric(line.charAt(index))) { + index = index + 1; + } + return index; + } else if (_couscous_tmp_10.equals(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType._STRING)) { + while (index < line.Length && !(line.charAt(index) == 39)) { + index = index + 1; + } + index = index + 1; + return index; + } else { + return index; + } + } + public static bool isWhitespace(char c) { + return c == 32 || c == 9; + } + public static bool isIdentifierCharacter(char c) { + return ((Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.StyleMappingTokeniser.isAlphabetic(c) || Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.StyleMappingTokeniser.isNumeric(c)) || c == 45) || c == 95; + } + public static bool isAlphabetic(char nextChar) { + return nextChar >= 97 && nextChar <= 122 || nextChar >= 65 && nextChar <= 90; + } + public static bool isNumeric(char c) { + return c >= 48 && c <= 57; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing { + internal class Token { + internal int _characterIndex; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType _tokenType; + internal string _value; + internal Token(int characterIndex, Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType tokenType, string value) { + this._characterIndex = characterIndex; + this._tokenType = tokenType; + this._value = value; + } + public int getCharacterIndex() { + return this._characterIndex; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType getTokenType() { + return this._tokenType; + } + public string getValue() { + return this._value; + } + public string toString() { + return ((("Token(tokenType=" + this._tokenType) + ", value=") + this._value) + ")"; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing { + internal class TokenIterator { + internal Mammoth.Couscous.java.util.List _tokens; + internal int _index; + internal TokenIterator(Mammoth.Couscous.java.util.List tokens) { + this._tokens = tokens; + this._index = 0; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType peekTokenType() { + return ((this._tokens).get(this._index)).getTokenType(); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType peekTokenType(int count) { + return ((this._tokens).get(this._index + count)).getTokenType(); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.Token next(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType type) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.Token token = (this._tokens).get(this._index); + if (token.getTokenType() == type) { + this._index = this._index + 1; + return token; + } else { + throw this.unexpectedTokenType(type, token); + } + } + public string nextValue(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType type) { + return (this.next(type)).getValue(); + } + public void skip() { + this._index = this._index + 1; + } + public void skip(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType tokenType) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.Token token = (this._tokens).get(this._index); + if (!(token.getTokenType() == tokenType)) { + throw this.unexpectedTokenType(tokenType, token); + } + this._index = this._index + 1; + } + public void skip(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType tokenType, string tokenValue) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.Token token = (this._tokens).get(this._index); + if (!(token.getTokenType() == tokenType)) { + throw this.unexpectedTokenType(tokenType, token); + } + string actualValue = token.getValue(); + if (!actualValue.Equals(tokenValue)) { + throw new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.LineParseException(token, (((("expected " + tokenType) + " token with value ") + tokenValue) + " but value was ") + actualValue); + } + this._index = this._index + 1; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.LineParseException unexpectedTokenType(Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.TokenType expected, Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.Token actual) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing.LineParseException(actual, (("expected token of type " + expected) + " but was of type ") + actual.getTokenType()); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing { + internal enum TokenType { + _WHITESPACE, _IDENTIFIER, _DOT, _COLON, _GREATER_THAN, _ARROW, _EQUALS, _OPEN_PAREN, _CLOSE_PAREN, _OPEN_SQUARE_BRACKET, _CLOSE_SQUARE_BRACKET, _STRING, _UNTERMINATED_STRING, _INTEGER, _CHOICE, _EOF, _UNKNOWN + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util { + internal interface InputStreamSupplier { + Mammoth.Couscous.java.io.InputStream open(); + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util { + internal class Optionals { + public static Mammoth.Couscous.java.util.Optional first(Mammoth.Couscous.java.util.Optional first, Mammoth.Couscous.java.util.Optional second) { + if (first.isPresent()) { + return first; + } else { + return second; + } + } + public static Mammoth.Couscous.java.util.Optional flatMap(Mammoth.Couscous.java.util.Optional first, Mammoth.Couscous.java.util.Optional second, Mammoth.Couscous.java.util.function.BiFunction> function) { + if (first.isPresent() && second.isPresent()) { + return function.apply(first.get(), second.get()); + } else { + return Mammoth.Couscous.java.util.Optional.empty(); + } + } + public static Mammoth.Couscous.java.util.Optional map(Mammoth.Couscous.java.util.Optional first, Mammoth.Couscous.java.util.Optional second, Mammoth.Couscous.java.util.function.BiFunction function) { + if (first.isPresent() && second.isPresent()) { + return Mammoth.Couscous.java.util.Optional.of(function.apply(first.get(), second.get())); + } else { + return Mammoth.Couscous.java.util.Optional.empty(); + } + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util { + internal interface SupplierWithException { + T get(); + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml { + internal class NamespacePrefixes__Builder { + internal Mammoth.Couscous.java.util.Map _uriToPrefix; + internal NamespacePrefixes__Builder() { + this._uriToPrefix = new Mammoth.Couscous.java.util.HashMap(); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.NamespacePrefixes__Builder put(string prefix, string uri) { + (this._uriToPrefix).put(uri, prefix); + return this; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.NamespacePrefixes build() { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.NamespacePrefixes(this._uriToPrefix); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml { + internal class NamespacePrefixes { + internal Mammoth.Couscous.java.util.Map _uriToPrefix; + internal NamespacePrefixes(Mammoth.Couscous.java.util.Map uriToPrefix) { + this._uriToPrefix = uriToPrefix; + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.NamespacePrefixes__Builder builder() { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.NamespacePrefixes__Builder(); + } + public Mammoth.Couscous.java.util.Optional prefixForUri(string uri) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.lookup(this._uriToPrefix, uri); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml { + internal class NullXmlElement : Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementLike { + internal static Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementLike _INSTANCE; + static NullXmlElement() { + Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.NullXmlElement._INSTANCE = new Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.NullXmlElement(); + } + public bool hasChild(string name) { + return false; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementLike findChildOrEmpty(string name) { + return this; + } + public Mammoth.Couscous.java.util.Optional getAttributeOrNone(string name) { + return Mammoth.Couscous.java.util.Optional.empty(); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml { + internal class XmlElement_Anonymous_113 : Mammoth.Couscous.java.util.function.Supplier { + internal string _name; + internal XmlElement_Anonymous_113(string name) { + this._name = name; + } + public Mammoth.Couscous.java.lang.RuntimeException get() { + return new Mammoth.Couscous.java.lang.RuntimeException(("Element has no '" + this._name) + "' attribute"); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml { + internal class XmlElement_Anonymous_114 : Mammoth.Couscous.java.util.function.Function { + public string apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlNode arg0) { + return arg0.innerText(); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml { + internal class XmlElement_Anonymous_115 : Mammoth.Couscous.java.util.function.Predicate { + internal string _name; + internal XmlElement_Anonymous_115(string name) { + this._name = name; + } + public bool test(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement child) { + return (child.getName()).Equals(this._name); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml { + internal class XmlElement : Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlNode, Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementLike { + internal string _name; + internal Mammoth.Couscous.java.util.Map _attributes; + internal Mammoth.Couscous.java.util.List _children; + internal XmlElement(string name, Mammoth.Couscous.java.util.Map attributes, Mammoth.Couscous.java.util.List children) { + this._name = name; + this._attributes = attributes; + this._children = children; + } + public string getName() { + return this._name; + } + public Mammoth.Couscous.java.util.Map getAttributes() { + return this._attributes; + } + public string getAttribute(string name) { + return (this.getAttributeOrNone(name)).orElseThrow(new Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement_Anonymous_113(name)); + } + public Mammoth.Couscous.java.util.Optional getAttributeOrNone(string name) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.lookup(this._attributes, name); + } + public Mammoth.Couscous.java.util.List getChildren() { + return this._children; + } + public string innerText() { + return java.lang.String.join("", Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Iterables.lazyMap(this._children, new Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement_Anonymous_114())); + } + public T accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlNodeVisitor visitor) { + return visitor.visit(this); + } + public Mammoth.Couscous.java.lang.Iterable children() { + return this._children; + } + public string toString() { + return ((((("XmlElement(name=" + this._name) + ", attributes=") + this._attributes) + ", children=") + this._children) + ")"; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementList findChildren(string name) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementList(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.toList(this.findChildrenIterable(name))); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement findChild(string name) { + return ((this.findChildrenIterable(name)).iterator()).next(); + } + public bool hasChild(string name) { + return ((this.findChildrenIterable(name)).iterator()).hasNext(); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementLike findChildOrEmpty(string name) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Iterables.getFirst(this.findChildrenIterable(name), Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.NullXmlElement._INSTANCE); + } + public Mammoth.Couscous.java.lang.Iterable findChildrenIterable(string name) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Iterables.lazyFilter(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Iterables.lazyFilter(this._children, typeof(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement)), new Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement_Anonymous_115(name)); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml { + internal interface XmlElementLike { + bool hasChild(string name); + Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementLike findChildOrEmpty(string name); + Mammoth.Couscous.java.util.Optional getAttributeOrNone(string name); + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml { + internal class XmlElementList_Anonymous_116 : Mammoth.Couscous.java.util.function.Function> { + internal string _name; + internal XmlElementList_Anonymous_116(string name) { + this._name = name; + } + public Mammoth.Couscous.java.lang.Iterable apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element) { + return element.findChildren(this._name); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml { + internal class XmlElementList : Mammoth.Couscous.java.lang.Iterable { + internal Mammoth.Couscous.java.util.List _elements; + internal XmlElementList(Mammoth.Couscous.java.util.List elements) { + this._elements = elements; + } + public Mammoth.Couscous.java.util.Iterator iterator() { + return (this._elements).iterator(); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementList findChildren(string name) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementList(Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.eagerFlatMap(this._elements, new Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElementList_Anonymous_116(name))); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml { + internal interface XmlNode { + string innerText(); + T accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlNodeVisitor visitor); + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml { + internal interface XmlNodeVisitor { + T visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element); + T visit(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlTextNode textNode); + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml { + internal class XmlNodes { + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element(string name) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlNodes.element(name, Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list()); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element(string name, Mammoth.Couscous.java.util.Map attributes) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlNodes.element(name, attributes, Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Lists.list()); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element(string name, Mammoth.Couscous.java.util.List children) { + return Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlNodes.element(name, Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.map(), children); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement element(string name, Mammoth.Couscous.java.util.Map attributes, Mammoth.Couscous.java.util.List children) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement(name, attributes, children); + } + public static Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlTextNode text(string value) { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlTextNode(value); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml { + internal class XmlTextNode : Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlNode { + internal string _value; + internal XmlTextNode(string value) { + this._value = value; + } + public string getValue() { + return this._value; + } + public string innerText() { + return this._value; + } + public T accept(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlNodeVisitor visitor) { + return visitor.visit(this); + } + public string toString() { + return ("XmlTextNode(value=" + this._value) + ")"; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing { + internal class ElementName { + internal string _uri; + internal string _localName; + internal ElementName(string uri, string localName) { + this._uri = uri; + this._localName = localName; + } + public string getUri() { + return this._uri; + } + public string getLocalName() { + return this._localName; + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing { + internal interface SimpleSaxHandler { + void startElement(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.ElementName name, Mammoth.Couscous.java.util.Map attributes); + void endElement(); + void characters(string @string); + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing { + internal class XmlElementBuilder { + internal string _name; + internal Mammoth.Couscous.java.util.Map _attributes; + internal Mammoth.Couscous.java.util.List _children; + internal XmlElementBuilder(string name, Mammoth.Couscous.java.util.Map attributes) { + this._name = name; + this._attributes = attributes; + this._children = new Mammoth.Couscous.java.util.ArrayList(); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement build() { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement(this._name, this._attributes, this._children); + } + public void addChild(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlNode node) { + (this._children).add(node); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing { + internal class XmlParser__NodeGenerator_Anonymous_117 : Mammoth.Couscous.java.util.function.Function { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.XmlParser__NodeGenerator _this_org__zwobble__mammoth__internal__xml__parsing__XmlParser__NodeGenerator; + internal XmlParser__NodeGenerator_Anonymous_117(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.XmlParser__NodeGenerator this_org__zwobble__mammoth__internal__xml__parsing__XmlParser__NodeGenerator) { + this._this_org__zwobble__mammoth__internal__xml__parsing__XmlParser__NodeGenerator = this_org__zwobble__mammoth__internal__xml__parsing__XmlParser__NodeGenerator; + } + public string apply(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.ElementName arg0) { + return (this._this_org__zwobble__mammoth__internal__xml__parsing__XmlParser__NodeGenerator).readName(arg0); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing { + internal class XmlParser__NodeGenerator_Anonymous_118 : Mammoth.Couscous.java.util.function.Supplier { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.ElementName _name; + internal XmlParser__NodeGenerator_Anonymous_118(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.ElementName name) { + this._name = name; + } + public string get() { + return (("{" + (this._name).getUri()) + "}") + (this._name).getLocalName(); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing { + internal class XmlParser__NodeGenerator_Anonymous_119 : Mammoth.Couscous.java.util.function.Function { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.ElementName _name; + internal XmlParser__NodeGenerator_Anonymous_119(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.ElementName name) { + this._name = name; + } + public string apply(string prefix) { + return (prefix + ":") + (this._name).getLocalName(); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing { + internal class XmlParser__NodeGenerator : Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.SimpleSaxHandler { + internal Mammoth.Couscous.java.util.Deque _elementStack; + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.XmlParser _this_org__zwobble__mammoth__internal__xml__parsing__XmlParser; + internal XmlParser__NodeGenerator(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.XmlParser this_org__zwobble__mammoth__internal__xml__parsing__XmlParser) { + this._this_org__zwobble__mammoth__internal__xml__parsing__XmlParser = this_org__zwobble__mammoth__internal__xml__parsing__XmlParser; + this._elementStack = new Mammoth.Couscous.java.util.ArrayDeque(); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement getRoot() { + return ((this._elementStack).getFirst()).build(); + } + public void startElement(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.ElementName name, Mammoth.Couscous.java.util.Map attributes) { + Mammoth.Couscous.java.util.Map simpleAttributes = Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Maps.eagerMapKeys(attributes, new Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.XmlParser__NodeGenerator_Anonymous_117(this)); + Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.XmlElementBuilder element = new Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.XmlElementBuilder(this.readName(name), simpleAttributes); + (this._elementStack).add(element); + } + public string readName(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.ElementName name) { + if (Mammoth.Couscous.org.zwobble.mammoth.@internal.util.Strings.isNullOrEmpty(name.getUri())) { + return name.getLocalName(); + } else { + return ((((this._this_org__zwobble__mammoth__internal__xml__parsing__XmlParser)._namespaces).prefixForUri(name.getUri())).map(new Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.XmlParser__NodeGenerator_Anonymous_119(name))).orElseGet(new Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.XmlParser__NodeGenerator_Anonymous_118(name)); + } + } + public void endElement() { + if ((this._elementStack).size() > 1) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.XmlElementBuilder element = (this._elementStack).removeLast(); + ((this._elementStack).getLast()).addChild(element.build()); + } + } + public void characters(string @string) { + ((this._elementStack).getLast()).addChild(new Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlTextNode(@string)); + } + } +} + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing { + internal class XmlParser { + internal Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.NamespacePrefixes _namespaces; + internal XmlParser(Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.NamespacePrefixes namespaces) { + this._namespaces = namespaces; + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement parseStream(Mammoth.Couscous.java.io.InputStream inputStream) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.XmlParser__NodeGenerator nodeGenerator = this.create_NodeGenerator(); + Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.SimpleSax.parseStream(inputStream, nodeGenerator); + return nodeGenerator.getRoot(); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.XmlElement parseString(string value) { + Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.XmlParser__NodeGenerator nodeGenerator = this.create_NodeGenerator(); + Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.SimpleSax.parseString(value, nodeGenerator); + return nodeGenerator.getRoot(); + } + public Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.XmlParser__NodeGenerator create_NodeGenerator() { + return new Mammoth.Couscous.org.zwobble.mammoth.@internal.xml.parsing.XmlParser__NodeGenerator(this); + } + } +} + diff --git a/Mammoth/mammoth.browser.js b/Mammoth/mammoth.browser.js deleted file mode 100644 index 5ab3cd2..0000000 --- a/Mammoth/mammoth.browser.js +++ /dev/null @@ -1,26610 +0,0 @@ -// Module: mammoth@0.3.18 -// License: BSD -// -// Module: mammoth@0.3.18 => underscore@1.6.0 -// License: MIT -// -// Module: mammoth@0.3.18 => uglify-js@2.4.13 -// License: BSD 2-Clause -// -// Module: mammoth@0.3.18 => uglify-js@2.4.13 => uglify-to-browserify@1.0.2 -// License: MIT -// -// Module: mammoth@0.3.18 => uglify-js@2.4.13 => source-map@0.1.33 -// License: BSD -// -// Module: mammoth@0.3.18 => uglify-js@2.4.13 => source-map@0.1.33 => amdefine@0.1.0 -// License: BSD, MIT -// -// Module: mammoth@0.3.18 => uglify-js@2.4.13 => optimist@0.3.7 -// License: MIT/X11 -// -// Module: mammoth@0.3.18 => uglify-js@2.4.13 => optimist@0.3.7 => wordwrap@0.0.2 -// License: MIT/X11 -// -// Module: mammoth@0.3.18 => temp@0.7.0 -// License: MIT -// -// Module: mammoth@0.3.18 => temp@0.7.0 => rimraf@2.2.6 -// License: MIT -// -// Module: mammoth@0.3.18 => sax@0.5.8 -// License: BSD -// -// Module: mammoth@0.3.18 => nomnom@1.6.2 -// License: MIT -// -// Module: mammoth@0.3.18 => nomnom@1.6.2 => colors@0.5.1 -// License: Unknown license -// -// Module: mammoth@0.3.18 => mocha@2.1.0 -// License: MIT -// -// Module: mammoth@0.3.18 => mocha@2.1.0 => mkdirp@0.5.0 -// License: MIT -// -// Module: mammoth@0.3.18 => mocha@2.1.0 => mkdirp@0.5.0 => minimist@0.0.8 -// License: MIT -// -// Module: mammoth@0.3.18 => mocha@2.1.0 => jade@0.26.3 -// License: MIT -// -// Module: mammoth@0.3.18 => mocha@2.1.0 => jade@0.26.3 => mkdirp@0.3.0 -// License: MIT/X11 -// -// Module: mammoth@0.3.18 => mocha@2.1.0 => jade@0.26.3 => commander@0.6.1 -// License: MIT -// -// Module: mammoth@0.3.18 => mocha@2.1.0 => growl@1.8.1 -// License: MIT -// -// Module: mammoth@0.3.18 => mocha@2.1.0 => glob@3.2.3 -// License: BSD -// -// Module: mammoth@0.3.18 => mocha@2.1.0 => glob@3.2.3 => minimatch@0.2.14 -// License: MIT -// -// Module: mammoth@0.3.18 => mocha@2.1.0 => glob@3.2.3 => minimatch@0.2.14 => sigmund@1.0.0 -// License: BSD -// -// Module: mammoth@0.3.18 => mocha@2.1.0 => glob@3.2.3 => minimatch@0.2.14 => lru-cache@2.5.0 -// License: MIT -// -// Module: mammoth@0.3.18 => mocha@2.1.0 => glob@3.2.3 => inherits@2.0.1 -// License: ISC -// -// Module: mammoth@0.3.18 => mocha@2.1.0 => glob@3.2.3 => graceful-fs@2.0.3 -// License: BSD -// -// Module: mammoth@0.3.18 => mocha@2.1.0 => escape-string-regexp@1.0.2 -// License: MIT -// -// Module: mammoth@0.3.18 => mocha@2.1.0 => diff@1.0.8 -// License: BSD -// -// Module: mammoth@0.3.18 => mocha@2.1.0 => debug@2.0.0 -// License: MIT -// -// Module: mammoth@0.3.18 => mocha@2.1.0 => debug@2.0.0 => ms@0.6.2 -// License: Unknown license -// -// Module: mammoth@0.3.18 => mocha@2.1.0 => commander@2.3.0 -// License: MIT -// -// Module: mammoth@0.3.18 => lop@0.2.8 -// License: BSD -// -// Module: mammoth@0.3.18 => lop@0.2.8 => option@0.2.1 -// License: BSD -// -// Module: mammoth@0.3.18 => license-sniffer@0.1.2 -// License: BSD -// -// Module: mammoth@0.3.18 => license-sniffer@0.1.2 => underscore@1.4.4 -// License: MIT -// -// Module: mammoth@0.3.18 => license-sniffer@0.1.2 => q@0.9.7 -// License: MIT -// -// Module: mammoth@0.3.18 => license-sniffer@0.1.2 => optimist@0.3.7 -// License: MIT/X11 -// -// Module: mammoth@0.3.18 => license-sniffer@0.1.2 => optimist@0.3.7 => wordwrap@0.0.2 -// License: MIT/X11 -// -// Module: mammoth@0.3.18 => license-sniffer@0.1.2 => natural@0.1.29 -// License: MIT -// -// Module: mammoth@0.3.18 => license-sniffer@0.1.2 => natural@0.1.29 => sylvester@0.0.21 -// License: MIT -// -// Module: mammoth@0.3.18 => license-sniffer@0.1.2 => natural@0.1.29 => apparatus@0.0.8 -// License: MIT -// -// Module: mammoth@0.3.18 => license-sniffer@0.1.2 => markdown@0.4.0 -// License: MIT -// -// Module: mammoth@0.3.18 => license-sniffer@0.1.2 => markdown@0.4.0 => nopt@1.0.10 -// License: MIT -// -// Module: mammoth@0.3.18 => license-sniffer@0.1.2 => markdown@0.4.0 => nopt@1.0.10 => abbrev@1.0.5 -// License: MIT -// -// Module: mammoth@0.3.18 => jszip@2.4.0 -// License: MIT or GPLv3 -// -// Module: mammoth@0.3.18 => jszip@2.4.0 => pako@0.2.5 -// License: MIT -// -// Module: mammoth@0.3.18 => jshint@2.5.2 -// License: MIT -// -// Module: mammoth@0.3.18 => jshint@2.5.2 => strip-json-comments@0.1.3 -// License: MIT -// -// Module: mammoth@0.3.18 => jshint@2.5.2 => shelljs@0.3.0 -// License: BSD* -// -// Module: mammoth@0.3.18 => jshint@2.5.2 => minimatch@0.3.0 -// License: MIT -// -// Module: mammoth@0.3.18 => jshint@2.5.2 => minimatch@0.3.0 => sigmund@1.0.0 -// License: BSD -// -// Module: mammoth@0.3.18 => jshint@2.5.2 => minimatch@0.3.0 => lru-cache@2.5.0 -// License: MIT -// -// Module: mammoth@0.3.18 => jshint@2.5.2 => htmlparser2@3.7.2 -// License: MIT -// -// Module: mammoth@0.3.18 => jshint@2.5.2 => htmlparser2@3.7.2 => readable-stream@1.1.13-1 -// License: MIT -// -// Module: mammoth@0.3.18 => jshint@2.5.2 => htmlparser2@3.7.2 => readable-stream@1.1.13-1 => string_decoder@0.10.25-1 -// License: MIT -// -// Module: mammoth@0.3.18 => jshint@2.5.2 => htmlparser2@3.7.2 => readable-stream@1.1.13-1 => isarray@0.0.1 -// License: MIT -// -// Module: mammoth@0.3.18 => jshint@2.5.2 => htmlparser2@3.7.2 => readable-stream@1.1.13-1 => inherits@2.0.1 -// License: ISC -// -// Module: mammoth@0.3.18 => jshint@2.5.2 => htmlparser2@3.7.2 => readable-stream@1.1.13-1 => core-util-is@1.0.1 -// License: MIT -// -// Module: mammoth@0.3.18 => jshint@2.5.2 => htmlparser2@3.7.2 => entities@1.0.0 -// License: BSD-like -// -// Module: mammoth@0.3.18 => jshint@2.5.2 => htmlparser2@3.7.2 => domutils@1.5.0 -// License: BSD 2-Clause -// -// Module: mammoth@0.3.18 => jshint@2.5.2 => htmlparser2@3.7.2 => domhandler@2.2.0 -// License: BSD 2-Clause -// -// Module: mammoth@0.3.18 => jshint@2.5.2 => htmlparser2@3.7.2 => domelementtype@1.1.1 -// License: BSD 2-Clause -// -// Module: mammoth@0.3.18 => jshint@2.5.2 => exit@0.1.2 -// License: MIT -// -// Module: mammoth@0.3.18 => jshint@2.5.2 => console-browserify@1.1.0 -// License: MIT -// -// Module: mammoth@0.3.18 => jshint@2.5.2 => console-browserify@1.1.0 => date-now@0.1.4 -// License: MIT -// -// Module: mammoth@0.3.18 => jshint@2.5.2 => cli@0.6.3 -// License: MIT -// -// Module: mammoth@0.3.18 => jshint@2.5.2 => cli@0.6.3 => glob@3.2.11 -// License: BSD -// -// Module: mammoth@0.3.18 => jshint@2.5.2 => cli@0.6.3 => glob@3.2.11 => inherits@2.0.1 -// License: ISC -// -// Module: mammoth@0.3.18 => duck@0.1.11 -// License: BSD -// -// Module: mammoth@0.3.18 => browserify@3.33.0 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => zlib-browserify@0.0.3 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => zlib-browserify@0.0.3 => tape@0.2.2 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => zlib-browserify@0.0.3 => tape@0.2.2 => jsonify@0.0.0 -// License: Public Domain -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => zlib-browserify@0.0.3 => tape@0.2.2 => deep-equal@0.0.0 -// License: MIT/X11 -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => vm-browserify@0.0.4 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => vm-browserify@0.0.4 => indexof@0.0.1 -// License: Unknown license -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => util@0.10.3 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => url@0.7.9 -// License: Unknown license -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => url@0.7.9 => querystring@0.1.0 -// License: Unknown license -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => url@0.7.9 => punycode@1.0.0 -// License: MIT, GPL -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => umd@2.0.0 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => umd@2.0.0 => ruglify@1.0.0 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => umd@2.0.0 => ruglify@1.0.0 => uglify-js@2.2.5 -// License: Unknown license -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => umd@2.0.0 => ruglify@1.0.0 => uglify-js@2.2.5 => source-map@0.1.33 -// License: BSD -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => umd@2.0.0 => ruglify@1.0.0 => uglify-js@2.2.5 => source-map@0.1.33 => amdefine@0.1.0 -// License: BSD, MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => umd@2.0.0 => ruglify@1.0.0 => uglify-js@2.2.5 => optimist@0.3.7 -// License: MIT/X11 -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => umd@2.0.0 => ruglify@1.0.0 => uglify-js@2.2.5 => optimist@0.3.7 => wordwrap@0.0.2 -// License: MIT/X11 -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => umd@2.0.0 => rfile@1.0.0 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => umd@2.0.0 => rfile@1.0.0 => resolve@0.3.1 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => umd@2.0.0 => rfile@1.0.0 => callsite@1.0.0 -// License: Unknown license -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => tty-browserify@0.0.0 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => timers-browserify@1.0.1 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => timers-browserify@1.0.1 => process@0.5.2 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => through@2.3.4 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => syntax-error@1.1.0 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => syntax-error@1.1.0 => esprima-fb@3001.1.0-dev-harmony-fb -// License: BSD -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => subarg@0.0.1 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => subarg@0.0.1 => minimist@0.0.8 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => string_decoder@0.0.1 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => stream-combiner@0.0.4 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => stream-browserify@0.1.3 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => stream-browserify@0.1.3 => process@0.5.2 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => shell-quote@0.0.1 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => shallow-copy@0.0.1 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => resolve@0.6.2 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => querystring-es3@0.2.0 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => punycode@1.2.4 -// License: MIT, GPL -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => path-browserify@0.0.0 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => parents@0.0.2 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => os-browserify@0.1.2 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => module-deps@1.8.0 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => module-deps@1.8.0 => minimist@0.0.8 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => module-deps@1.8.0 => detective@3.1.0 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => module-deps@1.8.0 => detective@3.1.0 => esprima-fb@3001.1.0-dev-harmony-fb -// License: BSD -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => module-deps@1.8.0 => detective@3.1.0 => escodegen@1.1.0 -// License: BSD -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => module-deps@1.8.0 => detective@3.1.0 => escodegen@1.1.0 => source-map@0.1.33 -// License: BSD -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => module-deps@1.8.0 => detective@3.1.0 => escodegen@1.1.0 => source-map@0.1.33 => amdefine@0.1.0 -// License: BSD, MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => module-deps@1.8.0 => detective@3.1.0 => escodegen@1.1.0 => esutils@1.0.0 -// License: BSD -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => module-deps@1.8.0 => detective@3.1.0 => escodegen@1.1.0 => estraverse@1.5.0 -// License: BSD -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => module-deps@1.8.0 => detective@3.1.0 => escodegen@1.1.0 => esprima@1.0.4 -// License: BSD -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => insert-module-globals@4.1.0 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => insert-module-globals@4.1.0 => process@0.5.2 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => insert-module-globals@4.1.0 => lexical-scope@1.1.0 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => insert-module-globals@4.1.0 => lexical-scope@1.1.0 => astw@1.1.0 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => insert-module-globals@4.1.0 => lexical-scope@1.1.0 => astw@1.1.0 => esprima-fb@3001.1.0-dev-harmony-fb -// License: BSD -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => inherits@2.0.1 -// License: ISC -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => https-browserify@0.0.0 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => http-browserify@1.3.2 -// License: MIT/X11 -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => http-browserify@1.3.2 => Base64@0.2.0 -// License: WTFPL -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => glob@3.2.9 -// License: BSD -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => glob@3.2.9 => minimatch@0.2.14 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => glob@3.2.9 => minimatch@0.2.14 => sigmund@1.0.0 -// License: BSD -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => glob@3.2.9 => minimatch@0.2.14 => lru-cache@2.5.0 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => events@1.0.0 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => duplexer@0.1.1 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => domain-browser@1.1.1 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => derequire@0.6.1 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => derequire@0.6.1 => estraverse@1.5.0 -// License: BSD -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => derequire@0.6.1 => esrefactor@0.1.0 -// License: BSD -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => derequire@0.6.1 => esrefactor@0.1.0 => estraverse@0.0.4 -// License: BSD -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => derequire@0.6.1 => esrefactor@0.1.0 => esprima@1.0.4 -// License: BSD -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => derequire@0.6.1 => esrefactor@0.1.0 => escope@0.0.16 -// License: BSD -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => derequire@0.6.1 => esprima-six@0.0.3 -// License: BSD -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => deps-sort@0.1.1 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => deps-sort@0.1.1 => minimist@0.0.8 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => deps-sort@0.1.1 => JSONStream@0.6.4 -// License: Unknown license -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => deps-sort@0.1.1 => JSONStream@0.6.4 => through@2.2.7 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => deps-sort@0.1.1 => JSONStream@0.6.4 => jsonparse@0.0.5 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => defined@0.0.0 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => deep-equal@0.1.2 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => crypto-browserify@1.0.9 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => constants-browserify@0.0.1 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => console-browserify@1.0.3 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => concat-stream@1.4.4 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => concat-stream@1.4.4 => typedarray@0.0.5 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => concat-stream@1.4.4 => readable-stream@1.1.11 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => concat-stream@1.4.4 => readable-stream@1.1.11 => string_decoder@0.10.25-1 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => concat-stream@1.4.4 => readable-stream@1.1.11 => debuglog@0.0.2 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => concat-stream@1.4.4 => readable-stream@1.1.11 => core-util-is@1.0.1 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => commondir@0.0.1 -// License: MIT/X11 -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => builtins@0.0.2 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => buffer@2.1.5 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => buffer@2.1.5 => ieee754@1.1.3 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => buffer@2.1.5 => base64-js@0.0.6 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => browser-resolve@1.2.2 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => browser-resolve@1.2.2 => resolve@0.6.1 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => browser-pack@2.0.1 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => browser-pack@2.0.1 => combine-source-map@0.3.0 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => browser-pack@2.0.1 => combine-source-map@0.3.0 => source-map@0.1.33 -// License: BSD -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => browser-pack@2.0.1 => combine-source-map@0.3.0 => source-map@0.1.33 => amdefine@0.1.0 -// License: BSD, MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => browser-pack@2.0.1 => combine-source-map@0.3.0 => inline-source-map@0.3.0 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => browser-pack@2.0.1 => combine-source-map@0.3.0 => convert-source-map@0.3.3 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => browser-pack@2.0.1 => JSONStream@0.6.4 -// License: Unknown license -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => browser-pack@2.0.1 => JSONStream@0.6.4 => through@2.2.7 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => browser-pack@2.0.1 => JSONStream@0.6.4 => jsonparse@0.0.5 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => assert@1.1.1 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => assert@1.1.1 => util@0.10.2 -// License: Unknown license -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => JSONStream@0.7.1 -// License: Unknown license -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => JSONStream@0.7.1 => through@2.2.7 -// License: MIT -// -// Module: mammoth@0.3.18 => browserify@3.33.0 => JSONStream@0.7.1 => jsonparse@0.0.5 -// License: MIT -// -// Module: mammoth@0.3.18 => bluebird@2.3.11 -// License: MIT -// -// Module: mammoth@0.3.18 => async@0.2.10 -// License: MIT -// -!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.mammoth=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) { - writeAll(); - writer.text(value); - } - } - - function asString() { - return writer.asString(); - } - - function append(otherHtmlGenerator) { - var otherString = otherHtmlGenerator.asString(); - if (otherString.length > 0) { - writeAll(); - } - writer.append(otherString); - } - - function satisfyPath(style) { - var firstFreshPartIndex = findIndex(style, function(part) { - return part.fresh; - }); - - var partIndex = 0; - while (partIndex < firstFreshPartIndex && stylePartMatchesStackElement(style[partIndex], stack[partIndex])) { - partIndex++; - } - while (stack.length > partIndex) { - close(); - } - for (; partIndex < style.length; partIndex++) { - open(style[partIndex]); - } - } - - function stylePartMatchesStackElement(stylePart, stackElement) { - return stackElement && stylePart.matchesElement(stackElement); - } - - function open(htmlPathElement, options) { - var stackElement = Object.create(htmlPathElement); - stackElement.written = false; - stack.push(stackElement); - if (options && options.alwaysWrite) { - writeAll(); - } - } - - function close() { - var element = stack.pop(); - if (element.written) { - writer.close(element.tagName); - } - } - - function closeAll() { - while (stack.length > 0) { - close(); - } - } - - function writeAll() { - stack.filter(function(element) { - return !element.written; - }).forEach(writeElement); - } - - function writeElement(element) { - element.written = true; - writer.open(element.tagName, element.attributes); - } - - function selfClosing(element) { - writer.selfClosing(element.tagName, element.attributes); - } - - return { - satisfyPath: satisfyPath, - text: text, - open: open, - close: close, - closeAll: closeAll, - asString: asString, - append: append, - selfClosing: selfClosing - }; -} - -function findIndex(array, predicate) { - for (var i = 0; i < array.length; i++) { - if (predicate(array[i])) { - return i; - } - } - return -1; -} - -},{"./writers":24}],14:[function(_dereq_,module,exports){ -var _ = _dereq_("underscore"); - -exports.topLevelElement = topLevelElement; -exports.elements = elements; -exports.element = element; - -function topLevelElement(tagName, attributes) { - return elements([element(tagName, attributes, {fresh: true})]); -} - -function elements(elementStyles) { - return elementStyles.map(function(elementStyle) { - if (_.isString(elementStyle)) { - return element(elementStyle); - } else { - return elementStyle; - } - }); -} - -function element(tagName, attributes, options) { - options = options || {}; - return new Element(tagName, attributes, options); -} - -function Element(tagName, attributes, options) { - var tagNames = {}; - if (_.isArray(tagName)) { - tagName.forEach(function(tagName) { - tagNames[tagName] = true; - }); - tagName = tagName[0]; - } else { - tagNames[tagName] = true; - } - - this.tagName = tagName; - this.tagNames = tagNames; - this.attributes = attributes || {}; - this.fresh = options.fresh; -} - -Element.prototype.matchesElement = function(element) { - return this.tagNames[element.tagName] && _.isEqual(this.attributes || {}, element.attributes || {}); -}; - -exports.empty = elements([]); - -},{"underscore":136}],15:[function(_dereq_,module,exports){ -var promises = _dereq_("./promises"); -var htmlPaths = _dereq_("./html-paths"); - -exports.inline = function(func) { - return function(element, html, messages, callback) { - return promises.when(func(element)).then(function(result) { - var attributes = {src: result.src}; - if (element.altText) { - attributes.alt = element.altText; - } - html.selfClosing(htmlPaths.element("img", attributes)); - }).then(callback, callback); - }; -}; - -},{"./html-paths":14,"./promises":18}],16:[function(_dereq_,module,exports){ -var docxReader = _dereq_("./docx/docx-reader"); -var DocumentConverter = _dereq_("./document-to-html").DocumentConverter; -var readStyle = _dereq_("./style-reader").readStyle; -var readOptions = _dereq_("./options-reader").readOptions; - -exports.convertToHtml = convertToHtml; -exports.convertToMarkdown = convertToMarkdown; -exports.convert = convert; -exports.extractRawText = extractRawText; -exports.images = _dereq_("./images"); -exports.transforms = _dereq_("./transforms"); -exports.underline = _dereq_("./underline"); - -function convertToHtml(input, options) { - return convert(input, options); -} - -function convertToMarkdown(input, options) { - var markdownOptions = Object.create(options || {}); - markdownOptions.outputFormat = "markdown"; - return convert(input, markdownOptions); -} - -function convert(input, options) { - var fullOptions = readOptions(options); - - return docxReader.read(input) - .then(function(documentResult) { - return documentResult.map(fullOptions.transformDocument); - }) - .then(function(documentResult) { - return convertDocumentToHtml(documentResult, fullOptions); - }); -} - -function convertDocumentToHtml(documentResult, options) { - var parsedOptions = Object.create(options); - parsedOptions.styleMap = (options.styleMap || []).map(readStyle); - var documentConverter = new DocumentConverter(parsedOptions); - return documentResult.flatMapThen(function(document) { - return documentConverter.convertToHtml(document); - }); -} - - -function extractRawText(input) { - return docxReader.read(input) - .then(function(documentResult) { - return documentResult.map(convertElementToRawText); - }); -} - -function convertElementToRawText(element) { - if (element.type === "text") { - return element.value; - } else { - var tail = element.type === "paragraph" ? "\n\n" : ""; - return (element.children || []).map(convertElementToRawText).join("") + tail; - } -} - -exports.styleMapping = function() { - throw new Error('Use a raw string instead of mammoth.styleMapping e.g. "p[style-name=\'Title\'] => h1" instead of mammoth.styleMapping("p[style-name=\'Title\'] => h1")'); -}; - -},{"./document-to-html":3,"./docx/docx-reader":7,"./images":15,"./options-reader":17,"./style-reader":20,"./transforms":21,"./underline":22}],17:[function(_dereq_,module,exports){ -exports.readOptions = readOptions; - - -var _ = _dereq_("underscore"); - - -var standardOptions = exports._standardOptions = { - styleMap: [ - "p[style-name='Normal'] => p:fresh", - - "p.Heading1 => h1:fresh", - "p.Heading2 => h2:fresh", - "p.Heading3 => h3:fresh", - "p.Heading4 => h4:fresh", - "p[style-name='Heading 1'] => h1:fresh", - "p[style-name='Heading 2'] => h2:fresh", - "p[style-name='Heading 3'] => h3:fresh", - "p[style-name='Heading 4'] => h4:fresh", - "p[style-name='heading 1'] => h1:fresh", - "p[style-name='heading 2'] => h2:fresh", - "p[style-name='heading 3'] => h3:fresh", - "p[style-name='heading 4'] => h4:fresh", - "p[style-name='heading 4'] => h4:fresh", - - "p[style-name='footnote text'] => p", - "r[style-name='footnote reference'] =>", - "p[style-name='endnote text'] => p", - "r[style-name='endnote reference'] =>", - - // LibreOffice - "p[style-name='Footnote'] => p", - "r[style-name='Footnote anchor'] =>", - "p[style-name='Endnote'] => p", - "r[style-name='Endnote anchor'] =>", - - "p:unordered-list(1) => ul > li:fresh", - "p:unordered-list(2) => ul|ol > li > ul > li:fresh", - "p:unordered-list(3) => ul|ol > li > ul|ol > li > ul > li:fresh", - "p:unordered-list(4) => ul|ol > li > ul|ol > li > ul|ol > li > ul > li:fresh", - "p:unordered-list(5) => ul|ol > li > ul|ol > li > ul|ol > li > ul|ol > li > ul > li:fresh", - "p:ordered-list(1) => ol > li:fresh", - "p:ordered-list(2) => ul|ol > li > ol > li:fresh", - "p:ordered-list(3) => ul|ol > li > ul|ol > li > ol > li:fresh", - "p:ordered-list(4) => ul|ol > li > ul|ol > li > ul|ol > li > ol > li:fresh", - "p:ordered-list(5) => ul|ol > li > ul|ol > li > ul|ol > li > ul|ol > li > ol > li:fresh" - ], - transformDocument: identity, - includeDefaultStyleMap: true -}; - -function readOptions(options) { - options = options || {}; - var fullOptions = {}; - _.extend(fullOptions, standardOptions, options); - - fullOptions.styleMap = readStyleMap(options.styleMap, fullOptions); - - return fullOptions; -} - -function readStyleMap(styleMap, options) { - var customStyleMap = readCustomStyleMap(styleMap); - return customStyleMap.concat(options.includeDefaultStyleMap ? standardOptions.styleMap : []); -} - -function readCustomStyleMap(styleMap) { - if (!styleMap) { - return []; - } else if (_.isString(styleMap)) { - return styleMap.split("\n").map(function(line) { - return line.trim(); - }); - } else { - return styleMap; - } -} - - -function identity(value) { - return value; -} - -},{"underscore":136}],18:[function(_dereq_,module,exports){ -var bluebird = _dereq_("bluebird/js/main/promise")(); - -exports.defer = bluebird.defer; -exports.when = bluebird.resolve; -exports.resolve = bluebird.resolve; -exports.all = bluebird.all; -exports.reject = bluebird.reject; -exports.promisify = bluebird.promisify; - -exports.nfcall = function(func) { - var args = Array.prototype.slice.call(arguments, 1); - var promisedFunc = bluebird.promisify(func); - return promisedFunc.apply(null, args); -}; - -bluebird.prototype.fail = bluebird.prototype.caught; - -},{"bluebird/js/main/promise":47}],19:[function(_dereq_,module,exports){ -var _ = _dereq_("underscore"); - - -exports.Result = Result; -exports.warning = warning; - - -function Result(value, messages) { - this.value = value; - this.messages = messages || []; -} - -Result.prototype.map = function(func) { - return new Result(func(this.value), this.messages); -}; - -Result.prototype.flatMap = function(func) { - var funcResult = func(this.value); - return new Result(funcResult.value, combineMessages([this, funcResult])); -}; - -Result.prototype.flatMapThen = function(func) { - var that = this; - return func(this.value).then(function(otherResult) { - return new Result(otherResult.value, combineMessages([that, otherResult])); - }); -}; - -Result.combine = function(results) { - var values = _.flatten(_.pluck(results, "value")); - var messages = combineMessages(results); - return new Result(values, messages); -}; - -function warning(message) { - return { - type: "warning", - message: message - }; -} - -function combineMessages(results) { - var messages = []; - _.flatten(_.pluck(results, "messages"), true).forEach(function(message) { - if (!containsMessage(messages, message)) { - messages.push(message); - } - }); - return messages; -} - -function containsMessage(messages, message) { - return _.find(messages, isSameMessage.bind(null, message)) !== undefined; -} - -function isSameMessage(first, second) { - return first.type === second.type && first.message === second.message; -} - -},{"underscore":136}],20:[function(_dereq_,module,exports){ -var _ = _dereq_("underscore"); -var lop = _dereq_("lop"); -var RegexTokeniser = lop.RegexTokeniser; - -var documentMatchers = _dereq_("./document-matchers"); -var htmlPaths = _dereq_("./html-paths"); - -exports.readHtmlPath = readHtmlPath; -exports.readDocumentMatcher = readDocumentMatcher; -exports.readStyle = readStyle; - - -function readStyle(string) { - return parseString(styleRule, string); -} - -function createStyleRule() { - return lop.rules.sequence( - lop.rules.sequence.capture(documentMatcherRule()), - lop.rules.tokenOfType("whitespace"), - lop.rules.tokenOfType("arrow"), - lop.rules.sequence.capture(lop.rules.optional(lop.rules.sequence( - lop.rules.tokenOfType("whitespace"), - lop.rules.sequence.capture(htmlPathRule()) - ).head())) - ).map(function(documentMatcher, htmlPath) { - return { - from: documentMatcher, - to: htmlPath.valueOrElse(htmlPaths.empty) - }; - }); -} - -function readDocumentMatcher(string) { - return parseString(documentMatcherRule(), string); -} - -function documentMatcherRule() { - var sequence = lop.rules.sequence; - - var identifierToConstant = function(identifier, constant) { - return lop.rules.then( - lop.rules.token("identifier", identifier), - function() { - return constant; - } - ); - }; - - var paragraphRule = identifierToConstant("p", documentMatchers.paragraph); - var runRule = identifierToConstant("r", documentMatchers.run); - - var elementTypeRule = lop.rules.firstOf("p or r", - paragraphRule, - runRule - ); - - var styleIdRule = lop.rules.then( - classRule, - function(styleId) { - return {styleId: styleId}; - } - ); - - var stringRule = lop.rules.then( - lop.rules.tokenOfType("string"), - function(value) { - return value.substring(1, value.length - 1); - } - ); - - var styleNameRule = lop.rules.then( - lop.rules.sequence( - lop.rules.tokenOfType("open-square-bracket"), - lop.rules.token("identifier", "style-name"), - lop.rules.tokenOfType("equals"), - lop.rules.sequence.capture(stringRule), - lop.rules.tokenOfType("close-square-bracket") - ).head(), - function(styleName) { - return {styleName: styleName}; - } - ); - - - var listTypeRule = lop.rules.firstOf("list type", - identifierToConstant("ordered-list", {isOrdered: true}), - identifierToConstant("unordered-list", {isOrdered: false}) - ); - var listRule = sequence( - lop.rules.tokenOfType("colon"), - sequence.capture(listTypeRule), - sequence.cut(), - lop.rules.tokenOfType("open-paren"), - sequence.capture(integerRule), - lop.rules.tokenOfType("close-paren") - ).map(function(listType, levelNumber) { - return { - list: { - isOrdered: listType.isOrdered, - levelIndex: levelNumber - 1 - } - }; - }); - var matcherSuffix = lop.rules.firstOf("matcher suffix", - styleIdRule, - styleNameRule, - listRule - ); - var matcherSuffixes = lop.rules.zeroOrMore(matcherSuffix); - - return sequence( - sequence.capture(elementTypeRule), - sequence.capture(matcherSuffixes) - ).map(function(createMatcher, suffixes) { - var matcherOptions = {}; - suffixes.forEach(function(suffix) { - _.extend(matcherOptions, suffix); - }); - return createMatcher(matcherOptions); - }); -} - -function readHtmlPath(string) { - return parseString(htmlPathRule(), string); -} - -function htmlPathRule() { - var capture = lop.rules.sequence.capture; - var whitespaceRule = lop.rules.tokenOfType("whitespace"); - var freshRule = lop.rules.then( - lop.rules.optional(lop.rules.sequence( - lop.rules.tokenOfType("colon"), - lop.rules.token("identifier", "fresh") - )), - function(option) { - return option.map(function() { - return true; - }).valueOrElse(false); - } - ); - - var tagNamesRule = lop.rules.oneOrMoreWithSeparator( - identifierRule, - lop.rules.tokenOfType("choice") - ); - - var styleElementRule = lop.rules.sequence( - capture(tagNamesRule), - capture(lop.rules.zeroOrMore(classRule)), - capture(freshRule) - ).map(function(tagName, classNames, fresh) { - var attributes = {}; - var options = {}; - if (classNames.length > 0) { - attributes["class"] = classNames.join(" "); - } - if (fresh) { - options.fresh = true; - } - return htmlPaths.element(tagName, attributes, options); - }); - - return lop.rules.then( - lop.rules.zeroOrMoreWithSeparator( - styleElementRule, - lop.rules.sequence( - whitespaceRule, - lop.rules.tokenOfType("gt"), - whitespaceRule - ) - ), - htmlPaths.elements - ); -} - -var identifierRule = lop.rules.tokenOfType("identifier"); -var integerRule = lop.rules.tokenOfType("integer"); - -var classRule = lop.rules.sequence( - lop.rules.tokenOfType("dot"), - lop.rules.sequence.capture(identifierRule) -).head(); - -function parseString(rule, string) { - var tokens = tokenise(string); - var parser = lop.Parser(); - var parseResult = parser.parseTokens(rule, tokens); - if (!parseResult.isSuccess()) { - throw new Error("Failed to parse: " + describeFailure(parseResult)); - } - return parseResult.value(); -} - -function describeFailure(parseResult) { - return parseResult.errors().map(describeError).join("\n"); - - function describeError(error) { - return error.describe(); - } -} - -function tokenise(string) { - var tokeniser = new RegexTokeniser([ - {name: "identifier", regex: /([a-zA-Z][a-zA-Z0-9\-]*)/}, - {name: "dot", regex: /\./}, - {name: "colon", regex: /:/}, - {name: "gt", regex: />/}, - {name: "whitespace", regex: /\s+/}, - {name: "arrow", regex: /=>/}, - {name: "equals", regex: /=/}, - {name: "open-paren", regex: /\(/}, - {name: "close-paren", regex: /\)/}, - {name: "open-square-bracket", regex: /\[/}, - {name: "close-square-bracket", regex: /\]/}, - {name: "string", regex: /'[^']*'/}, - {name: "integer", regex: /([0-9]+)/}, - {name: "choice", regex: /\|/} - ]); - return tokeniser.tokenise(string); -} - - -var styleRule = createStyleRule(); - -},{"./document-matchers":2,"./html-paths":14,"lop":122,"underscore":136}],21:[function(_dereq_,module,exports){ -exports.paragraph = function(transform) { - function transformElement(element) { - if (element.children) { - for (var i = 0; i < element.children.length; i++) { - element.children[i] = transformElement(element.children[i]); - } - } - if (element.type === "paragraph") { - return transform(element); - } else { - return element; - } - } - return transformElement; -}; - -},{}],22:[function(_dereq_,module,exports){ -var htmlPaths = _dereq_("./html-paths"); - - -exports.element = element; - -function element(name) { - return function(html) { - html.open(htmlPaths.element(name)); - }; -} - -},{"./html-paths":14}],23:[function(_dereq_,module,exports){ -var util = _dereq_("util"); -var _ = _dereq_("underscore"); - -exports.writer = writer; - -function writer(options) { - options = options || {}; - if (options.prettyPrint) { - return prettyWriter(); - } else { - return simpleWriter(); - } -} - - -var indentedElements = { - div: true, - p: true, - ul: true -}; - - -function prettyWriter() { - var indentationLevel = 0; - var indentation = " "; - var stack = []; - var start = true; - var inText = false; - - var writer = simpleWriter(); - - function open(tagName, attributes) { - indent(); - stack.push(tagName); - writer.open(tagName, attributes); - if (indentedElements[tagName]) { - indentationLevel++; - } - start = false; - } - - function close(tagName) { - if (indentedElements[tagName]) { - indentationLevel--; - } - indent(); - stack.pop(); - writer.close(tagName); - } - - function text(value) { - startText(); - writer.text(value.replace("\n", "\n" + indentation)); - } - - function selfClosing(tagName, attributes) { - indent(); - writer.selfClosing(tagName, attributes); - } - - function append(html) { - startText(); - writer.append(html.replace("\n", "\n" + indentation)); - } - - function insideIndentedElement() { - return stack.length === 0 || indentedElements[stack[stack.length - 1]]; - } - - function startText() { - if (!inText) { - indent(); - inText = true; - } - } - - function indent() { - inText = false; - if (!start && insideIndentedElement()) { - writer.append("\n"); - for (var i = 0; i < indentationLevel; i++) { - writer.append(indentation); - } - } - } - - return { - asString: writer.asString, - open: open, - close: close, - text: text, - selfClosing: selfClosing, - append: append - }; -} - - -function simpleWriter() { - var fragments = []; - - function open(tagName, attributes) { - var attributeString = generateAttributeString(attributes); - fragments.push(util.format("<%s%s>", tagName, attributeString)); - } - - function close(tagName) { - fragments.push(util.format("", tagName)); - } - - function selfClosing(tagName, attributes) { - var attributeString = generateAttributeString(attributes); - fragments.push(util.format("<%s%s />", tagName, attributeString)); - } - - function generateAttributeString(attributes) { - return _.map(attributes, function(value, key) { - return util.format(' %s="%s"', key, escapeHtml(value)); - }).join(""); - } - - function text(value) { - fragments.push(escapeHtml(value)); - } - - function append(html) { - fragments.push(html); - } - - function asString() { - return fragments.join(""); - } - - return { - asString: asString, - open: open, - close: close, - text: text, - selfClosing: selfClosing, - append: append - }; -} - - -function escapeHtml(value) { - return value - .replace(/&/g, '&') - .replace(/"/g, '"') - .replace(//g, '>'); -} - -},{"underscore":136,"util":81}],24:[function(_dereq_,module,exports){ -var htmlWriter = _dereq_("./html-writer"); -var markdownWriter = _dereq_("./markdown-writer"); - -exports.writer = writer; - - -function writer(options) { - options = options || {}; - if (options.outputFormat === "markdown") { - return markdownWriter.writer(); - } else { - return htmlWriter.writer(options); - } -} - -},{"./html-writer":23,"./markdown-writer":25}],25:[function(_dereq_,module,exports){ -var _ = _dereq_("underscore"); - - -function symmetricMarkdownElement(end) { - return markdownElement(end, end); -} - -function markdownElement(start, end) { - return function() { - return {start: start, end: end}; - }; -} - -function markdownLink(attributes) { - var href = attributes.href || ""; - if (href) { - return { - start: "[", - end: "](" + href + ")", - anchorPosition: "before" - }; - } else { - return {}; - } -} - -function markdownImage(attributes) { - var src = attributes.src || ""; - var altText = attributes.alt || ""; - if (src || altText) { - return {start: "![" + altText + "](" + src + ")"}; - } else { - return {}; - } -} - -function markdownList(options) { - return function(attributes, list) { - return { - start: list ? "\n" : "", - end: list ? "" : "\n", - list: { - isOrdered: options.isOrdered, - indent: list ? list.indent + 1 : 0, - count: 0 - } - }; - }; -} - -function markdownListItem(attributes, list, listItem) { - list = list || {indent: 0, isOrdered: false, count: 0}; - list.count++; - listItem.hasClosed = false; - - var bullet = list.isOrdered ? list.count + "." : "-"; - var start = repeatString("\t", list.indent) + bullet + " "; - - return { - start: start, - end: function() { - if (!listItem.hasClosed) { - listItem.hasClosed = true; - return "\n"; - } - } - }; -} - -var htmlToMarkdown = { - "p": markdownElement("", "\n\n"), - "br": markdownElement("", " \n"), - "ul": markdownList({isOrdered: false}), - "ol": markdownList({isOrdered: true}), - "li": markdownListItem, - "strong": symmetricMarkdownElement("__"), - "em": symmetricMarkdownElement("*"), - "a": markdownLink, - "img": markdownImage, -}; - -(function() { - for (var i = 1; i <= 6; i++) { - htmlToMarkdown["h" + i] = markdownElement(repeatString("#", i) + " ", "\n\n"); - } -})(); - -function repeatString(value, count) { - return new Array(count + 1).join(value); -} - -function markdownWriter() { - var fragments = []; - var elementStack = []; - var list = null; - var listItem = {}; - - function open(tagName, attributes) { - attributes = attributes || {}; - - var createElement = htmlToMarkdown[tagName] || function() { return {}; }; - var element = createElement(attributes, list, listItem); - elementStack.push({end: element.end, list: list}); - - if (element.list) { - list = element.list; - } - - var anchorBeforeStart = element.anchorPosition === "before"; - if (anchorBeforeStart) { - writeAnchor(attributes); - } - - fragments.push(element.start || ""); - if (!anchorBeforeStart) { - writeAnchor(attributes); - } - } - - function writeAnchor(attributes) { - if (attributes.id) { - fragments.push(''); - } - } - - function close(tagName) { - var element = elementStack.pop(); - list = element.list; - var end = _.isFunction(element.end) ? element.end() : element.end; - fragments.push(end || ""); - } - - function selfClosing(tagName, attributes) { - open(tagName, attributes); - close(tagName); - } - - function text(value) { - fragments.push(escapeMarkdown(value)); - } - - function append(html) { - fragments.push(html); - } - - function asString() { - return fragments.join(""); - } - - return { - asString: asString, - open: open, - close: close, - text: text, - selfClosing: selfClosing, - append: append - }; -} - -exports.writer = markdownWriter; - -function escapeMarkdown(value) { - return value - .replace(/\\/g, '\\\\') - .replace(/([\`\*_\{\}\[\]\(\)\#\+\-\.\!])/g, '\\$1'); -} - -},{"underscore":136}],26:[function(_dereq_,module,exports){ -var promises = _dereq_("./promises"); -var sax = _dereq_("sax"); -var _ = _dereq_("underscore"); - -exports.read = read; -exports.Element = Element; - -function read(xmlString, namespaceMap) { - namespaceMap = namespaceMap || {}; - - var finished = false; - var parser = sax.parser(true, {xmlns: true, position: false}); - - var rootElement = {children: []}; - var currentElement = rootElement; - var stack = []; - - var deferred = promises.defer(); - - parser.onopentag = function(node) { - var attributes = mapObject(node.attributes, function(attribute) { - return attribute.value; - }, mapName); - - var element = new Element(mapName(node), attributes); - currentElement.children.push(element); - stack.push(currentElement); - currentElement = element; - }; - - function mapName(node) { - if (node.uri) { - var mappedPrefix = namespaceMap[node.uri]; - var prefix; - if (mappedPrefix) { - prefix = mappedPrefix; - } else { - prefix = "{" + node.uri + "}"; - } - return prefix + ":" + node.local; - } else { - return node.local; - } - } - - parser.onclosetag = function(node) { - currentElement = stack.pop(); - }; - - parser.ontext = function(text) { - if (currentElement !== rootElement) { - currentElement.children.push({ - type: "text", - value: text - }); - } - }; - - parser.onend = function() { - if (!finished) { - finished = true; - deferred.resolve({ - root: rootElement.children[0] - }); - } - }; - - parser.onerror = function(error) { - if (!finished) { - finished = true; - deferred.reject(error); - } - }; - - parser.write(xmlString).close(); - - return deferred.promise; -} - -function mapObject(input, valueFunc, keyFunc) { - return _.reduce(input, function(result, value, key) { - var mappedKey = keyFunc.call(null, value, key, input); - result[mappedKey] = valueFunc.call(null, value, key, input); - return result; - }, {}); -} - -function Element(name, attributes, children) { - this.type = "element"; - this.name = name; - this.attributes = attributes || {}; - this.children = children || []; -} - -Element.prototype.first = function(name) { - return _.find(this.children, function(child) { - return child.name == name; - }); -}; - -Element.prototype.getElementsByTagName = function(name) { - var elements = _.filter(this.children, function(child) { - return child.name == name; - }); - return toElementList(elements); -}; - -Element.prototype.text = function() { - if (this.children.length === 0) { - return ""; - } else if (this.children.length !== 1 || this.children[0].type !== "text") { - throw new Error("Not implemented"); - } - return this.children[0].value; -}; - -var elementListPrototype = { - getElementsByTagName: function(name) { - return toElementList(_.flatten(this.map(function(element) { - return element.getElementsByTagName(name); - }, true))); - } -}; - -function toElementList(array) { - return _.extend(array, elementListPrototype); -} - -},{"./promises":18,"sax":135,"underscore":136}],27:[function(_dereq_,module,exports){ -(function (Buffer){ -var JSZip = _dereq_("jszip"); - -var promises = _dereq_("./promises"); - -exports.openArrayBuffer = openArrayBuffer; - -function openArrayBuffer(arrayBuffer) { - var zipFile = new JSZip(arrayBuffer); - function exists(name) { - return zipFile.file(name) !== null; - } - - function read(name, encoding) { - var array = zipFile.file(name).asUint8Array(); - var buffer = new Buffer(array); - if (encoding) { - return promises.when(buffer.toString(encoding)); - } else { - return promises.when(buffer); - } - } - return { - exists: exists, - read: read - }; -} - - -}).call(this,_dereq_("buffer").Buffer) -},{"./promises":18,"buffer":66,"jszip":91}],28:[function(_dereq_,module,exports){ -(function (process){ -/*global setImmediate: false, setTimeout: false, console: false */ -(function () { - - var async = {}; - - // global on the server, window in the browser - var root, previous_async; - - root = this; - if (root != null) { - previous_async = root.async; - } - - async.noConflict = function () { - root.async = previous_async; - return async; - }; - - function only_once(fn) { - var called = false; - return function() { - if (called) throw new Error("Callback was already called."); - called = true; - fn.apply(root, arguments); - } - } - - //// cross-browser compatiblity functions //// - - var _each = function (arr, iterator) { - if (arr.forEach) { - return arr.forEach(iterator); - } - for (var i = 0; i < arr.length; i += 1) { - iterator(arr[i], i, arr); - } - }; - - var _map = function (arr, iterator) { - if (arr.map) { - return arr.map(iterator); - } - var results = []; - _each(arr, function (x, i, a) { - results.push(iterator(x, i, a)); - }); - return results; - }; - - var _reduce = function (arr, iterator, memo) { - if (arr.reduce) { - return arr.reduce(iterator, memo); - } - _each(arr, function (x, i, a) { - memo = iterator(memo, x, i, a); - }); - return memo; - }; - - var _keys = function (obj) { - if (Object.keys) { - return Object.keys(obj); - } - var keys = []; - for (var k in obj) { - if (obj.hasOwnProperty(k)) { - keys.push(k); - } - } - return keys; - }; - - //// exported async module functions //// - - //// nextTick implementation with browser-compatible fallback //// - if (typeof process === 'undefined' || !(process.nextTick)) { - if (typeof setImmediate === 'function') { - async.nextTick = function (fn) { - // not a direct alias for IE10 compatibility - setImmediate(fn); - }; - async.setImmediate = async.nextTick; - } - else { - async.nextTick = function (fn) { - setTimeout(fn, 0); - }; - async.setImmediate = async.nextTick; - } - } - else { - async.nextTick = process.nextTick; - if (typeof setImmediate !== 'undefined') { - async.setImmediate = function (fn) { - // not a direct alias for IE10 compatibility - setImmediate(fn); - }; - } - else { - async.setImmediate = async.nextTick; - } - } - - async.each = function (arr, iterator, callback) { - callback = callback || function () {}; - if (!arr.length) { - return callback(); - } - var completed = 0; - _each(arr, function (x) { - iterator(x, only_once(function (err) { - if (err) { - callback(err); - callback = function () {}; - } - else { - completed += 1; - if (completed >= arr.length) { - callback(null); - } - } - })); - }); - }; - async.forEach = async.each; - - async.eachSeries = function (arr, iterator, callback) { - callback = callback || function () {}; - if (!arr.length) { - return callback(); - } - var completed = 0; - var iterate = function () { - iterator(arr[completed], function (err) { - if (err) { - callback(err); - callback = function () {}; - } - else { - completed += 1; - if (completed >= arr.length) { - callback(null); - } - else { - iterate(); - } - } - }); - }; - iterate(); - }; - async.forEachSeries = async.eachSeries; - - async.eachLimit = function (arr, limit, iterator, callback) { - var fn = _eachLimit(limit); - fn.apply(null, [arr, iterator, callback]); - }; - async.forEachLimit = async.eachLimit; - - var _eachLimit = function (limit) { - - return function (arr, iterator, callback) { - callback = callback || function () {}; - if (!arr.length || limit <= 0) { - return callback(); - } - var completed = 0; - var started = 0; - var running = 0; - - (function replenish () { - if (completed >= arr.length) { - return callback(); - } - - while (running < limit && started < arr.length) { - started += 1; - running += 1; - iterator(arr[started - 1], function (err) { - if (err) { - callback(err); - callback = function () {}; - } - else { - completed += 1; - running -= 1; - if (completed >= arr.length) { - callback(); - } - else { - replenish(); - } - } - }); - } - })(); - }; - }; - - - var doParallel = function (fn) { - return function () { - var args = Array.prototype.slice.call(arguments); - return fn.apply(null, [async.each].concat(args)); - }; - }; - var doParallelLimit = function(limit, fn) { - return function () { - var args = Array.prototype.slice.call(arguments); - return fn.apply(null, [_eachLimit(limit)].concat(args)); - }; - }; - var doSeries = function (fn) { - return function () { - var args = Array.prototype.slice.call(arguments); - return fn.apply(null, [async.eachSeries].concat(args)); - }; - }; - - - var _asyncMap = function (eachfn, arr, iterator, callback) { - var results = []; - arr = _map(arr, function (x, i) { - return {index: i, value: x}; - }); - eachfn(arr, function (x, callback) { - iterator(x.value, function (err, v) { - results[x.index] = v; - callback(err); - }); - }, function (err) { - callback(err, results); - }); - }; - async.map = doParallel(_asyncMap); - async.mapSeries = doSeries(_asyncMap); - async.mapLimit = function (arr, limit, iterator, callback) { - return _mapLimit(limit)(arr, iterator, callback); - }; - - var _mapLimit = function(limit) { - return doParallelLimit(limit, _asyncMap); - }; - - // reduce only has a series version, as doing reduce in parallel won't - // work in many situations. - async.reduce = function (arr, memo, iterator, callback) { - async.eachSeries(arr, function (x, callback) { - iterator(memo, x, function (err, v) { - memo = v; - callback(err); - }); - }, function (err) { - callback(err, memo); - }); - }; - // inject alias - async.inject = async.reduce; - // foldl alias - async.foldl = async.reduce; - - async.reduceRight = function (arr, memo, iterator, callback) { - var reversed = _map(arr, function (x) { - return x; - }).reverse(); - async.reduce(reversed, memo, iterator, callback); - }; - // foldr alias - async.foldr = async.reduceRight; - - var _filter = function (eachfn, arr, iterator, callback) { - var results = []; - arr = _map(arr, function (x, i) { - return {index: i, value: x}; - }); - eachfn(arr, function (x, callback) { - iterator(x.value, function (v) { - if (v) { - results.push(x); - } - callback(); - }); - }, function (err) { - callback(_map(results.sort(function (a, b) { - return a.index - b.index; - }), function (x) { - return x.value; - })); - }); - }; - async.filter = doParallel(_filter); - async.filterSeries = doSeries(_filter); - // select alias - async.select = async.filter; - async.selectSeries = async.filterSeries; - - var _reject = function (eachfn, arr, iterator, callback) { - var results = []; - arr = _map(arr, function (x, i) { - return {index: i, value: x}; - }); - eachfn(arr, function (x, callback) { - iterator(x.value, function (v) { - if (!v) { - results.push(x); - } - callback(); - }); - }, function (err) { - callback(_map(results.sort(function (a, b) { - return a.index - b.index; - }), function (x) { - return x.value; - })); - }); - }; - async.reject = doParallel(_reject); - async.rejectSeries = doSeries(_reject); - - var _detect = function (eachfn, arr, iterator, main_callback) { - eachfn(arr, function (x, callback) { - iterator(x, function (result) { - if (result) { - main_callback(x); - main_callback = function () {}; - } - else { - callback(); - } - }); - }, function (err) { - main_callback(); - }); - }; - async.detect = doParallel(_detect); - async.detectSeries = doSeries(_detect); - - async.some = function (arr, iterator, main_callback) { - async.each(arr, function (x, callback) { - iterator(x, function (v) { - if (v) { - main_callback(true); - main_callback = function () {}; - } - callback(); - }); - }, function (err) { - main_callback(false); - }); - }; - // any alias - async.any = async.some; - - async.every = function (arr, iterator, main_callback) { - async.each(arr, function (x, callback) { - iterator(x, function (v) { - if (!v) { - main_callback(false); - main_callback = function () {}; - } - callback(); - }); - }, function (err) { - main_callback(true); - }); - }; - // all alias - async.all = async.every; - - async.sortBy = function (arr, iterator, callback) { - async.map(arr, function (x, callback) { - iterator(x, function (err, criteria) { - if (err) { - callback(err); - } - else { - callback(null, {value: x, criteria: criteria}); - } - }); - }, function (err, results) { - if (err) { - return callback(err); - } - else { - var fn = function (left, right) { - var a = left.criteria, b = right.criteria; - return a < b ? -1 : a > b ? 1 : 0; - }; - callback(null, _map(results.sort(fn), function (x) { - return x.value; - })); - } - }); - }; - - async.auto = function (tasks, callback) { - callback = callback || function () {}; - var keys = _keys(tasks); - if (!keys.length) { - return callback(null); - } - - var results = {}; - - var listeners = []; - var addListener = function (fn) { - listeners.unshift(fn); - }; - var removeListener = function (fn) { - for (var i = 0; i < listeners.length; i += 1) { - if (listeners[i] === fn) { - listeners.splice(i, 1); - return; - } - } - }; - var taskComplete = function () { - _each(listeners.slice(0), function (fn) { - fn(); - }); - }; - - addListener(function () { - if (_keys(results).length === keys.length) { - callback(null, results); - callback = function () {}; - } - }); - - _each(keys, function (k) { - var task = (tasks[k] instanceof Function) ? [tasks[k]]: tasks[k]; - var taskCallback = function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (args.length <= 1) { - args = args[0]; - } - if (err) { - var safeResults = {}; - _each(_keys(results), function(rkey) { - safeResults[rkey] = results[rkey]; - }); - safeResults[k] = args; - callback(err, safeResults); - // stop subsequent errors hitting callback multiple times - callback = function () {}; - } - else { - results[k] = args; - async.setImmediate(taskComplete); - } - }; - var requires = task.slice(0, Math.abs(task.length - 1)) || []; - var ready = function () { - return _reduce(requires, function (a, x) { - return (a && results.hasOwnProperty(x)); - }, true) && !results.hasOwnProperty(k); - }; - if (ready()) { - task[task.length - 1](taskCallback, results); - } - else { - var listener = function () { - if (ready()) { - removeListener(listener); - task[task.length - 1](taskCallback, results); - } - }; - addListener(listener); - } - }); - }; - - async.waterfall = function (tasks, callback) { - callback = callback || function () {}; - if (tasks.constructor !== Array) { - var err = new Error('First argument to waterfall must be an array of functions'); - return callback(err); - } - if (!tasks.length) { - return callback(); - } - var wrapIterator = function (iterator) { - return function (err) { - if (err) { - callback.apply(null, arguments); - callback = function () {}; - } - else { - var args = Array.prototype.slice.call(arguments, 1); - var next = iterator.next(); - if (next) { - args.push(wrapIterator(next)); - } - else { - args.push(callback); - } - async.setImmediate(function () { - iterator.apply(null, args); - }); - } - }; - }; - wrapIterator(async.iterator(tasks))(); - }; - - var _parallel = function(eachfn, tasks, callback) { - callback = callback || function () {}; - if (tasks.constructor === Array) { - eachfn.map(tasks, function (fn, callback) { - if (fn) { - fn(function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (args.length <= 1) { - args = args[0]; - } - callback.call(null, err, args); - }); - } - }, callback); - } - else { - var results = {}; - eachfn.each(_keys(tasks), function (k, callback) { - tasks[k](function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (args.length <= 1) { - args = args[0]; - } - results[k] = args; - callback(err); - }); - }, function (err) { - callback(err, results); - }); - } - }; - - async.parallel = function (tasks, callback) { - _parallel({ map: async.map, each: async.each }, tasks, callback); - }; - - async.parallelLimit = function(tasks, limit, callback) { - _parallel({ map: _mapLimit(limit), each: _eachLimit(limit) }, tasks, callback); - }; - - async.series = function (tasks, callback) { - callback = callback || function () {}; - if (tasks.constructor === Array) { - async.mapSeries(tasks, function (fn, callback) { - if (fn) { - fn(function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (args.length <= 1) { - args = args[0]; - } - callback.call(null, err, args); - }); - } - }, callback); - } - else { - var results = {}; - async.eachSeries(_keys(tasks), function (k, callback) { - tasks[k](function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (args.length <= 1) { - args = args[0]; - } - results[k] = args; - callback(err); - }); - }, function (err) { - callback(err, results); - }); - } - }; - - async.iterator = function (tasks) { - var makeCallback = function (index) { - var fn = function () { - if (tasks.length) { - tasks[index].apply(null, arguments); - } - return fn.next(); - }; - fn.next = function () { - return (index < tasks.length - 1) ? makeCallback(index + 1): null; - }; - return fn; - }; - return makeCallback(0); - }; - - async.apply = function (fn) { - var args = Array.prototype.slice.call(arguments, 1); - return function () { - return fn.apply( - null, args.concat(Array.prototype.slice.call(arguments)) - ); - }; - }; - - var _concat = function (eachfn, arr, fn, callback) { - var r = []; - eachfn(arr, function (x, cb) { - fn(x, function (err, y) { - r = r.concat(y || []); - cb(err); - }); - }, function (err) { - callback(err, r); - }); - }; - async.concat = doParallel(_concat); - async.concatSeries = doSeries(_concat); - - async.whilst = function (test, iterator, callback) { - if (test()) { - iterator(function (err) { - if (err) { - return callback(err); - } - async.whilst(test, iterator, callback); - }); - } - else { - callback(); - } - }; - - async.doWhilst = function (iterator, test, callback) { - iterator(function (err) { - if (err) { - return callback(err); - } - if (test()) { - async.doWhilst(iterator, test, callback); - } - else { - callback(); - } - }); - }; - - async.until = function (test, iterator, callback) { - if (!test()) { - iterator(function (err) { - if (err) { - return callback(err); - } - async.until(test, iterator, callback); - }); - } - else { - callback(); - } - }; - - async.doUntil = function (iterator, test, callback) { - iterator(function (err) { - if (err) { - return callback(err); - } - if (!test()) { - async.doUntil(iterator, test, callback); - } - else { - callback(); - } - }); - }; - - async.queue = function (worker, concurrency) { - if (concurrency === undefined) { - concurrency = 1; - } - function _insert(q, data, pos, callback) { - if(data.constructor !== Array) { - data = [data]; - } - _each(data, function(task) { - var item = { - data: task, - callback: typeof callback === 'function' ? callback : null - }; - - if (pos) { - q.tasks.unshift(item); - } else { - q.tasks.push(item); - } - - if (q.saturated && q.tasks.length === concurrency) { - q.saturated(); - } - async.setImmediate(q.process); - }); - } - - var workers = 0; - var q = { - tasks: [], - concurrency: concurrency, - saturated: null, - empty: null, - drain: null, - push: function (data, callback) { - _insert(q, data, false, callback); - }, - unshift: function (data, callback) { - _insert(q, data, true, callback); - }, - process: function () { - if (workers < q.concurrency && q.tasks.length) { - var task = q.tasks.shift(); - if (q.empty && q.tasks.length === 0) { - q.empty(); - } - workers += 1; - var next = function () { - workers -= 1; - if (task.callback) { - task.callback.apply(task, arguments); - } - if (q.drain && q.tasks.length + workers === 0) { - q.drain(); - } - q.process(); - }; - var cb = only_once(next); - worker(task.data, cb); - } - }, - length: function () { - return q.tasks.length; - }, - running: function () { - return workers; - } - }; - return q; - }; - - async.cargo = function (worker, payload) { - var working = false, - tasks = []; - - var cargo = { - tasks: tasks, - payload: payload, - saturated: null, - empty: null, - drain: null, - push: function (data, callback) { - if(data.constructor !== Array) { - data = [data]; - } - _each(data, function(task) { - tasks.push({ - data: task, - callback: typeof callback === 'function' ? callback : null - }); - if (cargo.saturated && tasks.length === payload) { - cargo.saturated(); - } - }); - async.setImmediate(cargo.process); - }, - process: function process() { - if (working) return; - if (tasks.length === 0) { - if(cargo.drain) cargo.drain(); - return; - } - - var ts = typeof payload === 'number' - ? tasks.splice(0, payload) - : tasks.splice(0); - - var ds = _map(ts, function (task) { - return task.data; - }); - - if(cargo.empty) cargo.empty(); - working = true; - worker(ds, function () { - working = false; - - var args = arguments; - _each(ts, function (data) { - if (data.callback) { - data.callback.apply(null, args); - } - }); - - process(); - }); - }, - length: function () { - return tasks.length; - }, - running: function () { - return working; - } - }; - return cargo; - }; - - var _console_fn = function (name) { - return function (fn) { - var args = Array.prototype.slice.call(arguments, 1); - fn.apply(null, args.concat([function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (typeof console !== 'undefined') { - if (err) { - if (console.error) { - console.error(err); - } - } - else if (console[name]) { - _each(args, function (x) { - console[name](x); - }); - } - } - }])); - }; - }; - async.log = _console_fn('log'); - async.dir = _console_fn('dir'); - /*async.info = _console_fn('info'); - async.warn = _console_fn('warn'); - async.error = _console_fn('error');*/ - - async.memoize = function (fn, hasher) { - var memo = {}; - var queues = {}; - hasher = hasher || function (x) { - return x; - }; - var memoized = function () { - var args = Array.prototype.slice.call(arguments); - var callback = args.pop(); - var key = hasher.apply(null, args); - if (key in memo) { - callback.apply(null, memo[key]); - } - else if (key in queues) { - queues[key].push(callback); - } - else { - queues[key] = [callback]; - fn.apply(null, args.concat([function () { - memo[key] = arguments; - var q = queues[key]; - delete queues[key]; - for (var i = 0, l = q.length; i < l; i++) { - q[i].apply(null, arguments); - } - }])); - } - }; - memoized.memo = memo; - memoized.unmemoized = fn; - return memoized; - }; - - async.unmemoize = function (fn) { - return function () { - return (fn.unmemoized || fn).apply(null, arguments); - }; - }; - - async.times = function (count, iterator, callback) { - var counter = []; - for (var i = 0; i < count; i++) { - counter.push(i); - } - return async.map(counter, iterator, callback); - }; - - async.timesSeries = function (count, iterator, callback) { - var counter = []; - for (var i = 0; i < count; i++) { - counter.push(i); - } - return async.mapSeries(counter, iterator, callback); - }; - - async.compose = function (/* functions... */) { - var fns = Array.prototype.reverse.call(arguments); - return function () { - var that = this; - var args = Array.prototype.slice.call(arguments); - var callback = args.pop(); - async.reduce(fns, args, function (newargs, fn, cb) { - fn.apply(that, newargs.concat([function () { - var err = arguments[0]; - var nextargs = Array.prototype.slice.call(arguments, 1); - cb(err, nextargs); - }])) - }, - function (err, results) { - callback.apply(that, [err].concat(results)); - }); - }; - }; - - var _applyEach = function (eachfn, fns /*args...*/) { - var go = function () { - var that = this; - var args = Array.prototype.slice.call(arguments); - var callback = args.pop(); - return eachfn(fns, function (fn, cb) { - fn.apply(that, args.concat([cb])); - }, - callback); - }; - if (arguments.length > 2) { - var args = Array.prototype.slice.call(arguments, 2); - return go.apply(this, args); - } - else { - return go; - } - }; - async.applyEach = doParallel(_applyEach); - async.applyEachSeries = doSeries(_applyEach); - - async.forever = function (fn, callback) { - function next(err) { - if (err) { - if (callback) { - return callback(err); - } - throw err; - } - fn(next); - } - next(); - }; - - // AMD / RequireJS - if (typeof define !== 'undefined' && define.amd) { - define([], function () { - return async; - }); - } - // Node.js - else if (typeof module !== 'undefined' && module.exports) { - module.exports = async; - } - // included directly via