Commit e9984626 authored by Neveux Anais's avatar Neveux Anais

Merge branch 'master' of gitlab.utc.fr:crozatst/hdoc

parents b718f5dc 31638183
...@@ -54,7 +54,14 @@ Example : ...@@ -54,7 +54,14 @@ Example :
Currently available on: https://framemo.org/framapad_to_opale Currently available on: https://framemo.org/framapad_to_opale
See also : https://bimestriel.framapad.org/p/nf29_framapad_to_opale for the full documentation of our working process.
## TODO ## TODO
- Nested Lists
- Indentation
- Titles (and therefore Structure of the doc)
- Coloured text
- Code
- Markdown - Markdown
## Technical notes ## Technical notes
......
This diff is collapsed.
libdir=${basedir}/lib libdir=${basedir}/lib
xsldir=${basedir}/xsl xsldir=${basedir}/xsl
inputPath=${basedir}/input inputPath=${basedir}/input
outputPath=${basedir}/output tmpHdoc=${basedir}/tmp_hdoc
\ No newline at end of file outputPath=${basedir}/output
<project name="hdoc_to_elasticsearch" default="unzipSource"> <project name="hdoc_to_elasticsearch" default="clean">
<property file="build.properties"/> <property file="build.properties"/>
<target name="unzipSource">
<target name="unzipSource">
<echo message="Conversion begin" /> <echo message="Conversion begin" />
<path id="hdocDirPath"> <path id="hdocDirPath">
<fileset dir="${inputPath}" id="hdocFile"> <fileset dir="${inputPath}" id="hdocFile">
<include name="*.hdoc"/> <include name="*.hdoc"/>
</fileset> </fileset>
</path> </path>
<property name="hdocFile" refId="hdocDirPath"/>
<property name="hdocFile" refId="hdocDirPath"/>
<basename property="hdocFileName" file="${hdocFile}" suffix=".hdoc"/> <basename property="hdocFileName" file="${hdocFile}" suffix=".hdoc"/>
<echo>Entry file : ${hdocFileName}</echo>
<echo>Entry file : ${hdocFileName}</echo>
<!-- create subdirectory for each file --> <!-- create subdirectory for each file -->
<mkdir dir="${outputPath}/${hdocFileName}"/> <mkdir dir="${tmpHdoc}/${hdocFileName}"/>
<!--unzips the hdoc to be converted into the previously created directory--> <!--unzips the hdoc to be converted into the previously created directory-->
<unzip dest="${outputPath}/${hdocFileName}"> <unzip dest="${tmpHdoc}/${hdocFileName}">
<fileset dir="${inputPath}" id="hdocFile"> <fileset dir="${inputPath}" id="hdocFile">
<include name="${hdocFileName}.hdoc"/> <include name="${hdocFileName}.hdoc"/>
</fileset> </fileset>
</unzip> </unzip>
<echo message="Conversion end" />
</target> </target>
<target name="jsonFiles" depends="unzipSource"> <target name="jsonFiles" depends="unzipSource">
<echo message="JSON File creation" /> <echo message="JSON File creation" />
<!-- TODO : create JSON & extract data --> <xslt in="${tmpHdoc}/${hdocFileName}/content.xml" out="${outputPath}/${hdocFileName}.json" style="xsl/content_extractor.xsl"/>
</target> </target>
<!-- Clear tmp files --> <!-- Clear tmp files -->
<target name="clean" depends="jsonFiles"> <target name="clean" depends="jsonFiles">
<echo message="Clean files" />
</target> <!-- -->
<delete includeemptydirs="true" verbose="true">
<fileset dir="${tmpHdoc}"> </fileset>
<dirset dir="${tmpHdoc}" includes="**/*" />
</delete>
<echo message="Conversion end" />
</target>
</project>
<echo message="Conversion end" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
exclude-result-prefixes="xs"
version="2.0">
<xsl:output omit-xml-declaration="yes"
encoding="UTF-8">
<!-- Encodage UTF-8 pour caractères spéciaux (accents...) -->
</xsl:output>
<!-- -->
<xsl:template match="/" >
{
<xsl:apply-templates select="html"/>
}
</xsl:template>
<!-- Extraction des informations du head -->
<xsl:template match="head">
"title" : "<xsl:value-of select="title/text()"/>",
"keywords" : [
<xsl:for-each select="meta[@name='keywords']">
"<xsl:value-of select="@content"/>"<xsl:if test="position() != last()">,</xsl:if>
</xsl:for-each>
],
<xsl:apply-templates select="meta"/>
</xsl:template>
<!-- Extraction des informations du body -->
<xsl:template match="body" />
<xsl:template match="meta[@name='author']">
"author" : "<xsl:value-of select="@content"/>"
</xsl:template>
<xsl:template match="meta[@name='date']">
"date" : "<xsl:value-of select="@content"/>",
</xsl:template>
<xsl:template match="meta[@name='rights']">
"rights" : "<xsl:value-of select="@content"/>",
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
...@@ -35,15 +35,23 @@ La personne possède un hdoc et voudrait le convertir en epub. Il se dirige vers ...@@ -35,15 +35,23 @@ La personne possède un hdoc et voudrait le convertir en epub. Il se dirige vers
Unsupported Unsupported
----------- -----------
Known bugs Known bugs
---------- ----------
Problème dans le hdoc : contient des images mais ne sont pas référencées.
Problème avec les keywords : le hdoc contient des keywords mais nous ne savons pas où les utiliser.
Todo list Todo list
--------- ---------
Validation de l'epub actuel
Mise en place de la première page
Validation
Étude compatibilité entre EPUB2 et EPUB3
Technical Notes Technical Notes
--------------- ---------------
<?xml version="1.0"?> <?xml version="1.0"?>
<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0"> <container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
<rootfiles> <rootfiles>
<rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/> <rootfile full-path="oebps/content.opf" media-type="application/oebps-package+xml"/>
</rootfiles> </rootfiles>
</container> </container>
...@@ -7,9 +7,12 @@ ...@@ -7,9 +7,12 @@
<property name="in" location="${basedir}/input"/> <property name="in" location="${basedir}/input"/>
<property name="out" location="${basedir}/output"/> <property name="out" location="${basedir}/output"/>
<property name="tmp" location="${basedir}/tmp"/> <property name="tmp" location="${basedir}/tmp"/>
<property name="xsl" location="${basedir}/xsl"/>
<property name="file" location="${basedir}/file"/> <property name="file" location="${basedir}/file"/>
<property name="schema" location="${basedir}/schema"/> <property name="schema" location="${basedir}/schema"/>
<property name="lib" location="${basedir}/lib"/>
<property name="tmpRetour" location="${basedir}/tmp/retour"/>
<target name="convert"> <target name="convert">
<delete dir="${tmp}" failonerror="false"/> <delete dir="${tmp}" failonerror="false"/>
<sleep seconds="1"/> <sleep seconds="1"/>
...@@ -18,6 +21,8 @@ ...@@ -18,6 +21,8 @@
<delete dir="${out}" failonerror="false"/> <delete dir="${out}" failonerror="false"/>
<sleep seconds="1"/> <sleep seconds="1"/>
<mkdir dir="${out}"/> <mkdir dir="${out}"/>
<mkdir dir="${tmpRetour}"/>
<for param="inputFile"> <for param="inputFile">
<path> <path>
...@@ -27,7 +32,7 @@ ...@@ -27,7 +32,7 @@
<sequential> <sequential>
<local name="filename"/> <local name="filename"/>
<basename property="filename" file="@{inputFile}"/> <basename property="filename" file="@{inputFile}"/>
<antcall target="UnzipHdocFile"> <antcall target="UnzipHdocFile">
<param name="filename" value="${filename}"/> <param name="filename" value="${filename}"/>
</antcall> </antcall>
...@@ -36,12 +41,27 @@ ...@@ -36,12 +41,27 @@
<param name="filename" value="${filename}"/> <param name="filename" value="${filename}"/>
</antcall> </antcall>
<antcall target="MakeOCF"/> <antcall target="MakeOCF">
<param name="filename" value="${filename}"/>
</antcall>
<!--<antcall target="MakeOPF"/> --> <antcall target="MakeOPF">
<param name="filename" value="${filename}"/>
</antcall>
<antcall target="MakeOPS">
<param name="filename" value="${filename}"/>
</antcall>
<antcall target="MakeOPS"/> <antcall target="ZipEpubFile">
<param name="filename" value="${filename}"/>
</antcall>
<antcall target="ValidateOutput">
<param name="filename" value="${filename}"/>
</antcall>
<antcall target="CleanTmp"/>
</sequential> </sequential>
</for> </for>
</target> </target>
...@@ -66,20 +86,49 @@ ...@@ -66,20 +86,49 @@
</target> </target>
<target name="MakeOCF"> <target name="MakeOCF">
<mkdir dir="${out}/META-INF"/> <mkdir dir="${tmpRetour}/META-INF"/>
<mkdir dir="${out}/oebps"/> <mkdir dir="${tmpRetour}/oebps"/>
<copy file="${file}/mimetype" todir="${out}"/> <copy file="${file}/mimetype" todir="${tmpRetour}"/>
<copy file="${file}/container.xml" todir="${out}/META-INF"/> <copy file="${file}/container.xml" todir="${tmpRetour}/META-INF"/>
</target> </target>
<target name="MakeOPF"> <target name="MakeOPF">
<xslt in="${tmp}/${filename}/decompressedHdoc/content.xml" out="${tmpRetour}/oebps/content.opf" classpath="${lib}/saxon9he.jar" style="${xsl}/content.xsl"/>
</target> </target>
<target name="MakeOPS"> <target name="MakeOPS">
<mkdir dir="${out}/oebps/images"/> <mkdir dir="${tmpRetour}/oebps/images"/>
<mkdir dir="${out}/oebps/styles"/> <copy todir="${tmpRetour}/oebps/images">
<mkdir dir="${out}/oebps/text"/> <fileset dir="${tmp}/${filename}/decompressedHdoc/re" includes="**"/>
</copy>
<mkdir dir="${tmpRetour}/oebps/styles"/>
<mkdir dir="${tmpRetour}/oebps/chapitres"/>
<xslt in="${tmp}/${filename}/decompressedHdoc/content.xml" out="${tmpRetour}/oebps/tableDesMatieres.ncx" classpath="${lib}/saxon9he.jar" style="${xsl}/tdmncx.xsl"/>
<xslt destdir="${tmpRetour}/oebps/chapitres" basedir="${tmp}/${filename}/decompressedHdoc" includes="content.xml" classpath="${lib}/saxon9he.jar" style="${xsl}/chapitre.xsl"/>
<delete file="${tmpRetour}/oebps/chapitres/content.html"/>
</target> </target>
<target name="ZipEpubFile">
<propertyregex property="properFilename" input="${filename}" regexp=".hdoc" replace="" casesensitive="false" override="true" />
<zip destfile="${out}/${properFilename}.epub" update="true" encoding="UTF-8">
<zipfileset dir="${tmpRetour}/META-INF"
includes="*" prefix="META-INF"/>
<zipfileset dir="${tmpRetour}/oebps"
includes="**" prefix="oebps"/>
</zip>
<!-- zip64Mode="never" -->
<zip destfile="${out}/${properFilename}.epub" update="true" compress="false" encoding="UTF-8" keepcompression="true" createunicodeextrafields="never">
<zipfileset dir="${tmpRetour}"
includes="mimetype"/>
</zip>
</target>
<target name="ValidateOutput">
</target>
<target name="CleanTmp">
<delete dir="${tmp}" failonerror="false"/>
</target>
</project> </project>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
xmlns="http://www.w3.org/1999/xhtml"
version="2.0">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="/html" priority="10">
<xsl:for-each select="body/section">
<xsl:variable name="path">../../../retour/oebps/chapitres/chapitre<xsl:number level="multiple" count="section" format="1"/>.xhtml</xsl:variable>
<xsl:result-document method="xml" href="{$path}">
<html xml:lang="en" lang="en" xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<title><xsl:value-of select="header/h1"/></title>
</head>
<body>
<h1><xsl:value-of select="header/h1"/></h1>
<xsl:apply-templates select="div|section"/>
</body>
</html>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
<xsl:template match="section" priority="3">
<xsl:element name="h{count(ancestor::section)+1}">
<xsl:value-of select="header/h1"/>
<xsl:apply-templates select="div|section"/>
</xsl:element>
</xsl:template>
<!-- Identity transformation -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<!-- Namespace substitution for hdoc elements -->
<xsl:template match="*" priority="1">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dc="http://www.idpf.org/2007/opf"
xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
exclude-result-prefixes="xs"
version="2.0">
<xsl:import href="content/metadata.xsl"/>
<xsl:import href="content/manifest.xsl"/>
<xsl:import href="content/spine.xsl"/>
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="html">
<package unique-identifier="BookID" version="3.0">
<xsl:call-template name="metadata"/>
<xsl:call-template name="manifest"/>
<xsl:call-template name="spine"/>
</package>
</xsl:template>
<xsl:template match="text()"/>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dc="http://www.idpf.org/2007/opf"
xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template name="manifest">
<manifest>
<item id="tDMncx" href="tableDesMatieres.ncx" media-type="application/x-dtbncx+xml" />
<xsl:for-each select="body/section">
<item>
<xsl:attribute name="href">chapitres/chapitre<xsl:number level="multiple" count="section" format="1"/>.xhtml</xsl:attribute>
<xsl:attribute name="id">ch<xsl:number level="multiple" count="section" format="1"/></xsl:attribute>
<xsl:attribute name="media-type">application/xhtml+xml</xsl:attribute>
</item>
</xsl:for-each>
</manifest>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dc="http://www.idpf.org/2007/opf"
xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template name="metadata">
<metadata>
<dc:title><xsl:value-of select="head/title"/></dc:title>
<dc:creator><xsl:value-of select="head/meta[@name='author']/@content"/></dc:creator>
<dc:language>fr</dc:language>
</metadata>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dc="http://www.idpf.org/2007/opf"
xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template name="spine">
<spine toc="tDMncx">
<xsl:for-each select="body/section">
<itemref>
<xsl:attribute name="idref">ch<xsl:number level="multiple" count="section" format="1"/></xsl:attribute>
</itemref>
</xsl:for-each>
</spine>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
xmlns="http://www.daisy.org/z3986/2005/ncx/"
version="2.0">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="html">
<ncx version="2005-1" xml:lang="en-US">
<head>
<meta content="org-example-5059463624137734586" name="dtb:uid"/>
</head>
<navMap>
<xsl:apply-templates/>
</navMap>
</ncx>
</xsl:template>
<xsl:template match="//section">
<navPoint>
<xsl:attribute name="class">h<xsl:value-of select="count(ancestor::section)+1"/></xsl:attribute>
<xsl:attribute name="id">ch_<xsl:number level="multiple" count="section" format="1_1"/></xsl:attribute>
<navLabel>
<text>
<xsl:value-of select="header/h1"/>
</text>
</navLabel>
<content>
<xsl:attribute name="src">content.html#ch_<xsl:number level="multiple" count="section" format="1_1"/></xsl:attribute>
</content>
<xsl:apply-templates/>
</navPoint>
</xsl:template>
<xsl:template match="text()"/>
</xsl:stylesheet>
\ No newline at end of file
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<xsl:import href="subroutines/author.xsl"/> <xsl:import href="subroutines/author.xsl"/>
<xsl:import href="subroutines/keyword.xsl"/> <xsl:import href="subroutines/keyword.xsl"/>
<xsl:import href="subroutines/right.xsl"/> <xsl:import href="subroutines/right.xsl"/>
<xsl:import href="subroutines/introduction.xsl"/>
<xsl:output method="text" encoding="UTF-8" omit-xml-declaration="yes"/> <xsl:output method="text" encoding="UTF-8" omit-xml-declaration="yes"/>
...@@ -16,7 +17,8 @@ ...@@ -16,7 +17,8 @@
"title" : <xsl:call-template name="title-main"/>, "title" : <xsl:call-template name="title-main"/>,
"authors" : <xsl:call-template name="author-main"/>, "authors" : <xsl:call-template name="author-main"/>,
"keywords" : <xsl:call-template name="keyword-main"/>, "keywords" : <xsl:call-template name="keyword-main"/>,
"rights" : <xsl:call-template name="right-main"/> "rights" : <xsl:call-template name="right-main"/>,
"introduction" : <xsl:call-template name="introduction-main"/>
} }
</xsl:template> </xsl:template>
......
<?xml version="1.0" encoding="UTF-8"?>
<?target hdoc/content.xml ?>
<xsl:stylesheet version="2.0" xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:h2m="http://www.utc.fr/hdoc/hdoc_to_mongo">
<xsl:import href="../xsl-import/string.xsl"/>
<xsl:template name="introduction-main">
<xsl:value-of select="h2m:escape-string(string-join(/html/body/section[@data-hdoc-type='introduction']/div/descendant::*/text(), ' '))"/>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
...@@ -195,6 +195,11 @@ ...@@ -195,6 +195,11 @@
<text/> <text/>
</element> </element>
</optional> </optional>
<optional>
<element name="div">
<ref name="DivType"/>
</element>
</optional>
<ref name="Flow"/> <ref name="Flow"/>
</element> </element>
</oneOrMore> </oneOrMore>
......
...@@ -45,6 +45,8 @@ ...@@ -45,6 +45,8 @@
<value>choice-correct</value> <value>choice-correct</value>
<value>choice-incorrect</value> <value>choice-incorrect</value>
<value>explanation</value> <value>explanation</value>
<value>explanation-choice-correct</value>
<value>explanation-choice-incorrect</value>
</choice> </choice>
</attribute> </attribute>
</optional> </optional>
......
...@@ -62,6 +62,10 @@ You can use special rules in Freemind to personnalize your Scenari Module : ...@@ -62,6 +62,10 @@ You can use special rules in Freemind to personnalize your Scenari Module :
* **#wrng** : a warning * **#wrng** : a warning
* **#ex** : an example * **#ex** : an example
* **#def** : a definition * **#def** : a definition
* **#question** : a MCQ
* **#choice-correct** : a correct answer within a MCQ
* **#choice-incorrect** : an incorrect answer within a MCQ
* **#explanation** : an explanation of the answers within a MCQ
* *Then you can add some **#p** inside these node to create the content* * *Then you can add some **#p** inside these node to create the content*
- You can arrange the order of the node usine the hashtag **#1, #2, #3** etc. - You can arrange the order of the node usine the hashtag **#1, #2, #3** etc.
......
...@@ -309,10 +309,10 @@ ...@@ -309,10 +309,10 @@
</xsl:if> </xsl:if>
</xsl:if> </xsl:if>
</xsl:template> </xsl:template>
<!-- Simple Tables --> <!-- Simple Tables -->
<xsl:template match="table" mode="textOnly"> <xsl:template match="table" mode="#all">
<xsl:choose> <xsl:choose>
<!-- Tables that doesn't contain colspan, rowspan or included tables --> <!-- Tables that doesn't contain colspan, rowspan or included tables -->
<xsl:when test="not(descendant::td/@colspan | descendant::td/@rowspan | descendant::table)"> <xsl:when test="not(descendant::td/@colspan | descendant::td/@rowspan | descendant::table)">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment