Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a new EPUB stylesheet and the various bits of machinery needed to produce a basic EPUB file. Currently, the code is very incomplete and the resulting EPUB is unpleasant to look at due to CSS (or lack of). Affects: #13
- Loading branch information
Showing
23 changed files
with
1,925 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...structural.cmdline/src/main/java/com/io7m/xstructural/cmdline/XSCommandTransformEPUB.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Copyright © 2020 Mark Raynsford <code@io7m.com> http://io7m.com | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
package com.io7m.xstructural.cmdline; | ||
|
||
import com.beust.jcommander.Parameter; | ||
import com.beust.jcommander.Parameters; | ||
import com.io7m.xstructural.api.XSProcessorRequest; | ||
import com.io7m.xstructural.cmdline.internal.XSServices; | ||
|
||
import java.nio.file.Path; | ||
|
||
import static com.io7m.xstructural.api.XSProcessorRequestType.Stylesheet; | ||
import static com.io7m.xstructural.api.XSProcessorRequestType.Task; | ||
|
||
@Parameters(commandDescription = "Transform a structural document to an EPUB") | ||
final class XSCommandTransformEPUB extends XSCommandRoot | ||
{ | ||
@Parameter( | ||
required = true, | ||
description = "The source document", | ||
names = "--sourceFile" | ||
) | ||
private Path sourceFile; | ||
|
||
@Parameter( | ||
required = true, | ||
description = "The output directory", | ||
names = "--outputDirectory" | ||
) | ||
private Path outputDirectory; | ||
|
||
@Parameter( | ||
required = false, | ||
description = "The output file for trace messages", | ||
names = "--traceFile" | ||
) | ||
private Path traceFile; | ||
|
||
@Parameter( | ||
required = false, | ||
description = "The output file for XSLT messages", | ||
names = "--messagesFile" | ||
) | ||
private Path messagesFile; | ||
|
||
XSCommandTransformEPUB() | ||
{ | ||
|
||
} | ||
|
||
@Override | ||
public Status execute() | ||
throws Exception | ||
{ | ||
if (super.execute() == Status.FAILURE) { | ||
return Status.FAILURE; | ||
} | ||
|
||
final var requestBuilder = XSProcessorRequest.builder(); | ||
requestBuilder.setOutputDirectory(this.outputDirectory.toAbsolutePath()); | ||
requestBuilder.setSourceFile(this.sourceFile.toAbsolutePath()); | ||
requestBuilder.setStylesheet(Stylesheet.EPUB); | ||
requestBuilder.setTask(Task.TRANSFORM_EPUB); | ||
requestBuilder.setWriteResources(false); | ||
|
||
if (this.traceFile != null) { | ||
requestBuilder.setTraceFile(this.traceFile.toAbsolutePath()); | ||
} | ||
if (this.messagesFile != null) { | ||
requestBuilder.setMessageFile(this.messagesFile.toAbsolutePath()); | ||
} | ||
|
||
final var request = requestBuilder.build(); | ||
final var processors = XSServices.findProcessors(); | ||
final var processor = processors.create(request); | ||
processor.execute(); | ||
return Status.SUCCESS; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
com.io7m.xstructural.tests/src/test/resources/com/io7m/xstructural/tests/example3.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
|
||
<Document xmlns="urn:com.io7m.structural:7:0" | ||
xmlns:dc="http://purl.org/dc/elements/1.1/" | ||
tableOfContentsDepth="3" | ||
tableOfContents="true"> | ||
|
||
<Metadata> | ||
<dc:contributor>A Contributor</dc:contributor> | ||
<dc:creator>A Creator</dc:creator> | ||
<dc:description>An example article.</dc:description> | ||
<dc:identifier>7486b85a-30de-4007-8b32-679b8a851b91</dc:identifier> | ||
<dc:language>English</dc:language> | ||
<dc:publisher>A Publisher</dc:publisher> | ||
<dc:relation>A Relation</dc:relation> | ||
<dc:rights>CC-0</dc:rights> | ||
<dc:source>A Source</dc:source> | ||
<dc:title>Example Document</dc:title> | ||
</Metadata> | ||
|
||
<Section title="08eb2001-58ef-44be-acce-5eecee051515"> | ||
<Paragraph> | ||
No bagel. | ||
</Paragraph> | ||
<Paragraph> | ||
No bagel. | ||
</Paragraph> | ||
<Paragraph> | ||
No bagel. | ||
</Paragraph> | ||
<Paragraph> | ||
No bagel. | ||
</Paragraph> | ||
</Section> | ||
|
||
</Document> |
Binary file added
BIN
+20.4 KB
...o7m.xstructural.tests/src/test/resources/com/io7m/xstructural/tests/missing.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+29.7 KB
com.io7m.xstructural.tests/src/test/resources/com/io7m/xstructural/tests/woods.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.