Commit a940c82b authored by Bastien Bascou's avatar Bastien Bascou
Browse files

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

parents 44758d11 d092646c
...@@ -25,6 +25,7 @@ Un utilisateur a cr ...@@ -25,6 +25,7 @@ Un utilisateur a cr
- Method and Remind fully functional. - Method and Remind fully functional.
- Add QCU and QCM. Transclusion of them available too. Need to fix a schema validation error when putting a title to a question, without filling the question content. - Add QCU and QCM. Transclusion of them available too. Need to fix a schema validation error when putting a title to a question, without filling the question content.
- Add "Exercice redactionnel" and transclusion. - Add "Exercice redactionnel" and transclusion.
- Fill-in-the blank (and transclusion)
## Known bugs ## Known bugs
- You can have an exercice with no question but a solution. We should add a if statement to handle this. - You can have an exercice with no question but a solution. We should add a if statement to handle this.
...@@ -35,4 +36,5 @@ Un utilisateur a cr ...@@ -35,4 +36,5 @@ Un utilisateur a cr
- Handle multiple files conversion - Handle multiple files conversion
- Add all other type of exercices - Add all other type of exercices
- Handle other kind of paragraph - Handle other kind of paragraph
- Handle resources (images for example) - Handle resources (images for example)
\ No newline at end of file - Handle sub-level transclusion
\ No newline at end of file
...@@ -160,6 +160,13 @@ ...@@ -160,6 +160,13 @@
<xsl:value-of select="." /> <xsl:value-of select="." />
</span> </span>
</xsl:template> </xsl:template>
<xsl:template match="sc:para/sc:textLeaf[@role='gap']" priority = "2">
<span data-hdoc-type="blank">
<xsl:value-of select="."/>
</span>
</xsl:template>
<!-- default behaviour for other balises --> <!-- default behaviour for other balises -->
<xsl:template match="sc:para/sc:inlineStyle|sc:para/sc:textLeaf" priority="1"> <xsl:template match="sc:para/sc:inlineStyle|sc:para/sc:textLeaf" priority="1">
<xsl:value-of select="." /> <xsl:value-of select="." />
...@@ -332,7 +339,48 @@ ...@@ -332,7 +339,48 @@
<!-- ******** FIN ACTIVITE TETM ********** --> <!-- ******** FIN ACTIVITE TETM ********** -->
<!-- ******** EXERCICE AVEC CORRIGE ******** --> <!-- ******** EXERCICE AVEC ET SANS CORRIGE ******** -->
<!-- Texte à trou -->
<xsl:template match="sp:question/cp:cloze | sp:exercice/cp:cloze">
<section data-hdoc-type='fill-in-the-blank'>
<header>
<h1><xsl:value-of select="cp:questionM/sp:title"/></h1>
</header>
<div data-hdoc-type='question'>
<xsl:apply-templates select="sc:question/cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
</div>
<div data-hdoc-type='gapText'>
<xsl:apply-templates select="sc:gapText/cp:txtCloze/sc:para"/>
</div>
<xsl:if test="../name() = 'sp:question'">
<div data-hdoc-type='explanation'>
<xsl:apply-templates select="sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
</div>
</xsl:if>
</section>
</xsl:template>
<xsl:template match="sc:item/cp:cloze">
<xsl:param name="withoutExplanation"/>
<section data-hdoc-type='fill-in-the-blank'>
<header>
<h1><xsl:value-of select="cp:questionM/sp:title"/></h1>
</header>
<div data-hdoc-type='question'>
<xsl:apply-templates select="sc:question/cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
</div>
<div data-hdoc-type='gapText'>
<xsl:apply-templates select="sc:gapText/cp:txtCloze/sc:para"/>
</div>
<xsl:if test="$withoutExplanation = 'sp:question'">
<div data-hdoc-type='explanation'>
<xsl:apply-templates select="sc:globalExplanation/cp:block/sp:body/cp:flow/sp:txt/cp:txt//sc:para"/>
</div>
</xsl:if>
</section>
</xsl:template>
<!-- Questionnement --> <!-- Questionnement -->
......
...@@ -27,6 +27,7 @@ A .scar example is already in the input folder. ...@@ -27,6 +27,7 @@ A .scar example is already in the input folder.
- Method and Remind fully functional - Method and Remind fully functional
- QCM and QCU working, even with transclusion. - QCM and QCU working, even with transclusion.
- Add "Exercice redactionnel" and transclusion. - Add "Exercice redactionnel" and transclusion.
- Fill-in-the-blank with transclusion.
## Known bugs ## Known bugs
- You can have an exercice with no question but a solution. We should add a if statement to handle this. - You can have an exercice with no question but a solution. We should add a if statement to handle this.
......
...@@ -445,7 +445,7 @@ ...@@ -445,7 +445,7 @@
<xsl:choose> <xsl:choose>
<!-- If it is directly included in a div, we have to add Opale's text markups --> <!-- If it is directly included in a div, we have to add Opale's text markups -->
<xsl:when test="parent::*[name() = 'div']"> <xsl:when test="parent::*[name() = 'div'] and not(parent::*[@data-hdoc-type = 'gapText'])">
<sp:txt> <sp:txt>
<op:txt> <op:txt>
<xsl:call-template name="blockloop"/> <xsl:call-template name="blockloop"/>
...@@ -630,6 +630,39 @@ ...@@ -630,6 +630,39 @@
</sp:listing> </sp:listing>
</xsl:template> </xsl:template>
<!-- Fill-in-the-blank -->
<xsl:template match="h:section[@data-hdoc-type = 'fill-in-the-blank']" priority="2">
<sp:trainUcCloze>
<op:cloze>
<op:exeM>
<sp:title><xsl:value-of select="h:header/h:h1"/></sp:title>
</op:exeM>
<xsl:apply-templates select="h:div[@data-hdoc-type = 'question']"/>
<xsl:apply-templates select="h:div[@data-hdoc-type = 'gapText']"/>
<sc:globalExplanation>
<op:res>
<xsl:apply-templates select="./h:div[@data-hdoc-type = 'explanation']/h:p"/>
</op:res>
</sc:globalExplanation>
</op:cloze>
</sp:trainUcCloze>
</xsl:template>
<xsl:template match="h:div[@data-hdoc-type = 'gapText']">
<sc:gapText>
<op:clozeTxt>
<xsl:apply-templates select="./*"/>
</op:clozeTxt>
</sc:gapText>
</xsl:template>
<xsl:template match="h:span[@data-hdoc-type = 'blank']">
<sc:textLeaf role="gap">
<xsl:apply-templates select="./* | ./text()"/>
</sc:textLeaf>
</xsl:template>
<!-- Open Question --> <!-- Open Question -->
<xsl:template match="h:section[@data-hdoc-type = 'exercise']"> <xsl:template match="h:section[@data-hdoc-type = 'exercise']">
<sp:practUc> <sp:practUc>
......
...@@ -29,6 +29,7 @@ User documentation ...@@ -29,6 +29,7 @@ User documentation
------------------ ------------------
There are two different ways to use the converter hdoc_to_pdf: by running a script run.bat/run.sh or by command line using a terminal (allows the user to specify some parameters). There are two different ways to use the converter hdoc_to_pdf: by running a script run.bat/run.sh or by command line using a terminal (allows the user to specify some parameters).
The folder samples contains a hdoc file which may be used for some tests.
#### Running the script run.bat/run.sh: #### Running the script run.bat/run.sh:
...@@ -65,8 +66,9 @@ Known bugs ...@@ -65,8 +66,9 @@ Known bugs
* Nested ul in ol are sometimes converted to ol. * Nested ul in ol are sometimes converted to ol.
* It seems that FS doesn't support the max-width for img tags, which makes proper scaling harder. * It seems that FS doesn't support the max-width for img tags, which makes proper scaling harder.
* ToC lines rendering is sometimes ugly if the title label is too long. * ToC lines rendering is sometimes ugly if the title label is too long: dotted leader or even page number may appear on the following line, sometimes colliding between themselves.
* Inline elements like em cause bad paragraphs justification. * Inline elements like em cause bad paragraphs justification.
* Sometimes, they are unwanted page breaks after a heading.
Generic Todo Generic Todo
------------ ------------
...@@ -77,22 +79,44 @@ Generic Todo ...@@ -77,22 +79,44 @@ Generic Todo
* Generate the ToC according to the converted (by XSL) headings of the hdoc * Generate the ToC according to the converted (by XSL) headings of the hdoc
* Handle as fully as possible of widows and girl orphans; trying to match Prince's layout and implementing the suitable CSS rules (which shall not be interpreted by FS) * Handle as fully as possible of widows and girl orphans; trying to match Prince's layout and implementing the suitable CSS rules (which shall not be interpreted by FS)
* Allow the user to override some specific CSS rules, according to the main layout logical rules * Allow the user to override some specific CSS rules, according to the main layout logical rules
* Manage container.xml and content.xml validations using jing as jing task can't be handled with opale_to_pdf.ant call.
* Bonus: find out a HTML editor to manually add line breaks to a hdoc file in order to resolve widows and girl orphans problems after the PDF file's generation * Bonus: find out a HTML editor to manually add line breaks to a hdoc file in order to resolve widows and girl orphans problems after the PDF file's generation
Specific Todo list
------------------
* Gestion du bug d'espace qui apparaît après un lien.
* Ajouter le paramètre de reliure ("bound") au script ant
* Intégrer les styles CSS selon le paramètre "bound" dans un xsl
* Ajouter le paramètre de recto-verso au script ant
* Intégrer les styles CSS selon le paramètre recto-verso dans un xsl
* Ajout le support des marges pour documents oneside reliés
* Ajout le support des marges pour documents twoside reliés
* Identifier les règles CSS principales de traitement des tableaux
* Gérer les espacements veuves/o. pour les paragraphes
* Gérer les espacements veuves/o. pour les listes
* Gérer les espacements veuves/o. pour les tableaux
* Gérer les espacements veuves/o. pour les images
* Support des objets : ajouter une consigne dans le README de convertir tout objet graphique (odg, etc.) en image avant l'exécution
* Support des objets : ajouter des règles xsl de transformation des <object> en <img>
* Permettre à l'utilisateur de surcharger les règles CSS selon les règles logiques de la mise en page par défaut
Technical notes Technical notes
--------------- ---------------
* This converter works with _only one_ hdoc file in the input folder, please ensure to clean the folder before proceeding with the hdoc you want to convert to PDF. * This converter works with _only one_ hdoc file in the input folder at the moment, please ensure to clean the folder before proceeding with the hdoc you want to convert to PDF. When the multifiles ability is set within the hdoc_to_pdf converter, the opale_to_pdf one shall naturally work because it already implements the opale_to_hdoc multifiles handling (the copy of all the hdoc results into the input directory of the hdoc_to_pdf converter).
User Story User Story
---------- ----------
* L'utilisateur dispose d'un fichier hdoc en entrée, il veut obtenir un fichier pdf paginé en sortie. * Cas d'un fichier hdoc à convertir :
* Il accède au convertisseur (dossier dédié) hdoc_to_pdf. * L'utilisateur dispose d'un fichier hdoc en entrée, il veut obtenir un fichier pdf paginé en sortie.
* Il place le fichier hdoc dans le dossier input. * Il accède au convertisseur (dossier dédié) hdoc_to_pdf.
* Il lance le script run.bat/run.sh ou exécute directement le script ant hdoc_to_pdf.ant. * Il place le fichier hdoc dans le dossier input.
* Il récupère le fichier pdf dans le dossier output. * Il lance le script run.bat/run.sh ou exécute directement le script ant hdoc_to_pdf.ant.
* Il récupère le fichier pdf dans le dossier output.
Capitalisation Capitalisation
......
...@@ -45,14 +45,21 @@ ...@@ -45,14 +45,21 @@
@bottom-center { content: counter(page) } @bottom-center { content: counter(page) }
} }
body { html, body {
padding: 0;
margin: 0; margin: 0;
height: auto;
} }
* { * {
font-family: "CMU Serif"; font-family: "CMU Serif";
} }
a {
text-decoration: none;
color: black;
}
p { p {
text-align: justify; text-align: justify;
text-indent: 2em; text-indent: 2em;
...@@ -62,6 +69,8 @@ p { ...@@ -62,6 +69,8 @@ p {
word-break: normal; word-break: normal;
} }
span[data-hdoc-type="syntax"] {font-family: "CMU Typewriter Text"}
h1 {font-size: 2em} h1 {font-size: 2em}
h2 {font-size: 1.6em} h2 {font-size: 1.6em}
h3 {font-size: 1.4em} h3 {font-size: 1.4em}
...@@ -77,26 +86,11 @@ h6 {font-style: italic} ...@@ -77,26 +86,11 @@ h6 {font-style: italic}
body {counter-reset: h2} body {counter-reset: h2}
h2 {counter-reset: h3} h2 {counter-reset: h3}
h3 {counter-reset: h4} h3 {counter-reset: h4}
/*
h4 {counter-reset: h5}
h5 {counter-reset: h6}
*/
h2::before {counter-increment: h2; content: counter(h2) ".\0000a0\0000a0"} h2::before {counter-increment: h2; content: counter(h2) ".\0000a0\0000a0"}
h3::before {counter-increment: h3; content: counter(h2) "." counter(h3) ".\0000a0\0000a0"} h3::before {counter-increment: h3; content: counter(h2) "." counter(h3) ".\0000a0\0000a0"}
h4::before {counter-increment: h4; content: counter(h2) "." counter(h3) "." counter(h4) ".\0000a0\0000a0"} h4::before {counter-increment: h4; content: counter(h2) "." counter(h3) "." counter(h4) ".\0000a0\0000a0"}
/*
h5::before {counter-increment: h5; content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) ".\0000a0\0000a0"}
h6::before {counter-increment: h6; content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6) ".\0000a0\0000a0"}
*/
/*
h2.nocount:before,
h3.nocount:before,
h4.nocount:before,
h5.nocount:before,
h6.nocount:before { content: ""; counter-increment: none }
*/
h2.nocount:before, h2.nocount:before,
h3.nocount:before, h3.nocount:before,
h4.nocount:before { content: ""; counter-increment: none } h4.nocount:before { content: ""; counter-increment: none }
...@@ -146,27 +140,31 @@ ul.toc > li { ...@@ -146,27 +140,31 @@ ul.toc > li {
ul.toc > li::before { ul.toc > li::before {
left: 0; left: 0;
position: absolute; position: absolute;
content: counters(toc, ".") ". "; content: counters(toc, ".") "\A0";
counter-increment: toc; counter-increment: toc;
} }
ul.toc.level2 > li {padding-left: 8mm;} ul.toc.level2 > li {
ul.toc.level3 > li {padding-left: 11mm;} padding-left: 8mm;
ul.toc.level4 > li {padding-left: 13mm;} font-family: "CMU Serif Extra";
ul.toc.level5 > li {padding-left: 15mm;} }
ul.toc.level6 > li {padding-left: 17mm;}
ul.toc > li > a::after { ul.toc.level2 > li > a {
content: leader(dotted); font-family: "CMU Serif Extra";
text-decoration: none;
color: black;
} }
ul.toc.level3 > li {padding-left: 11mm}
ul.toc.level4 > li {padding-left: 13mm}
ul.toc.level3 > li > a::after, ul.toc.level4 > li > a::after {content: leader(dotted)}
ul.toc > li > span { ul.toc > li > span {
position: absolute; position: absolute;
right: -10mm; right: -10mm;
} }
ul.toc.level2 > li > span {font-family: "CMU Serif Extra"}
ul.toc > li > span::after { ul.toc > li > span::after {
content: target-counter(attr(href), page); content: target-counter(attr(href), page);
} }
......
...@@ -6,7 +6,11 @@ ...@@ -6,7 +6,11 @@
<pathelement location="lib/ant-contrib.jar"/> <pathelement location="lib/ant-contrib.jar"/>
</classpath> </classpath>
</taskdef> </taskdef>
<taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask"/> <!--<taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask">
<classpath>
<pathelement location="lib/jing.jar"/>
</classpath>
</taskdef>-->
<!-- Arguments properties --> <!-- Arguments properties -->
<property name="InputPath" location="input"/> <property name="InputPath" location="input"/>
...@@ -66,14 +70,14 @@ ...@@ -66,14 +70,14 @@
<chmod dir="${tmpdir}" perm="777"/> <chmod dir="${tmpdir}" perm="777"/>
<!-- Validating the XML container file --> <!-- Validating the XML container file -->
<trycatch property="foo" reference="bar"> <!--<trycatch property="foo" reference="bar">
<try> <try>
<jing file="${tmpdir}/META-INF/container.xml" rngfile="${Schema}/container/hdoc1-container.rng"></jing> <jing file="${tmpdir}/META-INF/container.xml" rngfile="${Schema}/container/hdoc1-container.rng"></jing>
</try> </try>
<catch> <catch>
<echo>Validation failed</echo> <echo>Validation failed</echo>
</catch> </catch>
</trycatch> </trycatch>-->
<!-- Launches the XSLT find_content to retrieve the content path --> <!-- Launches the XSLT find_content to retrieve the content path -->
<xslt in="${tmpdir}/META-INF/container.xml" out="${tmpdir}/prepare_hdoc.ant" classpath="./lib/saxon9he.jar" style="xsl/find_content.xsl"> <xslt in="${tmpdir}/META-INF/container.xml" out="${tmpdir}/prepare_hdoc.ant" classpath="./lib/saxon9he.jar" style="xsl/find_content.xsl">
......
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
<project name="hdoc_to_pdf" basedir=".." default="main"> <project name="hdoc_to_pdf" basedir=".." default="main">
<property name="lib" location="lib"/> <property name="lib" location="lib"/>
<property name="Schema" location="schemas"/> <property name="Schema" location="schemas"/>
<taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask"> <!--<taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask">
<classpath> <classpath>
<pathelement location="${lib}/jing.jar"/> <pathelement location="${lib}/jing.jar"/>
</classpath> </classpath>
</taskdef> </taskdef>-->
<target name="main"> <target name="main">
<xsl:apply-templates/> <xsl:apply-templates/>
</target> </target>
...@@ -48,14 +48,14 @@ ...@@ -48,14 +48,14 @@
<echo message="Filename : {$filename}"/> <echo message="Filename : {$filename}"/>
<echo message="Dirpath : {$dirpath}"/> <echo message="Dirpath : {$dirpath}"/>
<trycatch property="foo" reference="bar"> <!--<trycatch property="foo" reference="bar">
<try> <try>
<jing file="{$TempDirectory}/{$path}" rngfile="${{Schema}}/xhtml/hdoc1-xhtml.rng"></jing> <jing file="{$TempDirectory}/{$path}" rngfile="${{Schema}}/xhtml/hdoc1-xhtml.rng"></jing>
</try> </try>
<catch> <catch>
<echo>Validation failed</echo> <echo>Validation failed</echo>
</catch> </catch>
</trycatch> </trycatch>-->
<copy file="{$BaseDirectory}/css/main.css" tofile="{$dirpath}/main.css"/> <copy file="{$BaseDirectory}/css/main.css" tofile="{$dirpath}/main.css"/>
<copy file="{$BaseDirectory}/font/cmunrm.ttf" tofile="{$dirpath}/cmunrm.ttf"/> <copy file="{$BaseDirectory}/font/cmunrm.ttf" tofile="{$dirpath}/cmunrm.ttf"/>
......
...@@ -47,10 +47,10 @@ ...@@ -47,10 +47,10 @@
</xsl:if> </xsl:if>
</xsl:template> </xsl:template>
<!-- Cleaning des footers vides --> <!-- Cleaning des footers vides -->
<xsl:template match="footer[not(node())]"/> <xsl:template match="footer[not(node())]"/>
<xsl:template match="div[@data-hdoc-type='tags']"/>
<!-- Gestion de la table des matières --> <!-- Gestion de la table des matières -->
......
...@@ -20,8 +20,9 @@ Credits ...@@ -20,8 +20,9 @@ Credits
* Thibault DRAIN * Thibault DRAIN
* Christophe VIROT * Christophe VIROT
* Pierre Lemaire * Pierre Lemaire
* Baptiste PERRAUD * 2016 :
* Raphaël DEBRAY * Baptiste PERRAUD
* Raphaël DEBRAY
Dependance Dependance
...@@ -35,36 +36,45 @@ This converter is based on two converters : ...@@ -35,36 +36,45 @@ This converter is based on two converters :
User documentation User documentation
------------------ ------------------
The folder samples contains a scar file which may be used for some tests.
Follow the steps above to get a pdf file from a scar one:
1. Download hdoc_converter.zip and unzip it.
2. Add your source file into the input folder. It must be a .scar file.
3. Place _only one file_ in that folder.
4. On Linux or Mac, run the script run.sh. On Windows, run the script run.bat.
5. Your file has been converted, the result is in the output folder.
Unsupported Unsupported
----------- -----------
Refer to the unsupported elements in Opale to Hdoc and in Hdoc to Pdf. Refer to the unsupported elements in Opale to Hdoc and in Hdoc to Pdf.
Known bugs Known bugs
---------- ----------
Refer to the known bugs in Opale to Hdoc and in Hdoc to Pdf. Refer to the known bugs in Opale to Hdoc and in Hdoc to Pdf.
Todo Todo
---- ----
Technical notes Technical notes
--------------- ---------------
* This converter works with _only one_ hdoc file in the input folder at the moment, please ensure to clean the folder before proceeding with the hdoc you want to convert to PDF. When the multifiles ability is set within the hdoc_to_pdf converter, the opale_to_pdf one shall naturally work because it already implements the opale_to_hdoc multifiles handling (the copy of all the hdoc results into the input directory of the hdoc_to_pdf converter).
The converter contains 1 file: The converter contains 1 file:
* opale_to_pdf.ant * opale_to_pdf.ant
It checks wether or not the user specified the parameters and performs the following : It checks whether the user specified or not the parameters and performs the following :
* Copy the input file in the opale_to_hdoc directory. * Copy the input files in the opale_to_hdoc directory.
* Perform the opale_to_hdoc transformation. * Perform the opale_to_hdoc transformation.
* Copy the result in the hdoc_to_pdf directory. * Copy the results in the hdoc_to_pdf directory.
* Perform the hdoc_to_pdf transformation. * Perform the hdoc_to_pdf transformation.
* Copy the result in the opale_to_pdf directory. * Copy the results in the opale_to_pdf directory.
Capitalisation Capitalisation
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<pathelement location="lib/ant-contrib.jar" /> <pathelement location="lib/ant-contrib.jar" />
</classpath> </classpath>
</taskdef> </taskdef>
<!-- Arguments properties --> <!-- Arguments properties -->
<property name="DocType" value="paper" /> <property name="DocType" value="paper" />
<property name="Source" value="none" /> <property name="Source" value="none" />
...@@ -13,19 +13,19 @@ ...@@ -13,19 +13,19 @@
<!-- Beginning --> <!-- Beginning -->
<target name="convert"> <target name="convert">
<antcall target="clean_everything" /> <antcall target="clean_everything" />
<antcall t