Skip to content

Commit

Permalink
Run test for emphasis indicators in Norwegian
Browse files Browse the repository at this point in the history
see issue #6
  • Loading branch information
bertfrees committed Mar 5, 2015
1 parent e4d8156 commit 0171463
Show file tree
Hide file tree
Showing 8 changed files with 276 additions and 4 deletions.
12 changes: 12 additions & 0 deletions RunTestsAndProcessFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,19 @@ public Option[] config() {
mavenBundle().groupId("org.daisy.dotify").artifactId("dotify.formatter.impl").versionAsInProject(),
mavenBundle().groupId("net.java.dev.jna").artifactId("jna").versionAsInProject(),
mavenBundle().groupId("org.liblouis").artifactId("liblouis-java").versionAsInProject(),
mavenBundle().groupId("org.daisy.bindings").artifactId("jhyphen").versionAsInProject(),
brailleModule("common-utils"),
brailleModule("dotify-calabash"),
brailleModule("dotify-formatter"),
brailleModule("liblouis-core"),
brailleModule("liblouis-saxon"),
forThisPlatform(brailleModule("liblouis-native")),
brailleModule("liblouis-calabash"),
brailleModule("liblouis-formatter"),
brailleModule("liblouis-mathml"),
brailleModule("liblouis-utils"),
brailleModule("liblouis-tables"),
brailleModule("libhyphen-core"),
brailleModule("css-core"),
brailleModule("css-calabash"),
brailleModule("css-utils"),
Expand All @@ -92,6 +99,11 @@ public Option[] config() {
brailleModule("pef-to-html"),
brailleModule("pef-utils"),
pipelineModule("file-utils"),
pipelineModule("common-utils"),
pipelineModule("html-utils"),
pipelineModule("zip-utils"),
pipelineModule("mediatype-utils"),
pipelineModule("fileset-utils"),
xprocspecBundles(),
xspecBundles(),
mavenBundle().groupId("org.daisy.pipeline").artifactId("saxon-adapter").versionAsInProject(),
Expand Down
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,13 @@
</dependency>
<dependency>
<groupId>org.daisy.pipeline.modules.braille</groupId>
<artifactId>liblouis-saxon</artifactId>
<artifactId>liblouis-utils</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.daisy.pipeline.modules.braille</groupId>
<artifactId>liblouis-tables</artifactId>
<version>2.5.4-p1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
7 changes: 7 additions & 0 deletions src/index.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@
The system shall support marking of text-level semantics (i.e. em, strong) with braille
indicators.
</h3>
<p>
The system shall support marking of text-level semantics with Braille indicators in
Norwegian uncontracted braille.
</p>
<div>
<a class="test-src" href="test/38_nlb/test.xprocspec#38.1"/>
</div>
<p class="todo">
tests: text with text-level semantics (xml) --> braille translation
</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<level1 id="level1_7" class="chapter">
<level1 id="level1_7" class="chapter" xml:lang="no">
<pagenum id="p9" page="normal">9</pagenum>
<h1 id="h1_2">1 Rampete Robins mareritt</h1>
<p>Kroppen var dekket av slim, blodet dryppet fra hoggtennene, den hylte og skar tenner — og <em>gikk til angrep!</em>» skrek Frekke Fredrik.</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
 <page>
<pef xmlns="http://www.daisy.org/ns/2008/pef" version="2008-1">
<head xmlns:dc="http://purl.org/dc/elements/1.1/">
<meta>
<dc:format>application/x-pef+xml</dc:format>
</meta>
</head>
<body>
<volume rows="28" cols="32" rowgap="0" duplex="false">
<section>
<page>
<row>⠿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀</row>
<row>⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀</row>
<row>⠀⠀⠀⠀⠀⠀⠀⠼⠁⠀⠠⠗⠁⠍⠏⠑⠞⠑⠀⠠⠗⠕⠃⠊⠝⠎⠀⠀⠀⠀⠀⠀</row>
Expand Down Expand Up @@ -28,4 +37,7 @@
<row>⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀</row>
<row>⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠼⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠿⠼⠊</row>
</page>

</section>
</volume>
</body>
</pef>
17 changes: 17 additions & 0 deletions src/test/38_nlb/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@page { size: 32 28; }

pagenum { display: none }

h1 {
display: block;
margin-left: 2;
text-indent: 5;
border-bottom: ⠉;
margin-bottom: 1;
}

p {
display: block;
margin-left: 2;
text-indent: 2;
}
41 changes: 41 additions & 0 deletions src/test/38_nlb/test.xprocspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description xmlns:x="http://www.daisy.org/ns/xprocspec"
xmlns:pxi="http://www.daisy.org/ns/pipeline/xproc/internal"
xmlns:p="http://www.w3.org/ns/xproc"
xmlns:px="http://www.daisy.org/ns/pipeline/xproc"
xmlns:pef="http://www.daisy.org/ns/2008/pef"
xmlns:dotify="http://code.google.com/p/dotify/"
xmlns:css="http://www.daisy.org/ns/pipeline/braille-css">

<x:script>
<p:declare-step type="pxi:translate" version="1.0">
<p:input port="source"/>
<p:output port="result"/>
<p:option name="stylesheet" required="true"/>
<p:import href="http://www.daisy.org/pipeline/modules/braille/dotify-formatter/library.xpl"/>
<p:import href="http://www.daisy.org/pipeline/modules/braille/css-calabash/library.xpl"/>
<p:import href="http://www.daisy.org/pipeline/modules/braille/common-utils/library.xpl"/>
<css:inline>
<p:with-option name="default-stylesheet" select="resolve-uri($stylesheet)"/>
</css:inline>
<px:transform type="css-block" query=""/>
<dotify:format/>
</p:declare-step>
</x:script>

<x:scenario id="38.1" label="Text marked up with &lt;strong&gt; and &lt;em&gt; should get braille indicators in Norwegian uncontracted">
<x:call step="pxi:translate">
<x:input port="source">
<x:document type="file" href="../../resources/translation/Test.DTBook.Norwegian transl.Uncontracted braille.Emphasis indicators.xml"/>
</x:input>
<x:option name="stylesheet" select="'style.css'"/>
</x:call>
<x:context label="result">
<x:document type="port" port="result"/>
</x:context>
<x:expect label="result" type="custom" href="http://www.daisy.org/pipeline/modules/braille/pef-utils/library.xpl" step="x:pef-compare">
<x:document type="file" href="../../resources/translation/Test.PEF.Norwegian transl.Uncontracted braille.Emphasis indicators.pef"/>
</x:expect>
</x:scenario>

</x:description>
177 changes: 177 additions & 0 deletions src/test/38_nlb/test.xprocspec.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:x="http://www.daisy.org/ns/xprocspec"
xmlns:pef="http://www.daisy.org/ns/2008/pef"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="#all"
version="2.0">

<xsl:include href="../common/serialize.xsl"/>
<xsl:include href="http://www.daisy.org/pipeline/modules/braille/pef-utils/library.xsl"/>

<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="x:description">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<link rel="stylesheet" type="text/css" href="../../style.css"/>
<link rel="stylesheet" href="../../github.min.css"/>
<script type="text/javascript" src="../../jquery.min.js"/>
<script type="text/javascript" src="../../highlight.min.js"/>
<script type="text/javascript">
$(document).ready(function() {
$("code").each(function(i, block) {
hljs.highlightBlock(block);
});
$(".document.pef").each(function(i, div) {
var x = ["pef-xml", "pef-ascii", "pef-unicode"];
x.forEach(function(clazz) {
$(div).children("a." + clazz).click((function(clazz) {
return function(e) {
e.preventDefault();
$(div).removeClass("pef-xml pef-ascii pef-unicode");
$(div).addClass(clazz);
}
})(clazz));
});
});
});
</script>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="x:scenario">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:if test="not(child::x:documentation)">
<x:documentation>
<xsl:variable name="ul">
<wrap xml:base="{base-uri(.)}">
<ul>
<xsl:variable name="source" select="x:call/x:input[@port='source']/x:document"/>
<xsl:if test="$source">
<li>
<xsl:call-template name="x:document-as-code">
<xsl:with-param name="x:document" select="$source"/>
<xsl:with-param name="with-title">source</xsl:with-param>
</xsl:call-template>
</li>
</xsl:if>
<xsl:if test="x:call/x:option[@name='stylesheet']">
<li>
<a class="code" href="{replace(x:call/x:option[@name='stylesheet']/@select, '^.(.*).$', '$1')}">stylesheet</a>
</li>
</xsl:if>
<xsl:variable name="result" select="x:expect[preceding-sibling::x:context[1]/x:document[@port='result']]/x:document"/>
<xsl:if test="$result">
<li>
<xsl:call-template name="x:document-as-code">
<xsl:with-param name="x:document" select="$result"/>
<xsl:with-param name="with-title">result</xsl:with-param>
<xsl:with-param name="with-class" select="if ($result/parent::*/@step='x:pef-compare') then 'pef' else ''"/>
</xsl:call-template>
</li>
</xsl:if>
</ul>
</wrap>
</xsl:variable>
<xsl:apply-templates select="$ul/*/html:ul"/>
</x:documentation>
</xsl:if>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>

<xsl:template name="x:document-as-code">
<xsl:param name="x:document"/>
<xsl:param name="with-title"/>
<xsl:param name="with-class"/>
<xsl:choose>
<xsl:when test="$x:document/@type='file'">
<a href="{$x:document/@href}" class="{string-join(('code', $with-class), ' ')}">
<xsl:sequence select="$with-title"/>
</a>
</xsl:when>
<xsl:when test="$x:document/@type='inline'">
<span>
<xsl:sequence select="$with-title"/>
<div class="{string-join(('document', $with-class), ' ')}">
<code>
<xsl:if test="$with-class">
<xsl:attribute name="class" select="$with-class"/>
</xsl:if>
<xsl:apply-templates select="$x:document/*" mode="serialize"/>
</code>
<xsl:if test="tokenize($with-class, '\s+')='pef'">
<xsl:sequence select="$x:document/pef:pef"/>
<a class="pef-xml" href="#">xml</a>
<a class="pef-unicode" href="#">unicode</a>
<a class="pef-ascii" href="#">ascii</a>
</xsl:if>
</div>
</span>
</xsl:when>
</xsl:choose>
</xsl:template>

<xsl:template match="html:a[tokenize(@class, '\s+')='code']">
<span>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
<xsl:variable name="class" select="string-join(tokenize(@class, '\s+')[not('code'=.)], ' ')"/>
<div class="{string-join(('document', $class), ' ')}">
<code>
<xsl:if test="$class!=''">
<xsl:attribute name="class" select="$class"/>
</xsl:if>
<xsl:value-of select="unparsed-text(resolve-uri(@href, base-uri(/*)))"/>
</code>
<xsl:if test="tokenize($class, '\s+')='pef'">
<xsl:apply-templates select="document(resolve-uri(@href, base-uri(/*)))/pef:pef"/>
<a class="pef-xml" href="#">xml</a>
<a class="pef-unicode" href="#">unicode</a>
<a class="pef-ascii" href="#">ascii</a>
</xsl:if>
</div>
</span>
</xsl:template>

<xsl:template match="pef:page">
<xsl:variable name="rows" select="xs:integer(number(ancestor::*[@rows][1]/@rows))"/>
<xsl:variable name="cols" select="xs:integer(number(ancestor::*[@cols][1]/@cols))"/>
<!--
TODO: which encoding is used in Norway?
-->
<xsl:variable name="table" select="'org.daisy.braille.table.DefaultTableProvider.TableType.EN_US'"/>
<xsl:copy>
<xsl:sequence select="@*"/>
<xsl:for-each select="pef:row">
<xsl:variable name="row" select="string-join((string(.), for $x in string-length(string(.)) + 1 to $cols return '&#x2800;'), '')"/>
<pef:row>
<xsl:sequence select="$row"/>
</pef:row>
<pef:row class="ascii">
<xsl:sequence select="pef:encode($table, $row)"/>
</pef:row>
</xsl:for-each>
<xsl:for-each select="count(pef:row) + 1 to $rows">
<xsl:variable name="row" select="string-join(for $x in 1 to $cols return '&#x2800;', '')"/>
<pef:row>
<xsl:sequence select="$row"/>
</pef:row>
<pef:row class="ascii">
<xsl:sequence select="pef:encode($table, $row)"/>
</pef:row>
</xsl:for-each>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

0 comments on commit 0171463

Please sign in to comment.