Commit ba84cdd2 authored by Neveux Anais's avatar Neveux Anais
Browse files

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

parents a5204d15 31ec411a
......@@ -53,7 +53,6 @@
<target name="insertion" if="wantToInsert">
<antcall target="installModules"/>
<exec executable="node" dir="./node">
<arg line="insert.js"/>
</exec>
......@@ -65,19 +64,4 @@
</condition>
</target>
<target name="checkModules">
<condition property="modNotInstalled">
<not>
<available file="node_modules" type="dir"/>
</not>
</condition>
</target>
<target name="installModules" depends="checkModules" if="modNotInstalled">
<echo>"modules non installés"</echo>
<exec executable="npm" dir=".">
<arg line="install"/>
</exec>
</target>
</project>
\ No newline at end of file
......@@ -2,7 +2,7 @@
set ant=hdoc_to_neo4j.ant
set antparam=-Dnode true;
IF NOT EXIST ./node_modules call npm install
ant -buildfile %ant% %antparam%
pause
......
......@@ -31,5 +31,9 @@ fi
#Lancer la commande
scJarList="$lib/*"
#test si les packages ont été installés
if [ ! -d "$node_modules" ]; then
npm install
fi
$vJavaCmd -classpath "$scJarList:" -Xmx150m org.apache.tools.ant.Main -buildfile $ant $antparam
!tmp/.gitkeep
!output/.gitkeep
Converter hdoc_to_pdf
-----------------------
The purpose of this converter is to obtain a PDF file from a hdoc document.
The purpose of this converter is to obtain a PDF file from a hdoc document.
License GPL3.0
......@@ -28,7 +28,36 @@ This project can be used alone if you only want to convert a hdoc file into a PD
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).
#### Running the script run.bat/run.sh:
Use this method if you do not want to use a terminal.
1. Download hdoc_converter.zip and unzip it.
2. Add your source file into the input folder. It must be a .hdoc 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.
#### Terminal:
By using the terminal you can specify some parameters to the conversion at the moment: the source file.
1. Download hdoc_converter.zip and unzip it.
2. Open your terminal and go into the folder hdoc_to_pdf.
3. Run the following command:
"ant -buildfile hdoc_to_pdf.ant"
You can specify the source file by adding parameters.
Use -DInputFile to specify the source file.
Exemple:
"ant -buildfile hdoc_to_optim.ant -DInputFile=sample.hdoc"
This parameter is optional. Your file has been converted, the result is in the output folder.
Known bugs
......@@ -51,6 +80,7 @@ Generic Todo
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.
User Story
----------
......@@ -64,5 +94,3 @@ User Story
Capitalisation
--------------
......@@ -37,9 +37,32 @@
@page {
size: A4 portrait;
margin: 2cm;
margin-left: 44mm;
margin-right: 44mm;
margin-top: 20mm;
margin-bottom: 40mm;
@bottom-center { content: counter(page) }
}
* {
font-family: "CMU Serif";
}
p {
text-align: justify;
text-indent: 2em;
hyphens: auto;
}
body {counter-reset: h2}
h2 {counter-reset: h3}
h3 {counter-reset: h4}
h4 {counter-reset: h5}
h5 {counter-reset: h6}
h2:before {counter-increment: h2; content: counter(h2) ".\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"}
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"}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project name="hdoc_to_pdf" basedir="." default="main">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="lib/ant-contrib.jar"/>
</classpath>
</taskdef>
<!-- Arguments properties -->
<property name="InputPath" location="input"/>
<property name="OutputPath" location="output"/>
<property name="tmp" location="${basedir}/tmp"/>
<property name="tmpdir" location="${basedir}/tmp"/>
<property name="OutputFileName" location="${OutputPath}/result.pdf"/>
<target name="main" depends="hdocPreparation">
......@@ -16,51 +22,57 @@
<arg value="${OutputFileName}"/>
</exec>
<!-- Temporary files and folders are deleted -->
<!--
<delete dir="${tmp}"/>
<delete file="prepare_hdoc.ant"/>
<delete file="my.properties"/>
-->
</target>
<target name="hdocPreparation">
<echo message="The value of property of InputPath is ${InputPath}"/>
<echo message="The value of property of OutputPath is ${OutputPath}"/>
<echo message="The value of property of tmp is ${tmp}"/>
<!-- Creation of temp dir -->
<delete dir="${tmp}" failonerror="false"/>
<sleep seconds="1"/>
<mkdir dir="${tmp}"/>
<!-- Clean the folders before proceeding -->
<delete>
<fileset dir="${OutputPath}" excludes=".gitkeep"/>
<fileset dir="${tmpdir}" excludes=".gitkeep"/>
</delete>
<echo message="Getting input hdoc file..."/>
<condition property="InputFile.set" else="false">
<isset property="InputFile"/>
</condition>
<if>
<equals arg1="${InputFile.set}" arg2="false" />
<then>
<!-- There is no input, check the input folder -->
<echo message="Checking the input folder..."/>
<!-- Get input hdoc file path -->
<fileset id="fileset_hdoc" dir="${InputPath}" casesensitive="yes">
<include name="*.hdoc"/>
</fileset>
<pathconvert property="HdocFile" pathsep="" refid="fileset_hdoc"/>
<!-- Get input hdoc file path -->
<fileset id="fileset_hdoc" dir="${InputPath}" casesensitive="yes">
<include name="*.hdoc"/>
</fileset>
<pathconvert property="InputFile" pathsep="" refid="fileset_hdoc"/>
</then>
</if>
<echo message="Executing conversion..."/>
<!-- Unzips the hdoc to be converted-->
<unzip dest="${tmp}" src="${HdocFile}"/>
<unzip dest="${tmpdir}" src="${InputFile}"/>
<!-- Gives all rights to avoid bugs-->
<chmod dir="${tmp}" perm="777"/>
<chmod dir="${tmpdir}" perm="777"/>
<!-- Launches the XSLT find_content to retrieve the content path -->
<xslt in="${tmp}/META-INF/container.xml" out="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">
<param name="BaseDirectory" expression="${basedir}"/>
<param name="TempDirectory" expression="${tmp}"/>
<param name="TempDirectory" expression="${tmpdir}"/>
</xslt>
<chmod file="prepare_hdoc.ant" perm="777"/>
<chmod file="${tmpdir}/prepare_hdoc.ant" perm="777"/>
<!-- Launches the ANT prepare_hdoc.ant resulting from the previous XSLT in order to get a clean xhtml ready for the pdf conversion -->
<ant antfile="prepare_hdoc.ant"/>
<ant antfile="${tmpdir}/prepare_hdoc.ant"/>
<!-- Recover of the dirpath property extracted through find_content.xsl execution -->
<property file="${basedir}/my.properties"/>
<property file="${tmpdir}/my.properties"/>
</target>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!--find_content.xsl creates a ANT file prepare_hdoc.ant-->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
......@@ -51,7 +51,7 @@
<xslt in="{$dirpath}/hdoc_nsless.xhtml" out="{$dirpath}/flat_hdoc.xhtml" style="xsl/hdoc_flattenizer.xsl" classpath="./lib/saxon9he.jar"/>
<xslt in="{$dirpath}/flat_hdoc.xhtml" out="{$dirpath}/final.xhtml" style="xsl/last_transformer.xsl" classpath="./lib/saxon9he.jar"/>
<propertyfile file="{$BaseDirectory}/my.properties">
<propertyfile file="{$TempDirectory}/my.properties">
<entry key="dirpath" value="{$dirpath}"/>
</propertyfile>
......
......@@ -17,7 +17,7 @@
</xsl:template>
<xsl:template match="html">
<html>
<html lang="fr">
<xsl:apply-templates/>
</html>
</xsl:template>
......@@ -35,7 +35,7 @@
</xsl:template>
<xsl:template match="section">
<xsl:variable name="level" select="count(ancestor::section) + 1"/>
<xsl:variable name="level" select="count(ancestor::section) + 2"/>
<div>
<xsl:element name="h{$level}">
<xsl:value-of select="header/h1"/>
......@@ -48,7 +48,7 @@
</xsl:template>
<xsl:template match="h6">
<xsl:variable name="level" select="count(ancestor::section) + 1"/>
<xsl:variable name="level" select="count(ancestor::section) + 2"/>
<xsl:element name="h{$level}">
<xsl:value-of select="."/>
</xsl:element>
......
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