Jrst-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
May 2012
- 2 participants
- 40 discussions
r672 - branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst
by jpages@users.nuiton.org 24 May '12
by jpages@users.nuiton.org 24 May '12
24 May '12
Author: jpages
Date: 2012-05-24 14:52:39 +0200 (Thu, 24 May 2012)
New Revision: 672
Url: http://nuiton.org/repositories/revision/jrst/672
Log:
Correction du probl?\195?\168me qui emp?\195?\170chait la g?\195?\169n?\195?\169ration d'un pdf avec des images sous windows.
Modified:
branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java
branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTUserAgent.java
Modified: branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java 2012-05-24 08:44:53 UTC (rev 671)
+++ branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java 2012-05-24 12:52:39 UTC (rev 672)
@@ -296,7 +296,7 @@
ITextRenderer renderer = new ITextRenderer();
// Settings to resolve paths with the JRST User Agent
- String absolutePath = fileIn.getParentFile().getAbsolutePath() + "/";
+ String absolutePath = fileIn.getParentFile().getAbsolutePath();
JRSTUserAgent jrstUserAgent = new JRSTUserAgent(absolutePath);
jrstUserAgent.setBaseURL(absolutePath);
renderer.getSharedContext().setUserAgentCallback(jrstUserAgent);
Modified: branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTUserAgent.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTUserAgent.java 2012-05-24 08:44:53 UTC (rev 671)
+++ branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTUserAgent.java 2012-05-24 12:52:39 UTC (rev 672)
@@ -26,10 +26,6 @@
*/
public class JRSTUserAgent implements UserAgentCallback {
- public static final String THIS_DIRECTORY = "./";
-
- public static final String PREVIOUS_DIRECTORY = "../";
-
/** to use log facility, just put in your code: log.info("..."); */
protected static Log log = LogFactory.getLog(JRSTUserAgent.class);
@@ -124,13 +120,13 @@
} catch (MalformedURLException e) {
XRLog.load("Could not read " + uri + " as a URL; may be relative. Testing using parent URL " + path);
try {
- URI resourcePath = new URI(path);
+ File filePath = new File(path);
+ URI resourcePath = filePath.toURI();
resourcePath = resourcePath.resolve(uri);
// Builds the full resource path
- File file = new File(resourcePath.toString());
- URL result = file.toURI().toURL();
- ret = result.toString();
+ URL result = resourcePath.toURL();
+ ret = result.toURI().toString();
} catch (Exception e1) {
XRLog.exception("The default NaiveUserAgent cannot resolve the URL " + uri + " with base URL " + path);
}
1
0
r671 - branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst
by jpages@users.nuiton.org 24 May '12
by jpages@users.nuiton.org 24 May '12
24 May '12
Author: jpages
Date: 2012-05-24 10:44:53 +0200 (Thu, 24 May 2012)
New Revision: 671
Url: http://nuiton.org/repositories/revision/jrst/671
Log:
Am?\195?\169lioration de la r?\195?\169solution des chemins pour les images dans JRSTUserAgent.
Modified:
branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTUserAgent.java
Modified: branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTUserAgent.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTUserAgent.java 2012-05-23 15:26:30 UTC (rev 670)
+++ branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTUserAgent.java 2012-05-24 08:44:53 UTC (rev 671)
@@ -123,21 +123,12 @@
return new URL(uri).toString();
} catch (MalformedURLException e) {
XRLog.load("Could not read " + uri + " as a URL; may be relative. Testing using parent URL " + path);
- String ResourcePath = path;
try {
- // Transforms relative path to use it after
- if (uri.startsWith(THIS_DIRECTORY)) {
- uri = uri.replace(THIS_DIRECTORY, "");
- } else if ((uri.startsWith(PREVIOUS_DIRECTORY))) {
- while (uri.startsWith(PREVIOUS_DIRECTORY)) {
- uri = uri.replace(PREVIOUS_DIRECTORY, "");
- // ResourcePath becomes the path of the parent directory
- ResourcePath = path.substring(0, path.lastIndexOf("/", path.length()-2));
- ResourcePath = ResourcePath + "/";
- }
- }
+ URI resourcePath = new URI(path);
+ resourcePath = resourcePath.resolve(uri);
+
// Builds the full resource path
- File file = new File(ResourcePath + uri);
+ File file = new File(resourcePath.toString());
URL result = file.toURI().toURL();
ret = result.toString();
} catch (Exception e1) {
1
0
r670 - in branches/jrst-docutils-jython/jrst/src/test/resources: . schemas
by jpages@users.nuiton.org 23 May '12
by jpages@users.nuiton.org 23 May '12
23 May '12
Author: jpages
Date: 2012-05-23 17:26:30 +0200 (Wed, 23 May 2012)
New Revision: 670
Url: http://nuiton.org/repositories/revision/jrst/670
Log:
Ajout d'un dossier manquant pour les tests
Added:
branches/jrst-docutils-jython/jrst/src/test/resources/schemas/
branches/jrst-docutils-jython/jrst/src/test/resources/schemas/diagrammeClass.png
branches/jrst-docutils-jython/jrst/src/test/resources/schemas/diagrammeGeneration.png
branches/jrst-docutils-jython/jrst/src/test/resources/schemas/diagrammeSequence.png
branches/jrst-docutils-jython/jrst/src/test/resources/schemas/presentationXSL.png
Added: branches/jrst-docutils-jython/jrst/src/test/resources/schemas/diagrammeClass.png
===================================================================
(Binary files differ)
Property changes on: branches/jrst-docutils-jython/jrst/src/test/resources/schemas/diagrammeClass.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/jrst-docutils-jython/jrst/src/test/resources/schemas/diagrammeGeneration.png
===================================================================
(Binary files differ)
Property changes on: branches/jrst-docutils-jython/jrst/src/test/resources/schemas/diagrammeGeneration.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/jrst-docutils-jython/jrst/src/test/resources/schemas/diagrammeSequence.png
===================================================================
(Binary files differ)
Property changes on: branches/jrst-docutils-jython/jrst/src/test/resources/schemas/diagrammeSequence.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/jrst-docutils-jython/jrst/src/test/resources/schemas/presentationXSL.png
===================================================================
(Binary files differ)
Property changes on: branches/jrst-docutils-jython/jrst/src/test/resources/schemas/presentationXSL.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
1
0
Author: jpages
Date: 2012-05-23 16:35:21 +0200 (Wed, 23 May 2012)
New Revision: 669
Url: http://nuiton.org/repositories/revision/jrst/669
Log:
Correction de la g?\195?\169n?\195?\169ration de PDF en utilisant IText et nouveaux tests pour les images dans les pdfs.
Added:
branches/jrst-docutils-jython/jrst/src/main/java/org/dom4j/
branches/jrst-docutils-jython/jrst/src/main/java/org/dom4j/io/
branches/jrst-docutils-jython/jrst/src/main/java/org/dom4j/io/MyDocumentInputSource.java
branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTUserAgent.java
branches/jrst-docutils-jython/jrst/src/test/resources/docDeveloppeur.rst
Modified:
branches/jrst-docutils-jython/docutils/src/main/resources/docutils/__run__.py
branches/jrst-docutils-jython/doxia-module-jrst/src/main/java/org/nuiton/jrst/JrstParser.java
branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/devel/developerDoc.rst
branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/index.rst
branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/user/index.rst
branches/jrst-docutils-jython/jrst-doc/src/site/rst/index.rst
branches/jrst-docutils-jython/jrst-doc/src/site/rst/user/index.rst
branches/jrst-docutils-jython/jrst-doc/src/site/site_en.xml
branches/jrst-docutils-jython/jrst-doc/src/site/site_fr.xml
branches/jrst-docutils-jython/jrst/pom.xml
branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java
branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/convertisor/DocUtils2RST.java
branches/jrst-docutils-jython/jrst/src/main/resources/xsl/rst2xhtml.xsl
branches/jrst-docutils-jython/jrst/src/site/site_en.xml
branches/jrst-docutils-jython/jrst/src/site/site_fr.xml
branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/JRSTGeneratorTest.java
branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/DirectiveTest.java
branches/jrst-docutils-jython/pom.xml
Modified: branches/jrst-docutils-jython/docutils/src/main/resources/docutils/__run__.py
===================================================================
--- branches/jrst-docutils-jython/docutils/src/main/resources/docutils/__run__.py 2012-05-21 07:17:23 UTC (rev 668)
+++ branches/jrst-docutils-jython/docutils/src/main/resources/docutils/__run__.py 2012-05-23 14:35:21 UTC (rev 669)
@@ -12,18 +12,19 @@
# Define the function jaropen which will be able to read into the jar.
# Examples :
# If the value of the resourcePath is
- # '/home/user/workspace/jrst-docutils-jython/jrst/src/test/resources/text.rst',
+ # '/home/user/workspace/jrst/src/test/resources/text.rst',
# the classic function "open" can be used, but if the value is
# '__pyclasspath__/docutils/writers/html4css1/html4css1.css',
# python doesn't be able to find the resource, so it must have the
# absolute path to the jar to read it with jaropen after.
+ # ex: jar:file:/home/user/workspace/jrst/docutils/docutils.jar!
def jaropen(resourcePath, mode, bufsize=-1):
if "__pyclasspath__" in resourcePath:
# Replace the relative resource filepath by the absolute path
docutilsAbsolutePath = "jar:file:" + os.path.dirname(docutilsPath) + "!"
resourcePath = string.replace(resourcePath, "__pyclasspath__", docutilsAbsolutePath)
# Get the url and open a stream to access to the resource
- # /!\ Warning : we use a deprecated function, it will could be a problem later
+ # /!\ Warning : we use a deprecated function, it could be a problem later
url = URL(resourcePath)
inStream = url.openStream()
f = __builtin__.openlegacy(inStream, bufsize)
@@ -56,4 +57,4 @@
from docutils.core import publish_file
publish_file( source_path=filein, writer_name=typeOutput )
else:
- print "Wrong output format"
+ print "Wrong output format"
\ No newline at end of file
Modified: branches/jrst-docutils-jython/doxia-module-jrst/src/main/java/org/nuiton/jrst/JrstParser.java
===================================================================
--- branches/jrst-docutils-jython/doxia-module-jrst/src/main/java/org/nuiton/jrst/JrstParser.java 2012-05-21 07:17:23 UTC (rev 668)
+++ branches/jrst-docutils-jython/doxia-module-jrst/src/main/java/org/nuiton/jrst/JrstParser.java 2012-05-23 14:35:21 UTC (rev 669)
@@ -49,7 +49,6 @@
* @plexus.component role="org.apache.maven.doxia.parser.Parser" role-hint="jrst"
*/
public class JrstParser extends XdocParser {
- protected static Log log = LogFactory.getLog(JRST.class);
@Override
public void parse(Reader source, Sink sink) throws ParseException {
Modified: branches/jrst-docutils-jython/jrst/pom.xml
===================================================================
--- branches/jrst-docutils-jython/jrst/pom.xml 2012-05-21 07:17:23 UTC (rev 668)
+++ branches/jrst-docutils-jython/jrst/pom.xml 2012-05-23 14:35:21 UTC (rev 669)
@@ -132,13 +132,19 @@
<artifactId>jython-standalone</artifactId>
</dependency>
- <!-- Flying Saucer -->
- <!--dependency>
+ <!-- itext -->
+ <dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>core-renderer</artifactId>
<version>R8</version>
- </dependency-->
+ </dependency>
+ <dependency>
+ <groupId>com.lowagie</groupId>
+ <artifactId>itext</artifactId>
+ <version>2.0.8</version>
+ </dependency>
+
</dependencies>
<!-- ************************************************************* -->
Added: branches/jrst-docutils-jython/jrst/src/main/java/org/dom4j/io/MyDocumentInputSource.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/main/java/org/dom4j/io/MyDocumentInputSource.java (rev 0)
+++ branches/jrst-docutils-jython/jrst/src/main/java/org/dom4j/io/MyDocumentInputSource.java 2012-05-23 14:35:21 UTC (rev 669)
@@ -0,0 +1,16 @@
+package org.dom4j.io;
+
+import org.dom4j.Document;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: jpages
+ * Date: 22/05/12
+ * Time: 16:36
+ * To change this template use File | Settings | File Templates.
+ */
+public class MyDocumentInputSource extends DocumentInputSource {
+ public MyDocumentInputSource(Document document) {
+ super(document);
+ }
+}
Modified: branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java 2012-05-21 07:17:23 UTC (rev 668)
+++ branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java 2012-05-23 14:35:21 UTC (rev 669)
@@ -30,24 +30,16 @@
import java.net.URL;
import java.util.*;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.sax.SAXResult;
-import javax.xml.transform.stream.StreamSource;
-import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.Fop;
-import org.apache.fop.apps.FopFactory;
-import org.apache.fop.apps.MimeConstants;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
+import org.dom4j.io.MyDocumentInputSource;
import org.nuiton.i18n.I18n;
import org.nuiton.i18n.init.ClassPathI18nInitializer;
import org.nuiton.jrst.convertisor.DocUtils2RST;
@@ -57,8 +49,7 @@
import org.nuiton.util.Resource;
import org.nuiton.util.StringUtil;
import org.python.util.PythonInterpreter;
-import org.xml.sax.InputSource;
-import org.xml.sax.XMLReader;
+import org.xhtmlrenderer.pdf.ITextRenderer;
/**
* FIXME: 'JRST --help' doesn't work, but 'JRST --help toto' work :( FIXME:
@@ -92,13 +83,6 @@
NEVER, IFNEWER, ALLTIME
}
- /*
- // Formats created with Docutils and Jython
- public enum Docutils_Formats {
- XML, HTML, PDF, ODT, LATEX, S5, XETEX, MAN, RST
- }
- */
-
/** to use log facility, just put in your code: log.info("..."); */
protected static Log log = LogFactory.getLog(JRST.class);
@@ -118,9 +102,6 @@
/** XSL Stylesheet to transform Docbook into htmlhelp. */
protected static final String docbook2htmlhelp = "/docbook/htmlhelp/htmlhelp.xsl";
-// /** XSL Stylesheet to transform xml into rst. */
-// protected static final String rst2rst = "JRSTWriter";
-
/** XSL Stylesheet to transform Docbook into PDF. */
protected static final String docbook2fo = "/docbook/fo/docbook.xsl";
@@ -183,7 +164,7 @@
stylesheets.put(TYPE_RST, "");
//stylesheets.put(TYPE_ODT, rst2docbook + "," + docbook2odf);
stylesheets.put(TYPE_FO, rst2docbook + "," + docbook2fo);
- stylesheets.put(TYPE_PDF, rst2docbook + "," + docbook2fo);
+ stylesheets.put(TYPE_PDF, rst2xhtml);
mimeType = new HashMap<String, String>();
mimeType.put(TYPE_HTML, "text/html");
@@ -298,51 +279,53 @@
+ ", because already exists");
} else {
// Out
- FileOutputStream outputStream = new FileOutputStream(fileOut);
- OutputStreamWriter writer = new OutputStreamWriter(outputStream, outputEncoding);
+ OutputStream outputStream = new FileOutputStream(fileOut);
// Generate
- String result = generateString(outputType, fileIn);
+ Document result = generateDocument(outputType, fileIn);
- fileOut.getAbsoluteFile().getParentFile().mkdirs();
-
// generation PDF
if (outputType.equals("pdf")) {
- FopFactory fopFactory = FopFactory.newInstance();
+ try {
+ DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ builder.setEntityResolver(result.getEntityResolver());
+ MyDocumentInputSource source = new MyDocumentInputSource(result);
+ org.w3c.dom.Document doc = builder.parse(source);
- OutputStream outPDF = new BufferedOutputStream(new FileOutputStream(
- fileOut));
+ ITextRenderer renderer = new ITextRenderer();
- FOUserAgent userAgent = fopFactory.newFOUserAgent();
+ // Settings to resolve paths with the JRST User Agent
+ String absolutePath = fileIn.getParentFile().getAbsolutePath() + "/";
+ JRSTUserAgent jrstUserAgent = new JRSTUserAgent(absolutePath);
+ jrstUserAgent.setBaseURL(absolutePath);
+ renderer.getSharedContext().setUserAgentCallback(jrstUserAgent);
+ jrstUserAgent.setSharedContext(renderer.getSharedContext());
- // Step 3: Construct fop with desired output format
- Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF,
- userAgent, outPDF);
+ // Generation of the pdf file
+ renderer.setDocument(doc, null);
+ renderer.layout();
+ renderer.createPDF(outputStream);
+ } catch (Exception eee) {
+ log.error("Failed to write PDF", eee);
+ } finally {
+ outputStream.close();
+ }
- // Step 4: Setup JAXP using identity transformer
- TransformerFactory factory = TransformerFactory
- .newInstance();
- Transformer transformer = factory.newTransformer(); // identity
- // transformer
-
- // Step 5: Setup input and output for XSLT transformation
- // Setup input stream
- Source src = new StreamSource(new StringReader(result));
-
- // Resulting SAX events (the generated FO) must be piped
- // through to FOP
- Result res = new SAXResult(fop.getDefaultHandler());
-
- // Step 6: Start XSLT transformation and FOP processing
- transformer.transform(src, res);
-
- outPDF.close();
} else {
- // write generated document
- writer.write(result);
+ OutputStreamWriter writer = null;
+ try {
+ writer = new OutputStreamWriter(outputStream, outputEncoding);
- writer.close();
+ // write generated document
+ writer.write(result.asXML());
+ }catch (Exception eee) {
+ log.error("Failed to write " + outputType + " file", eee);
+ } finally {
+ if (writer != null) {
+ writer.close();
+ }
+ }
}
}
@@ -392,15 +375,21 @@
*/
public static String generateString(String outputType, File in) throws Exception {
+ return generateDocument(outputType, in).asXML();
+ }
+ /**
+ *
+ * @param outputType
+ * @param in
+ * @throws Exception
+ */
+ public static Document generateDocument(String outputType, File in) throws Exception {
+
Document doc = generateXML(in);
// Sortie vers rst
- if (outputType.equals(TYPE_RST)){
- return generateRST(doc);
- } else if (!StringUtils.isEmpty(outputType)) {
- doc = applyXsls(doc, outputType);
- }
- return doc.asXML();
+ doc = applyXsls(doc, outputType);
+ return doc;
}
private static Document applyXsls(Document doc, String xslListOrOutType) throws IOException, TransformerException {
Added: branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTUserAgent.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTUserAgent.java (rev 0)
+++ branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRSTUserAgent.java 2012-05-23 14:35:21 UTC (rev 669)
@@ -0,0 +1,162 @@
+package org.nuiton.jrst;
+
+import com.lowagie.text.Image;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xhtmlrenderer.extend.UserAgentCallback;
+import org.xhtmlrenderer.layout.SharedContext;
+import org.xhtmlrenderer.pdf.ITextFSImage;
+import org.xhtmlrenderer.resource.CSSResource;
+import org.xhtmlrenderer.resource.ImageResource;
+import org.xhtmlrenderer.resource.XMLResource;
+import org.xhtmlrenderer.swing.NaiveUserAgent;
+import org.xhtmlrenderer.util.XRLog;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: jpages
+ * Date: 22/05/12
+ * Time: 17:38
+ * To change this template use File | Settings | File Templates.
+ */
+public class JRSTUserAgent implements UserAgentCallback {
+
+ public static final String THIS_DIRECTORY = "./";
+
+ public static final String PREVIOUS_DIRECTORY = "../";
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ protected static Log log = LogFactory.getLog(JRSTUserAgent.class);
+
+ protected NaiveUserAgent delegate;
+
+ // Resources path
+ protected String path;
+
+ private SharedContext sharedContext;
+
+ public JRSTUserAgent(String path) {
+ this.path = path;
+ this.delegate = new NaiveUserAgent();
+ }
+
+
+ @Override
+ public CSSResource getCSSResource(String uri) {
+ return delegate.getCSSResource(uri);
+ }
+
+ @Override
+ public ImageResource getImageResource(String uri) {
+ uri = resolveURI(uri);
+ return createImageResource(uri);
+ }
+
+ protected ImageResource createImageResource(String uri) {
+ ImageResource imageResource = null;
+
+ try {
+ // Gets the image with its url
+ URL source = new URI(uri).toURL();
+ Image image = Image.getInstance(source);
+
+ // Sets the scale of the image
+ scaleToOutputResolution(image);
+
+ ITextFSImage iTextFSImage = new ITextFSImage(image);
+ imageResource = new ImageResource(iTextFSImage);
+ } catch (Exception eee) {
+ log.error("Failed to create image resource", eee);
+ }
+
+ return imageResource;
+ }
+
+ @Override
+ public XMLResource getXMLResource(String uri) {
+ return delegate.getXMLResource(uri);
+ }
+
+ @Override
+ public byte[] getBinaryResource(String uri) {
+ return delegate.getBinaryResource(uri);
+ }
+
+ @Override
+ public boolean isVisited(String uri) {
+ return delegate.isVisited(uri);
+ }
+
+ @Override
+ public void setBaseURL(String url) {
+ delegate.setBaseURL(url);
+ }
+
+ @Override
+ public String getBaseURL() {
+ return delegate.getBaseURL();
+ }
+
+ public String resolveURI(String uri) {
+ if (uri == null) return null;
+ String ret = null;
+ if (path == null) {
+ try {
+ URL result = new URL(uri);
+ setBaseURL(result.toExternalForm());
+ } catch (MalformedURLException e) {
+ try {
+ setBaseURL(new File(".").toURI().toURL().toExternalForm());
+ } catch (Exception e1) {
+ XRLog.exception("The default NaiveUserAgent doesn't know how to resolve the base URL for " + uri);
+ return null;
+ }
+ }
+ }
+
+ try {
+ return new URL(uri).toString();
+ } catch (MalformedURLException e) {
+ XRLog.load("Could not read " + uri + " as a URL; may be relative. Testing using parent URL " + path);
+ String ResourcePath = path;
+ try {
+ // Transforms relative path to use it after
+ if (uri.startsWith(THIS_DIRECTORY)) {
+ uri = uri.replace(THIS_DIRECTORY, "");
+ } else if ((uri.startsWith(PREVIOUS_DIRECTORY))) {
+ while (uri.startsWith(PREVIOUS_DIRECTORY)) {
+ uri = uri.replace(PREVIOUS_DIRECTORY, "");
+ // ResourcePath becomes the path of the parent directory
+ ResourcePath = path.substring(0, path.lastIndexOf("/", path.length()-2));
+ ResourcePath = ResourcePath + "/";
+ }
+ }
+ // Builds the full resource path
+ File file = new File(ResourcePath + uri);
+ URL result = file.toURI().toURL();
+ ret = result.toString();
+ } catch (Exception e1) {
+ XRLog.exception("The default NaiveUserAgent cannot resolve the URL " + uri + " with base URL " + path);
+ }
+ }
+ return ret;
+ }
+
+ private void scaleToOutputResolution(Image image) {
+ float factor = this.sharedContext.getDotsPerPixel();
+ image.scaleAbsolute(image.getPlainWidth() * factor, image.getPlainHeight() * factor);
+ }
+
+ public SharedContext getSharedContext() {
+ return this.sharedContext;
+ }
+
+ public void setSharedContext(SharedContext sharedContext) {
+ this.sharedContext = sharedContext;
+ }
+}
Modified: branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/convertisor/DocUtils2RST.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/convertisor/DocUtils2RST.java 2012-05-21 07:17:23 UTC (rev 668)
+++ branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/convertisor/DocUtils2RST.java 2012-05-23 14:35:21 UTC (rev 669)
@@ -506,6 +506,8 @@
@Override
public String composeFootnoteReference(Element e) {
+ String result = indent(e.getText(), level);
+ log.warn("composeFootnoteReference :\n" + result);
return EMPTY_STRING;
}
Modified: branches/jrst-docutils-jython/jrst/src/main/resources/xsl/rst2xhtml.xsl
===================================================================
--- branches/jrst-docutils-jython/jrst/src/main/resources/xsl/rst2xhtml.xsl 2012-05-21 07:17:23 UTC (rev 668)
+++ branches/jrst-docutils-jython/jrst/src/main/resources/xsl/rst2xhtml.xsl 2012-05-23 14:35:21 UTC (rev 669)
@@ -489,7 +489,7 @@
</xsl:template>
<xsl:template match="footnote">
- <table class="footnote" frame="void" id="{@id}" rules="none">
+ <table class="footnote" frame="void" id="{@ids}" rules="none">
<colgroup>
<col class="label"/>
<col/>
@@ -497,7 +497,7 @@
<tbody valign="top">
<tr>
<td class="label">
- <a class="backref" href="#{@backrefs}" name="{id}">
+ <a class="backref" href="#{@backrefs}" name="{@ids}">
[<xsl:value-of select="label"/>]
</a>
</td>
@@ -513,9 +513,9 @@
</xsl:template>
<xsl:template match="footnote_reference">
- <a class="footnote_reference" href="#{@refid}" id="{@id}" name="{@id}">
+ <a class="footnote_reference" href="#{@refid}" id="{@ids}" name="{@ids}">
[<xsl:value-of select="text()"/>]
</a>
</xsl:template>
-</xsl:stylesheet>
\ No newline at end of file
+</xsl:stylesheet>
Modified: branches/jrst-docutils-jython/jrst/src/site/site_en.xml
===================================================================
--- branches/jrst-docutils-jython/jrst/src/site/site_en.xml 2012-05-21 07:17:23 UTC (rev 668)
+++ branches/jrst-docutils-jython/jrst/src/site/site_en.xml 2012-05-23 14:35:21 UTC (rev 669)
@@ -25,7 +25,22 @@
-->
<project name="${project.name}">
+ <skin>
+ <groupId>org.apache.maven.skins</groupId>
+ <artifactId>maven-fluido-skin</artifactId>
+ <version>1.2.1</version>
+ </skin>
+ <custom>
+ <fluidoSkin>
+ <topBarEnabled>true</topBarEnabled>
+ <googleSearch/>
+ <sideBarEnabled>false</sideBarEnabled>
+ <searchEnabled>true</searchEnabled>
+ <sourceLineNumbersEnabled>true</sourceLineNumbersEnabled>
+ </fluidoSkin>
+ </custom>
+
<bannerLeft>
<name>Java ReStructuredText parser</name>
<href>/</href>
Modified: branches/jrst-docutils-jython/jrst/src/site/site_fr.xml
===================================================================
--- branches/jrst-docutils-jython/jrst/src/site/site_fr.xml 2012-05-21 07:17:23 UTC (rev 668)
+++ branches/jrst-docutils-jython/jrst/src/site/site_fr.xml 2012-05-23 14:35:21 UTC (rev 669)
@@ -25,7 +25,24 @@
-->
<project name="${project.name}">
+ <skin>
+ <groupId>org.apache.maven.skins</groupId>
+ <artifactId>maven-fluido-skin</artifactId>
+ <version>1.2.1</version>
+ </skin>
+ <custom>
+ <fluidoSkin>
+ <topBarEnabled>true</topBarEnabled>
+ <googleSearch/>
+ <sideBarEnabled>false</sideBarEnabled>
+ <searchEnabled>true</searchEnabled>
+ <sourceLineNumbersEnabled>true</sourceLineNumbersEnabled>
+ </fluidoSkin>
+ </custom>
+
+
+
<bannerLeft>
<name>Java ReStructuredText parser</name>
<href>/</href>
Modified: branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/JRSTGeneratorTest.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/JRSTGeneratorTest.java 2012-05-21 07:17:23 UTC (rev 668)
+++ branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/JRSTGeneratorTest.java 2012-05-23 14:35:21 UTC (rev 669)
@@ -73,11 +73,23 @@
log.info("Testing RST to HTML (test.rst)...");
}
- String test1 = getOutputTestPath("jrst-RstToHtml2.html");
+ String test1 = getOutputTestPath("jrst-RstToHtml.html");
JRST.main(new String[]{"-t", "html", "--force", "-o", test1, getResourcesTestPath()});
}
-
+
@Test
+ public void testRstToHtml2() throws Exception {
+
+ if (log.isInfoEnabled()) {
+ log.info("Testing RST to HTML (docDeveloppeur.rst) ...");
+ }
+
+ String test1 = getOutputTestPath("jrst-RstToHtml2.html");
+ JRST.main(new String[]{"-t", "html", "--force", "-o", test1, getTestFile("docDeveloppeur.rst").getPath()});
+ }
+
+
+ @Test
public void testRstToDocbook() throws Exception {
if (log.isInfoEnabled()) {
@@ -153,12 +165,21 @@
public void testRstToPDF() throws Exception {
if (log.isInfoEnabled()) {
- log.info("Testing RST to PDF (frEntier.rst) ...");
+ log.info("Testing RST to PDF (test.rst) ...");
}
String test1 = getOutputTestPath("jrst-RstToPDF.pdf");
- // Doesn't work with test.rst, so we use an other file
- JRST.main(new String[]{"-t", "pdf", "--force", "-o", test1, getTestFile("test5.rst").getPath()});
- //JRST.main(new String[]{"-t", "pdf", "--force", "-o", test1, getResourcesTestPath()});
+ JRST.main(new String[]{"-t", "pdf", "--force", "-o", test1, getResourcesTestPath()});
}
+
+ @Test
+ public void testRstToPDF2() throws Exception {
+
+ if (log.isInfoEnabled()) {
+ log.info("Testing RST to PDF (docDeveloppeur.rst) ...");
+ }
+
+ String test1 = getOutputTestPath("jrst-RstToPDF2.pdf");
+ JRST.main(new String[]{"-t", "pdf", "--force", "-o", test1, getTestFile("docDeveloppeur.rst").getPath()});
+ }
}
Modified: branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/DirectiveTest.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/DirectiveTest.java 2012-05-21 07:17:23 UTC (rev 668)
+++ branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/DirectiveTest.java 2012-05-23 14:35:21 UTC (rev 669)
@@ -55,7 +55,7 @@
File out = getOutputTestFile("jrst-testImages.html");
// out.deleteOnExit();
JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME);
-
+
String content = FileUtils.readFileToString(out, JRST.UTF_8);
assertTrue(content.indexOf("alt=\"alternate text\"") > 0);
assertTrue(content.indexOf("width=\"200px\"") > 0);
Added: branches/jrst-docutils-jython/jrst/src/test/resources/docDeveloppeur.rst
===================================================================
--- branches/jrst-docutils-jython/jrst/src/test/resources/docDeveloppeur.rst (rev 0)
+++ branches/jrst-docutils-jython/jrst/src/test/resources/docDeveloppeur.rst 2012-05-23 14:35:21 UTC (rev 669)
@@ -0,0 +1,153 @@
+.. -
+.. * #%L
+.. * JRst :: Documentation
+.. *
+.. * $Id: docDeveloppeur.rst 668 2012-05-21 07:17:23Z jpages $
+.. * $HeadURL: http://svn.nuiton.org/svn/jrst/branches/jrst-docutils-jython/jrst-doc/src/s… $
+.. * %%
+.. * Copyright (C) 2009 - 2010 CodeLutin
+.. * %%
+.. * This program is free software: you can redistribute it and/or modify
+.. * it under the terms of the GNU Lesser General Public License as
+.. * published by the Free Software Foundation, either version 3 of the
+.. * License, or (at your option) any later version.
+.. *
+.. * This program is distributed in the hope that it will be useful,
+.. * but WITHOUT ANY WARRANTY; without even the implied warranty of
+.. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.. * GNU General Lesser Public License for more details.
+.. *
+.. * You should have received a copy of the GNU General Lesser Public
+.. * License along with this program. If not, see
+.. * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+.. * #L%
+.. -
+
+=========================
+Documentation développeur
+=========================
+
+.. contents:: Sommaire
+
+Le diagramme de Class
+=====================
+
+.. image:: ./schemas/diagrammeClass.png
+ :alt: Diagramme de classes
+ :align: center
+ :width: 400 px
+
+La classe **JRST** contient la méthode main(), elle gère les options, la lecture et l'écriture des fichiers. Elle appelle dans un premier temps la classe **PythonInterpreter** de Jython_ permettant d'exécuter les scripts en Python de DocUtils_ pour générer un fichier XML intermédiaire. Ensuite, il ne reste qu'à appliquer le XSL désiré (si besoin) grâce à la classe **JRSTGenerator**.
+
+La génération
+=============
+
+.. image:: ../resources/schemas/diagrammeGeneration.png
+ :alt: Arbre des différentes générations possibles
+ :align: center
+ :width: 600 px
+
+
+Référence :
+
+ * xml2rst.xsl (convertion de xml de docutils vers rst) : http://www.merten-home.de/FreeSoftware/xml2rst
+ * dn2dbk.xsl (convertion de xml de docutils vers docbook) : http://membres.lycos.fr/ebellot/dn2dbk
+ * les xsl de nwalsh (convertion de docbook vers FO et xhtml) : http://nwalsh.com
+
+ * XMLmind (convertion de FO vers ODT et RTF) : http://www.xmlmind.com/foconverter/what_is_xfc.html
+ * FOP (convertion de FO vers PDF) : http://xmlgraphics.apache.org/fop
+
+
+Exemple d'utilisation
+=====================
+
+
+L'on souhaite convertir le document rst (text.rst) suivant en html (text.html) :
+
+::
+
+ =====
+ Titre
+ =====
+
+ :Author: Letellier Sylvain
+
+ .. Attention:: texte à être réinterprété comme un fichier rst indépendant
+ ceci est considéré comme un **paragraphe**
+
+On utilise donc la commande suivante::
+
+ JRST -t html -o text.html text.rst
+
+Ce diagramme de séquence décrit le fonctionnement du parseur tout au long de la génération :
+
+.. image:: ./schemas/diagrammeSequence.png
+ :alt: Diagramme de séquence d'une génération
+ :align: center
+ :width: 600 px
+
+
+La Classe **JRSTGenerator**, grâce au fichier XSL rst2xhtml.xsl, renvoie le fichier html suivant::
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <html xmlns="http://www.w3.org/TR/xhtml1/strict">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <meta name="generator" content="JRST http://jrst.labs.libre-entreprise.org/"/>
+ <title>Titre</title>
+ </head>
+ <body>
+ <h1>Titre</h1>
+ <table class="docinfo" frame="void" rules="none">
+ <col class="docinfo-name"/>
+ <col class="docinfo-content"/>
+ <tbody valign="top">
+ <tr>
+ <th class="docpatterninfo-name">author :</th>
+ <td class="docinfo-content">Letellier Sylvain</td>
+ </tr>
+ </tbody>
+ </table>
+ <div class="attention">
+ <p class="title">attention :</p>
+ <p class="body">
+ <p>texte à être réinterprété comme un fichier rst indépendant
+ ceci est considéré comme un <strong>paragraphe</strong></p>
+ </p>
+ </div>
+ </body>
+ </html>
+
+Qui affiche la page (un CSS [1]_ à été ajouté pour la mise en forme) :
+
+.. topic:: Titre
+
+ :Author: Letellier Sylvain
+
+ .. Attention:: texte à être réinterprété comme un fichier rst indépendant
+ ceci est considéré comme un **paragraphe**
+
+Utilisation de XSL externe
+==========================
+
+JRST propose de transformer le XML de docutils_ avec des fichiers XSL [2]_ externe.
+Pour cela, il faut utiliser la commande::
+
+ JRST -x fichierXSL, fichierXSL2 fichierRST
+
+ou::
+
+ JRST --xslFile fichierXSL, fichierXSL2 fichierRST
+
+JRST traitera le fichierRST, le XML de DocUtils_ qui est retourné sera transformé par la Class JRSTgenerator
+en commençant par le fichierXSL puis par le fichierXSL2...
+
+.. [1] `Cascading Style Sheets`_
+.. [2] Une documentation sur le XSL est diponible ici_.
+
+.. _ici: ./presentationXSL.html
+.. _Cascading Style Sheets: http://fr.wikipedia.org/wiki/Feuilles_de_style_en_cascade
+.. _RST: http://docutils.sourceforge.net/rst.html
+.. _DocUtils: http://docutils.sourceforge.net/docs/ref/doctree.html
+.. _Jython: http://jython.org/index.html
+
Modified: branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/devel/developerDoc.rst
===================================================================
--- branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/devel/developerDoc.rst 2012-05-21 07:17:23 UTC (rev 668)
+++ branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/devel/developerDoc.rst 2012-05-23 14:35:21 UTC (rev 669)
@@ -33,9 +33,6 @@
|classDiagramme|
-La classe **JRST** contient la méthode main(), elle gère les options, la lecture et l'écriture des fichiers. Elle appelle dans un premier temps la classe **PythonInterpreter** de Jython_ permettant d'exécuter les scripts en Python de DocUtils_ pour générer un fichier XML intermédiaire. Ensuite, il ne reste qu'à appliquer le XSL désiré (si besoin) grâce à la classe **JRSTGenerator**.
-
-
**JRST** Class contents main() method, it's looking after options, files reading and writing. Iinitially, it calls Jython_ class **PythonInterpreter** which allows to execute DocUtils' Python script to generate an intermediate file. Then it only remains to apply the wish XSL (if needed) by using **JRSTGenerator** Class.
Generation
Modified: branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/index.rst
===================================================================
--- branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/index.rst 2012-05-21 07:17:23 UTC (rev 668)
+++ branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/index.rst 2012-05-23 14:35:21 UTC (rev 669)
@@ -60,11 +60,11 @@
This command converts myfile.rst toward XML file, displayed to the standard output (console).
Several options are available :
--o file,--outFile=file to write toward a file.
--t format,--outType format to specify exit format, so using generation XSL_ file(s). Several formats are available xhtml, docbook, xml, HTML, xdoc, rst, pdf, odt, rtf.
--x xslFile,--xslFile xslFile to specify generation XSL_ file at using.
---force to overwrite, if file exists, it will be replaced by the new one.
---help to display available options :
+-o file, --outFile=file To write toward a file.
+-t format, --outType format To specify exit format, so using generation XSL_ file(s). Several formats are available xhtml, docbook, xml, HTML, xdoc, rst, pdf, odt, rtf.
+-x xslFile, --xslFile xslFile To specify generation XSL_ file at using.
+--force To overwrite, if file exists, it will be replaced by the new one.
+--help To display available options :
::
Modified: branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/user/index.rst
===================================================================
--- branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/user/index.rst 2012-05-21 07:17:23 UTC (rev 668)
+++ branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/user/index.rst 2012-05-23 14:35:21 UTC (rev 669)
@@ -60,11 +60,11 @@
This command converts myfile.rst toward XML file, displayed to the standard output (console).
Several options are available :
--o file,--outFile=file to write toward a file.
--t format,--outType format to specify exit format, so using generation XSL_ file(s). Several formats are available xhtml, docbook, xml, HTML, xdoc, rst, pdf, odt, rtf.
--x xslFile,--xslFile xslFile to specify generation XSL_ file at using.
---force to overwrite, if file exists, it will be replaced by the new one.
---help to display available options :
+-o file, --outFile=file To write toward a file.
+-t format, --outType format To specify exit format, so using generation XSL_ file(s). Several formats are available xhtml, docbook, xml, HTML, xdoc, rst, pdf, odt, rtf.
+-x xslFile, --xslFile xslFile To specify generation XSL_ file at using.
+--force To overwrite, if file exists, it will be replaced by the new one.
+--help To display available options :
::
Modified: branches/jrst-docutils-jython/jrst-doc/src/site/rst/index.rst
===================================================================
--- branches/jrst-docutils-jython/jrst-doc/src/site/rst/index.rst 2012-05-21 07:17:23 UTC (rev 668)
+++ branches/jrst-docutils-jython/jrst-doc/src/site/rst/index.rst 2012-05-23 14:35:21 UTC (rev 669)
@@ -61,11 +61,11 @@
Cette commande aura pour effet de convertir le fichier myfile.rst en XML qui sera affiché sur la sortie standard (console).
Plusieurs options sont disponibles :
--o file,--outFile=file pour rediriger la sortie vers un fichier.
--t format,--outType format pour préciser un format de sortie, donc utiliser un ou des fichiers XSL_ de génération. Plusieurs formats sont disponibles xhtml, docbook, xml, html, xdoc, rst, pdf, odt, rtf.
--x xslFile,--xslFile xslFile sert à préciser le fichier xsl de génération à utiliser.
---force forcer l'écriture d'un fichier, si le fichier de sortie existe, il sera remplacé.
---help pour afficher les options disponibles :
+-o file, --outFile=file Pour rediriger la sortie vers un fichier.
+-t format, --outType format Pour préciser un format de sortie, donc utiliser un ou des fichiers XSL_ de génération. Plusieurs formats sont disponibles xhtml, docbook, xml, html, xdoc, rst, pdf, odt, rtf.
+-x xslFile, --xslFile xslFile Sert à préciser le fichier xsl de génération à utiliser.
+--force Forcer l'écriture d'un fichier, si le fichier de sortie existe, il sera remplacé.
+--help Pour afficher les options disponibles :
::
@@ -95,7 +95,7 @@
http://maven-site.nuiton.org/jrst/maven-jrst-plugin. Il permet l'utilisation
depuis Maven_ de JRst.
-.. [1] Seul les formats html, xhtml, DocBook_, xdoc et pdf sont disponible pour le moment.
+.. [1] Seuls les formats html, xhtml, DocBook_, xdoc et pdf sont disponibles pour le moment.
.. _reStructuredText: ./user/presentationRST.html
.. _RST: ./user/presentationRST.html
Modified: branches/jrst-docutils-jython/jrst-doc/src/site/rst/user/index.rst
===================================================================
--- branches/jrst-docutils-jython/jrst-doc/src/site/rst/user/index.rst 2012-05-21 07:17:23 UTC (rev 668)
+++ branches/jrst-docutils-jython/jrst-doc/src/site/rst/user/index.rst 2012-05-23 14:35:21 UTC (rev 669)
@@ -61,11 +61,11 @@
Cette commande aura pour effet de convertir le fichier myfile.rst en XML qui sera affiché sur la sortie standard (console).
Plusieurs options sont disponibles :
--o file,--outFile=file pour rediriger la sortie vers un fichier.
--t format,--outType format pour préciser un format de sortie, donc utiliser un ou des fichiers XSL_ de génération. Plusieurs formats sont disponibles xhtml, docbook, xml, html, xdoc, rst, pdf, odt, rtf.
--x xslFile,--xslFile xslFile sert à préciser le fichier xsl de génération à utiliser.
---force forcer l'écriture d'un fichier, si le fichier de sortie existe, il sera remplacé.
---help pour afficher les options disponibles :
+-o file, --outFile=file Pour rediriger la sortie vers un fichier.
+-t format, --outType format Pour préciser un format de sortie, donc utiliser un ou des fichiers XSL_ de génération. Plusieurs formats sont disponibles xhtml, docbook, xml, html, xdoc, rst, pdf, odt, rtf.
+-x xslFile, --xslFile xslFile Sert à préciser le fichier xsl de génération à utiliser.
+--force Forcer l'écriture d'un fichier, si le fichier de sortie existe, il sera remplacé.
+--help Pour afficher les options disponibles :
::
Modified: branches/jrst-docutils-jython/jrst-doc/src/site/site_en.xml
===================================================================
--- branches/jrst-docutils-jython/jrst-doc/src/site/site_en.xml 2012-05-21 07:17:23 UTC (rev 668)
+++ branches/jrst-docutils-jython/jrst-doc/src/site/site_en.xml 2012-05-23 14:35:21 UTC (rev 669)
@@ -25,7 +25,22 @@
-->
<project name="${project.name}">
+ <skin>
+ <groupId>org.apache.maven.skins</groupId>
+ <artifactId>maven-fluido-skin</artifactId>
+ <version>1.2.1</version>
+ </skin>
+ <custom>
+ <fluidoSkin>
+ <topBarEnabled>true</topBarEnabled>
+ <googleSearch/>
+ <sideBarEnabled>false</sideBarEnabled>
+ <searchEnabled>true</searchEnabled>
+ <sourceLineNumbersEnabled>true</sourceLineNumbersEnabled>
+ </fluidoSkin>
+ </custom>
+
<poweredBy>
<logo href="http://jrst.labs.libre-entreprise.org" name="JRst"
img="${project.url}/images/jrst-logo.png"/>
Modified: branches/jrst-docutils-jython/jrst-doc/src/site/site_fr.xml
===================================================================
--- branches/jrst-docutils-jython/jrst-doc/src/site/site_fr.xml 2012-05-21 07:17:23 UTC (rev 668)
+++ branches/jrst-docutils-jython/jrst-doc/src/site/site_fr.xml 2012-05-23 14:35:21 UTC (rev 669)
@@ -26,6 +26,22 @@
<project name="${project.name}">
+ <skin>
+ <groupId>org.apache.maven.skins</groupId>
+ <artifactId>maven-fluido-skin</artifactId>
+ <version>1.2.1</version>
+ </skin>
+
+ <custom>
+ <fluidoSkin>
+ <topBarEnabled>true</topBarEnabled>
+ <googleSearch/>
+ <sideBarEnabled>false</sideBarEnabled>
+ <searchEnabled>true</searchEnabled>
+ <sourceLineNumbersEnabled>true</sourceLineNumbersEnabled>
+ </fluidoSkin>
+ </custom>
+
<poweredBy>
<logo href="http://jrst.labs.libre-entreprise.org" name="JRst"
img="${project.url}/images/jrst-logo.png"/>
Modified: branches/jrst-docutils-jython/pom.xml
===================================================================
--- branches/jrst-docutils-jython/pom.xml 2012-05-21 07:17:23 UTC (rev 668)
+++ branches/jrst-docutils-jython/pom.xml 2012-05-23 14:35:21 UTC (rev 669)
@@ -312,13 +312,20 @@
<version>2.5.2</version>
</dependency>
- <!-- Flying Saucer -->
+ <!-- itext -->
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>core-renderer</artifactId>
<version>R8</version>
</dependency>
+ <dependency>
+ <groupId>com.lowagie</groupId>
+ <artifactId>itext</artifactId>
+ <version>2.0.8</version>
+ </dependency>
+
+
</dependencies>
</dependencyManagement>
1
0
r668 - in branches/jrst-docutils-jython: doxia-module-jrst/src/main/java/org/nuiton/jrst jrst-doc/src/site/en/rst jrst-doc/src/site/en/rst/devel jrst-doc/src/site/en/rst/devel/images jrst-doc/src/site/en/rst/user jrst-doc/src/site/resources/schemas jrst-doc/src/site/rst jrst-doc/src/site/rst/devel jrst-doc/src/site/rst/user
by jpages@users.nuiton.org 21 May '12
by jpages@users.nuiton.org 21 May '12
21 May '12
Author: jpages
Date: 2012-05-21 09:17:23 +0200 (Mon, 21 May 2012)
New Revision: 668
Url: http://nuiton.org/repositories/revision/jrst/668
Log:
Mise ?\195?\160 jour de la documentation pour prendre en compte les modifications apport?\195?\169es avec Jython et Docutils.
Modified:
branches/jrst-docutils-jython/doxia-module-jrst/src/main/java/org/nuiton/jrst/JrstParser.java
branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/devel/developerDoc.rst
branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/devel/images/DiagrammeClass.png
branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/devel/images/DiagrammeSequance.png
branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/devel/library.rst
branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/index.rst
branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/user/index.rst
branches/jrst-docutils-jython/jrst-doc/src/site/resources/schemas/diagrammeClass.png
branches/jrst-docutils-jython/jrst-doc/src/site/resources/schemas/diagrammeSequence.png
branches/jrst-docutils-jython/jrst-doc/src/site/rst/devel/docDeveloppeur.rst
branches/jrst-docutils-jython/jrst-doc/src/site/rst/devel/librairies.rst
branches/jrst-docutils-jython/jrst-doc/src/site/rst/index.rst
branches/jrst-docutils-jython/jrst-doc/src/site/rst/user/index.rst
Modified: branches/jrst-docutils-jython/doxia-module-jrst/src/main/java/org/nuiton/jrst/JrstParser.java
===================================================================
--- branches/jrst-docutils-jython/doxia-module-jrst/src/main/java/org/nuiton/jrst/JrstParser.java 2012-05-16 13:47:36 UTC (rev 667)
+++ branches/jrst-docutils-jython/doxia-module-jrst/src/main/java/org/nuiton/jrst/JrstParser.java 2012-05-21 07:17:23 UTC (rev 668)
@@ -49,6 +49,7 @@
* @plexus.component role="org.apache.maven.doxia.parser.Parser" role-hint="jrst"
*/
public class JrstParser extends XdocParser {
+ protected static Log log = LogFactory.getLog(JRST.class);
@Override
public void parse(Reader source, Sink sink) throws ParseException {
Modified: branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/devel/developerDoc.rst
===================================================================
--- branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/devel/developerDoc.rst 2012-05-16 13:47:36 UTC (rev 667)
+++ branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/devel/developerDoc.rst 2012-05-21 07:17:23 UTC (rev 668)
@@ -33,25 +33,11 @@
|classDiagramme|
-AdvencedReader Class is used to easily read RST_ file using specifics methods:
- - String readLine() : return a line.
- - String[] readLines(int nb) : return nb lines
- - String[] readWhile(Pattern p) : return lines while they match to the pattern
- ...
+La classe **JRST** contient la méthode main(), elle gère les options, la lecture et l'écriture des fichiers. Elle appelle dans un premier temps la classe **PythonInterpreter** de Jython_ permettant d'exécuter les scripts en Python de DocUtils_ pour générer un fichier XML intermédiaire. Ensuite, il ne reste qu'à appliquer le XSL désiré (si besoin) grâce à la classe **JRSTGenerator**.
-**JRSTLexer** Class uses **AdvencedReader** to build XML file, it browses all document to isolate the data types, parameters
-and content, so assembling all usefuls informations to build the final XML. It will start by document's head (peekHeader(),
-peekDocInfo()), and finally peeking on the body (peekBody()).
-**JRSTReader** Class uses **JRSTLexer**, it interprets the returned XML to build the final XML. This one is conform to the Docutils_
-DTD. This Class sometimes needs to be called itself when a document part must be interpreted independently of rest. For exemple,
-if a table contains a list, we extract the cell's informations for being interpreted. Admonition's content must be considered like an
-independant document. When generation is finished, Class **JRSTReader** build summary (composeContent()) and parse all the inline
-specificities (inline()), like, italic or bold words, links, footnotes... All that can appear inside a line.
+**JRST** Class contents main() method, it's looking after options, files reading and writing. Iinitially, it calls Jython_ class **PythonInterpreter** which allows to execute DocUtils' Python script to generate an intermediate file. Then it only remains to apply the wish XSL (if needed) by using **JRSTGenerator** Class.
-**JRST** Class contents main() method, it's looking after options, files reading and writing. It reads document, parses
-it with **JRSTReader** Class and transforms with the wish XSL (if needed) by using **JRSTGenerator** Class.
-
Generation
==========
@@ -154,6 +140,7 @@
.. _RST: http://docutils.sourceforge.net/rst.html
.. _Cascading Style Sheets: http://en.wikipedia.org/wiki/Cascading_Style_Sheets
.. _DocUtils: http://docutils.sourceforge.net/docs/ref/doctree.html
+.. _Jython: http://jython.org/index.html
.. |diagrammegeneration| image:: images/diagrammeGeneration.png
.. |classDiagramme| image:: images/DiagrammeClass.png
-.. |sequenceDiagramme| image:: images/DiagrammeSequence.png
\ No newline at end of file
+.. |sequenceDiagramme| image:: images/DiagrammeSequence.png
Modified: branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/devel/images/DiagrammeClass.png
===================================================================
(Binary files differ)
Modified: branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/devel/images/DiagrammeSequance.png
===================================================================
(Binary files differ)
Modified: branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/devel/library.rst
===================================================================
--- branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/devel/library.rst 2012-05-16 13:47:36 UTC (rev 667)
+++ branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/devel/library.rst 2012-05-21 07:17:23 UTC (rev 668)
@@ -49,7 +49,22 @@
Xmlunit_ used to compare two XML files to show their differences.
+DocUtils_
+=========
+
+DocUtils_ is a set of scripts to transform RST_ files into useful formats, such as HTML, ODT, Latex and more.
+
+Jython_
+=======
+
+Jython_ is a Python interpreter for Java. Here, it allows to execute DocUtils_ scripts.
+
+
+
.. _dom4j: http://www.dom4j.org
.. _javax.xml.transform: http://java.sun.com/javase/6/docs/api/javax/xml/transform/package-summary.h…
.. _SDoc: http://sdoc.sourceforge.net/wiki/pmwiki.php
.. _Xmlunit: http://xmlunit.sourceforge.net/
+.. _RST: http://docutils.sourceforge.net/rst.html
+.. _DocUtils: http://docutils.sourceforge.net/docs/ref/doctree.html
+.. _Jython: http://jython.org/index.html
Modified: branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/index.rst
===================================================================
--- branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/index.rst 2012-05-16 13:47:36 UTC (rev 667)
+++ branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/index.rst 2012-05-21 07:17:23 UTC (rev 668)
@@ -22,6 +22,7 @@
.. * <http://www.gnu.org/licenses/lgpl-3.0.html>.
.. * #L%
.. -
+
===============================
reStructuredText_ parser : JRst
===============================
@@ -41,14 +42,14 @@
documents, becomes useless when it is used to quickly creating a simple
document. RST has a so simple syntax that it becomes almost invisible.
-JRST is a Java ReStructuredText_ parser enabling to create a tree representation
+JRST uses Jython_ and DocUtils_ to transform RST_ files to XML to create a tree representation
document. It becomes easy to generate document representation towards differents
fomats.
How to use it
-------------
-JRST parser takes a reStructuredText_ file and generates XML file. Which could be used to produce
+JRST takes a reStructuredText_ file and generates XML file. Which could be used to produce
various files formats with generation XSL_ files. The available output formats are HTML, xhtml,
rst, pdf, docbook, odt(Open-Office), rtf, or XML [1]_.
@@ -92,8 +93,11 @@
.. [1] Only html, xhtml, DocBook_, xdoc and pdf are available for the moment.
-.. _reStructuredText: RSTpresentation.html
+.. _reStructuredText: ./user/RSTpresentation.html
+.. _RST: ./user/RSTpresentation.html
.. _Maven: http://maven.apache.org/
.. _XSL: ./devel/XSLpresentation.html
.. _DocBook: http://www.docbook.org/
.. _LaTex: http://www.latex-project.org/
+.. _DocUtils: http://docutils.sourceforge.net/docs/ref/doctree.html
+.. _Jython: http://jython.org/index.html
Modified: branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/user/index.rst
===================================================================
--- branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/user/index.rst 2012-05-16 13:47:36 UTC (rev 667)
+++ branches/jrst-docutils-jython/jrst-doc/src/site/en/rst/user/index.rst 2012-05-21 07:17:23 UTC (rev 668)
@@ -22,6 +22,7 @@
.. * <http://www.gnu.org/licenses/lgpl-3.0.html>.
.. * #L%
.. -
+
===============================
reStructuredText_ parser : JRst
===============================
@@ -41,14 +42,14 @@
documents, becomes useless when it is used to quickly creating a simple
document. RST has a so simple syntax that it becomes almost invisible.
-JRST is a Java ReStructuredText_ parser enabling to create a tree representation
+JRST uses Jython_ and DocUtils_ to transform RST_ files to XML to create a tree representation
document. It becomes easy to generate document representation towards differents
fomats.
How to use it
-------------
-JRST parser takes a reStructuredText_ file and generates XML file. Which could be used to produce
+JRST takes a reStructuredText_ file and generates XML file. Which could be used to produce
various files formats with generation XSL_ files. The available output formats are HTML, xhtml,
rst, pdf, docbook, odt(Open-Office), rtf, or XML [1]_.
@@ -92,8 +93,11 @@
.. [1] Only html, xhtml, DocBook_, xdoc and pdf are available for the moment.
-.. _reStructuredText: RSTpresentation.html
+.. _reStructuredText: ./user/RSTpresentation.html
+.. _RST: ./user/RSTpresentation.html
.. _Maven: http://maven.apache.org/
.. _XSL: http://jrst.labs.libre-entreprise.org/en/devel/XSLpresentation.rst
.. _DocBook: http://www.docbook.org/
.. _LaTex: http://www.latex-project.org/
+.. _DocUtils: http://docutils.sourceforge.net/docs/ref/doctree.html
+.. _Jython: http://jython.org/index.html
Modified: branches/jrst-docutils-jython/jrst-doc/src/site/resources/schemas/diagrammeClass.png
===================================================================
(Binary files differ)
Modified: branches/jrst-docutils-jython/jrst-doc/src/site/resources/schemas/diagrammeSequence.png
===================================================================
(Binary files differ)
Modified: branches/jrst-docutils-jython/jrst-doc/src/site/rst/devel/docDeveloppeur.rst
===================================================================
--- branches/jrst-docutils-jython/jrst-doc/src/site/rst/devel/docDeveloppeur.rst 2012-05-16 13:47:36 UTC (rev 667)
+++ branches/jrst-docutils-jython/jrst-doc/src/site/rst/devel/docDeveloppeur.rst 2012-05-21 07:17:23 UTC (rev 668)
@@ -22,6 +22,7 @@
.. * <http://www.gnu.org/licenses/lgpl-3.0.html>.
.. * #L%
.. -
+
=========================
Documentation développeur
=========================
@@ -35,20 +36,8 @@
:alt: Diagramme de classes
:align: center
-La Class **AdvancedReader** à pour fonction de faciliter la lecture du fichier RST_ grâce à différentes méthodes :
- - String readLine() : renvoie une ligne
- - String[] readLines(int nombresLigne) : renvoie un certain nombre de lignes
- - Stringn[] readWhile(Pattern p) : renvoie les lignes tant qu'elles correspondent au pattern
- ...
+La classe **JRST** contient la méthode main(), elle gère les options, la lecture et l'écriture des fichiers. Elle appelle dans un premier temps la classe **PythonInterpreter** de Jython_ permettant d'exécuter les scripts en Python de DocUtils_ pour générer un fichier XML intermédiaire. Ensuite, il ne reste qu'à appliquer le XSL désiré (si besoin) grâce à la classe **JRSTGenerator**.
-La Class **JRSTLexer** utilise **AdvancedReader** pour construire un fichier XML, il parcours l'ensemble du document pour isoler les types de données, leurs paramètres et leurs contenus, donc rassembler toutes les informations utiles à la mise en forme du XML final. Il va commencer par l'entête du document (peekHeader(), peekDocInfo()) pour ensuite s'intéresser au corps (peekBody()).
-
-La Class **JRSTReader** utilise **JRSTLexer**, il interprète le XML qui lui est renvoyé pour construire le XML final. Celui-ci est conforme à la DTD définie par DocUtils_. Cette Class à parfois besoin de s'appeler elle même lorsque une partie du document doit être interprétée indépendamment du reste. Par exemple, s'il y a une liste dans une case d'un tableau, l'on extrait les informations de la case et on les interprètes, le contenu d'une admoniton (une note) doit lui aussi être considéré comme un document indépendant. Lorsque la génération est terminée, la Class compose le sommaire (composeContent()) puis s'occupe de toutes les spécificités « inline » (inline()), comme par exemple les mots en italique ou gras, les références, les footnotes... Tout ce qui peut apparaître à l'intérieur d'une ligne.
-
-La Class **reStructuredText** référence toutes les variables nécessaires à la génération du XML final.
-
-La Class **JRST** contient la méthode main(), elle gère les options, la lecture et l'écriture des fichiers. Elle lit le document, le parse grâce à la class **JRSTReader** puis applique le XSL désiré (si besoin) grâce à la class **JRSTGenerator**.
-
La génération
=============
@@ -154,4 +143,5 @@
.. _Cascading Style Sheets: http://fr.wikipedia.org/wiki/Feuilles_de_style_en_cascade
.. _RST: http://docutils.sourceforge.net/rst.html
.. _DocUtils: http://docutils.sourceforge.net/docs/ref/doctree.html
+.. _Jython: http://jython.org/index.html
Modified: branches/jrst-docutils-jython/jrst-doc/src/site/rst/devel/librairies.rst
===================================================================
--- branches/jrst-docutils-jython/jrst-doc/src/site/rst/devel/librairies.rst 2012-05-16 13:47:36 UTC (rev 667)
+++ branches/jrst-docutils-jython/jrst-doc/src/site/rst/devel/librairies.rst 2012-05-21 07:17:23 UTC (rev 668)
@@ -22,6 +22,7 @@
.. * <http://www.gnu.org/licenses/lgpl-3.0.html>.
.. * #L%
.. -
+
====================================
Les différentes librairies utilisées
====================================
@@ -48,7 +49,20 @@
Xmlunit_ permet de comparer deux fichiers XML pour mettre en évidences les différences.
+DocUtils_
+=========
+
+DocUtils_ est un ensemble de scripts permettant de transformer des fichiers RST_ en formats plus répendus comme le HTML, ODT, Latex et bien plus encore.
+
+Jython_
+=======
+
+Jython_ est un interprète Python en Java. Ici, il permet d'exécuter les scripts de DocUtils_.
+
.. _dom4j: http://www.dom4j.org
.. _javax.xml.transform: http://java.sun.com/javase/6/docs/api/javax/xml/transform/package-summary.h…
.. _SDoc: http://sdoc.sourceforge.net/wiki/pmwiki.php
-.. _Xmlunit: http://xmlunit.sourceforge.net/
\ No newline at end of file
+.. _Xmlunit: http://xmlunit.sourceforge.net/
+.. _RST: http://docutils.sourceforge.net/rst.html
+.. _DocUtils: http://docutils.sourceforge.net/docs/ref/doctree.html
+.. _Jython: http://jython.org/index.html
Modified: branches/jrst-docutils-jython/jrst-doc/src/site/rst/index.rst
===================================================================
--- branches/jrst-docutils-jython/jrst-doc/src/site/rst/index.rst 2012-05-16 13:47:36 UTC (rev 667)
+++ branches/jrst-docutils-jython/jrst-doc/src/site/rst/index.rst 2012-05-21 07:17:23 UTC (rev 668)
@@ -22,6 +22,7 @@
.. * <http://www.gnu.org/licenses/lgpl-3.0.html>.
.. * #L%
.. -
+
===================================
Parseur reStructuredText_ : le JRst
===================================
@@ -42,15 +43,13 @@
de créer rapidement un document pas trop complexe. RST_ dispose quant à lui d'une
syntaxe tellement simple qu'elle en devient presque invisible.
-JRST est un parseur RST_ en Java permettant de créer une représentation en arbre
-d'un document. Il devient alors facile de générer une représentation du document
-vers différents formats.
+JRST utilise Jython_ et DocUtils_ pour transformer le RST_ en XML permettant de créer une représentation en arbre d'un document. Il devient alors facile de générer une représentation du document vers différents formats.
Usage
-----
-Le parser JRST prend un fichier reStructuredText_ en entré et génère un fichier XML
+JRST prend un fichier reStructuredText_ en entrée et génère un fichier XML
qui pourra ensuite servir à produire divers formats de fichiers grâce à des fichiers
XSL de générations. Les formats de sortie disponibles sont le html, le xhtml, le rst,
le pdf, le docbook_, le odt (Open-Office), le rtf, ou encore le XML [1]_.
@@ -98,8 +97,11 @@
.. [1] Seul les formats html, xhtml, DocBook_, xdoc et pdf sont disponible pour le moment.
-.. _reStructuredText: presentationRST.html
+.. _reStructuredText: ./user/presentationRST.html
+.. _RST: ./user/presentationRST.html
.. _Maven: http://maven.apache.org/
.. _XSL: ./devel/presentationXSL.html
.. _DocBook: http://www.docbook.org/
-.. _LaTex: http://www.latex-project.org/
\ No newline at end of file
+.. _LaTex: http://www.latex-project.org/
+.. _DocUtils: http://docutils.sourceforge.net/docs/ref/doctree.html
+.. _Jython: http://jython.org/index.html
Modified: branches/jrst-docutils-jython/jrst-doc/src/site/rst/user/index.rst
===================================================================
--- branches/jrst-docutils-jython/jrst-doc/src/site/rst/user/index.rst 2012-05-16 13:47:36 UTC (rev 667)
+++ branches/jrst-docutils-jython/jrst-doc/src/site/rst/user/index.rst 2012-05-21 07:17:23 UTC (rev 668)
@@ -22,6 +22,7 @@
.. * <http://www.gnu.org/licenses/lgpl-3.0.html>.
.. * #L%
.. -
+
===================================
Parseur reStructuredText_ : le JRst
===================================
@@ -42,15 +43,13 @@
de créer rapidement un document pas trop complexe. RST_ dispose quant à lui d'une
syntaxe tellement simple qu'elle en devient presque invisible.
-JRST est un parseur RST_ en Java permettant de créer une représentation en arbre
-d'un document. Il devient alors facile de générer une représentation du document
-vers différents formats.
+JRST utilise Jython_ et DocUtils_ pour transformer le RST_ en XML permettant de créer une représentation en arbre d'un document. Il devient alors facile de générer une représentation du document vers différents formats.
Usage
-----
-Le parser JRST prend un fichier reStructuredText_ en entré et génère un fichier XML
+JRST prend un fichier reStructuredText_ en entrée et génère un fichier XML
qui pourra ensuite servir à produire divers formats de fichiers grâce à des fichiers
XSL de générations. Les formats de sortie disponibles sont le html, le xhtml, le rst,
le pdf, le docbook_, le odt (Open-Office), le rtf, ou encore le XML [1]_.
@@ -98,8 +97,11 @@
.. [1] Seul les formats html, xhtml, DocBook_, xdoc et pdf sont disponible pour le moment.
-.. _reStructuredText: presentationRST.html
+.. _reStructuredText: ./user/presentationRST.html
+.. _RST: ./user/presentationRST.html
.. _Maven: http://maven.apache.org/
.. _XSL: http://jrst.labs.libre-entreprise.org/fr/devel/presentationXSL.rst
.. _DocBook: http://www.docbook.org/
-.. _LaTex: http://www.latex-project.org/
\ No newline at end of file
+.. _LaTex: http://www.latex-project.org/
+.. _DocUtils: http://docutils.sourceforge.net/docs/ref/doctree.html
+.. _Jython: http://jython.org/index.html
1
0
r667 - branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst
by jpages@users.nuiton.org 16 May '12
by jpages@users.nuiton.org 16 May '12
16 May '12
Author: jpages
Date: 2012-05-16 15:47:36 +0200 (Wed, 16 May 2012)
New Revision: 667
Url: http://nuiton.org/repositories/revision/jrst/667
Log:
Cr?\195?\169ation de nouvelles constantes pour certaines cha?\195?\174nes de carat?\195?\168res.
Modified:
branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java
Modified: branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java 2012-05-16 13:22:28 UTC (rev 666)
+++ branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java 2012-05-16 13:47:36 UTC (rev 667)
@@ -76,12 +76,18 @@
public static final String UTF_8 = "UTF-8";
- public static final String DOCUTILS_LAUNCHER = "/__run__.py";
+ public static final String DOCUTILS_LAUNCHER = "__run__.py";
public static final String IMPORT_SCRIPT = "import __run__";
public static final String WINDOWS_NAME = "win";
+ public static final String OS_NAME = "os.name";
+
+ public static final String BANG = "!";
+
+ public static final String FILE_PREFIX = "file:";
+
public enum Overwrite {
NEVER, IFNEWER, ALLTIME
}
@@ -455,11 +461,11 @@
and it will become :
/home/user/.m2/repository/org/nuiton/jrst/docutils/1.6-SNAPSHOT/docutils-1.6-SNAPSHOT.jar/
*/
- URL resource = JRST.class.getResource(DOCUTILS_LAUNCHER);
+ URL resource = JRST.class.getResource("/" + DOCUTILS_LAUNCHER);
String docutilsPath = resource.getPath()
- .replaceAll("__run__.py", "");
- docutilsPath = docutilsPath.replaceAll("!", "");
- docutilsPath = docutilsPath.replaceAll("file:", "");
+ .replaceAll(DOCUTILS_LAUNCHER, "");
+ docutilsPath = docutilsPath.replaceAll(BANG, "");
+ docutilsPath = docutilsPath.replaceAll(FILE_PREFIX, "");
// Import of the main script to use docutils ( __run__ )
PythonInterpreter interp = new PythonInterpreter();
@@ -468,17 +474,17 @@
// If the OS is windows, escapes the backslashs in the filepath
String filePath = in.getAbsolutePath();
- String property = System.getProperty("os.name").toLowerCase();
+ String property = System.getProperty(OS_NAME).toLowerCase();
if (property.contains(WINDOWS_NAME)) {
filePath = filePath.replaceAll("\\\\", "\\\\\\\\");
}
+ // Sets an output stream in the python interpreter and executes the code
+ interp.setOut(out);
+
// Execution of the docutils script to transform rst to xml
String commandExec = String.format("__run__.exec_docutils('%s', '%s', '%s')",
docutilsPath, outputType, filePath);
-
- // Sets an output stream in the python interpreter and executes the code
- interp.setOut(out);
interp.exec(commandExec);
// Cleans the python interpreter to avoid problems if they are multiple execution of this method
@@ -490,7 +496,7 @@
try {
doc = DocumentHelper.parseText(xmlString);
} catch (DocumentException e) {
- log.error("Erreur lors de la lecture du xml", e);
+ log.error("Error during the creation of the document", e);
}
return doc;
1
0
r666 - branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst
by jpages@users.nuiton.org 16 May '12
by jpages@users.nuiton.org 16 May '12
16 May '12
Author: jpages
Date: 2012-05-16 15:22:28 +0200 (Wed, 16 May 2012)
New Revision: 666
Url: http://nuiton.org/repositories/revision/jrst/666
Log:
Pr?\195?\169cision sur l'encodage en UTF-8 pour la conversion en string ?\195?\160 partir du ByteArrayOutputStream.
Modified:
branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java
Modified: branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java 2012-05-16 12:57:18 UTC (rev 665)
+++ branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java 2012-05-16 13:22:28 UTC (rev 666)
@@ -484,7 +484,7 @@
// Cleans the python interpreter to avoid problems if they are multiple execution of this method
interp.cleanup();
- String xmlString = new String(out.toByteArray());
+ String xmlString = new String(out.toByteArray(), UTF_8);
Document doc = null;
try {
1
0
r665 - in branches/jrst-docutils-jython/jrst/src: main/java/org/nuiton/jrst test/java/org/nuiton/jrst/bugs test/resources/bugs
by jpages@users.nuiton.org 16 May '12
by jpages@users.nuiton.org 16 May '12
16 May '12
Author: jpages
Date: 2012-05-16 14:57:18 +0200 (Wed, 16 May 2012)
New Revision: 665
Url: http://nuiton.org/repositories/revision/jrst/665
Log:
Remplacement dans JRST de FileImputStream par ByteArrayOutputStream pour la g?\195?\169n?\195?\169ration du xml.
Modified:
branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java
branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TitlesTest.java
branches/jrst-docutils-jython/jrst/src/test/resources/bugs/testNoContentSubtitles.rst
Modified: branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java 2012-05-16 09:23:38 UTC (rev 664)
+++ branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java 2012-05-16 12:57:18 UTC (rev 665)
@@ -46,7 +46,8 @@
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;
import org.dom4j.Document;
-import org.dom4j.io.SAXReader;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
import org.nuiton.i18n.I18n;
import org.nuiton.i18n.init.ClassPathI18nInitializer;
import org.nuiton.jrst.convertisor.DocUtils2RST;
@@ -56,6 +57,8 @@
import org.nuiton.util.Resource;
import org.nuiton.util.StringUtil;
import org.python.util.PythonInterpreter;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
/**
* FIXME: 'JRST --help' doesn't work, but 'JRST --help toto' work :( FIXME:
@@ -73,6 +76,12 @@
public static final String UTF_8 = "UTF-8";
+ public static final String DOCUTILS_LAUNCHER = "/__run__.py";
+
+ public static final String IMPORT_SCRIPT = "import __run__";
+
+ public static final String WINDOWS_NAME = "win";
+
public enum Overwrite {
NEVER, IFNEWER, ALLTIME
}
@@ -422,27 +431,31 @@
}
public static Document generateXML(File in) throws Exception {
- // RST to XML transformation via Docutils and a temporary file
- File out = File.createTempFile("result", ".xml");
- out = generateDocument(TYPE_XML, in, out);
+ // RST to XML transformation in a StringWriter
+ ByteArrayOutputStream out = null;
+ Document doc = null;
- SAXReader saxReader = new SAXReader();
- saxReader.setEncoding(UTF_8);
- return saxReader.read(out);
+ try {
+ out = new ByteArrayOutputStream();
+ doc = generateDocument(TYPE_XML, in, out);
+ } finally {
+ if ( out != null) {
+ out.close();
+ }
+ }
+
+ return doc;
}
- public static File generateDocument(String outputType, File in, File out) throws Exception {
- // Name of the main Python script
- final String runner = "__run__";
-
+ public static Document generateDocument(String outputType, File in, ByteArrayOutputStream out) throws Exception {
/* Transformation of the __run__ URL into a path that python will use
For example the URL is :
jar:file:/home/user/.m2/repository/org/nuiton/jrst/docutils/1.6-SNAPSHOT/docutils-1.6-SNAPSHOT.jar!/__run__.py
and it will become :
/home/user/.m2/repository/org/nuiton/jrst/docutils/1.6-SNAPSHOT/docutils-1.6-SNAPSHOT.jar/
*/
- URL resource = JRST.class.getResource("/__run__.py");
+ URL resource = JRST.class.getResource(DOCUTILS_LAUNCHER);
String docutilsPath = resource.getPath()
.replaceAll("__run__.py", "");
docutilsPath = docutilsPath.replaceAll("!", "");
@@ -450,35 +463,37 @@
// Import of the main script to use docutils ( __run__ )
PythonInterpreter interp = new PythonInterpreter();
- String commandImport = "import __run__";
+ String commandImport = IMPORT_SCRIPT;
interp.exec(commandImport);
// If the OS is windows, escapes the backslashs in the filepath
String filePath = in.getAbsolutePath();
String property = System.getProperty("os.name").toLowerCase();
- if (property.contains("win")) {
+ if (property.contains(WINDOWS_NAME)) {
filePath = filePath.replaceAll("\\\\", "\\\\\\\\");
}
// Execution of the docutils script to transform rst to xml
String commandExec = String.format("__run__.exec_docutils('%s', '%s', '%s')",
docutilsPath, outputType, filePath);
- FileOutputStream fileOutputStream = null;
+
+ // Sets an output stream in the python interpreter and executes the code
+ interp.setOut(out);
+ interp.exec(commandExec);
+
+ // Cleans the python interpreter to avoid problems if they are multiple execution of this method
+ interp.cleanup();
+
+ String xmlString = new String(out.toByteArray());
+
+ Document doc = null;
try {
- // Sets an output stream to build the output file
- fileOutputStream = new FileOutputStream(out);
- interp.setOut(fileOutputStream);
- interp.exec(commandExec);
-
- // Cleans the python interpreter to avoid problems if they are multiple execution of this method
- interp.cleanup();
- } finally {
- if (fileOutputStream != null) {
- fileOutputStream.close();
- }
+ doc = DocumentHelper.parseText(xmlString);
+ } catch (DocumentException e) {
+ log.error("Erreur lors de la lecture du xml", e);
}
- return out;
+ return doc;
}
Modified: branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TitlesTest.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TitlesTest.java 2012-05-16 09:23:38 UTC (rev 664)
+++ branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TitlesTest.java 2012-05-16 12:57:18 UTC (rev 665)
@@ -8,16 +8,16 @@
* Copyright (C) 2011 Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
+ *
+ * You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
@@ -35,10 +35,10 @@
/**
* Test concernant les titres en général.
- *
+ *
* @author chatellier
* @version $Revision$
- *
+ *
* Last update : $Date$
* By : $Author$
*/
Modified: branches/jrst-docutils-jython/jrst/src/test/resources/bugs/testNoContentSubtitles.rst
===================================================================
--- branches/jrst-docutils-jython/jrst/src/test/resources/bugs/testNoContentSubtitles.rst 2012-05-16 09:23:38 UTC (rev 664)
+++ branches/jrst-docutils-jython/jrst/src/test/resources/bugs/testNoContentSubtitles.rst 2012-05-16 12:57:18 UTC (rev 665)
@@ -22,6 +22,7 @@
.. * <http://www.gnu.org/licenses/lgpl-3.0.html>.
.. * #L%
.. -
+
Lancement
=========
1
0
r664 - in branches/jrst-docutils-jython/jrst/src: main/java/org/nuiton/jrst test/java/org/nuiton/jrst test/java/org/nuiton/jrst/bugs
by jpages@users.nuiton.org 16 May '12
by jpages@users.nuiton.org 16 May '12
16 May '12
Author: jpages
Date: 2012-05-16 11:23:38 +0200 (Wed, 16 May 2012)
New Revision: 664
Url: http://nuiton.org/repositories/revision/jrst/664
Log:
Nettoyage du code (commentaires inutiles, etc...)
Modified:
branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java
branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/JRSTTest.java
branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/AdmonitionTest.java
Modified: branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java 2012-05-16 09:05:50 UTC (rev 663)
+++ branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java 2012-05-16 09:23:38 UTC (rev 664)
@@ -109,7 +109,7 @@
/** XSL Stylesheet to transform Docbook into PDF. */
protected static final String docbook2fo = "/docbook/fo/docbook.xsl";
- public static final String PATTERN_TYPE = "xml|xhtml|docbook|html|htmlInnerBody|xdoc|fo|pdf|odt|rtf|latex|s5|xetex";
+ public static final String PATTERN_TYPE = "xml|xhtml|docbook|html|htmlInnerBody|xdoc|rst|fo|pdf|odt|rtf";
/** HTML output format type */
public static final String TYPE_HTML = "html";
@@ -405,7 +405,6 @@
if (file.exists()) {
stylesheet = file.toURI().toURL();
} else {
- //stylesheet = JRST.class.getResource(xsl);
stylesheet = Resource.getURL(xsl);
}
if (stylesheet == null) {
@@ -437,8 +436,6 @@
// Name of the main Python script
final String runner = "__run__";
- //log.info(out);
-
/* Transformation of the __run__ URL into a path that python will use
For example the URL is :
jar:file:/home/user/.m2/repository/org/nuiton/jrst/docutils/1.6-SNAPSHOT/docutils-1.6-SNAPSHOT.jar!/__run__.py
Modified: branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/JRSTTest.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/JRSTTest.java 2012-05-16 09:05:50 UTC (rev 663)
+++ branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/JRSTTest.java 2012-05-16 09:23:38 UTC (rev 664)
@@ -135,64 +135,4 @@
JRST.generate(JRST.TYPE_XML, in, out, JRST.Overwrite.ALLTIME);
}
-
- /*
- @Test
- public void generateHtml() throws Exception {
-
- File in = getTestFile("text.rst");
- File out = getOutputTestFile("jrst-RstToHtml2.html");
-
- JRST.generate(JRST.Docutils_Formats.HTML.name(), in, out, JRST.Overwrite.ALLTIME);
- }
-
- @Test
- public void generateOdt() throws Exception {
-
- File in = getTestFile("text.rst");
- File out = getOutputTestFile("jrst-RstToOdt.odt");
-
- JRST.generate(JRST.Docutils_Formats.ODT.name(), in, out, JRST.Overwrite.ALLTIME);
- }
- */
-
- /* Does not work for 'text.rst', cause this message with rst2latex :
- "Cells that span multiple rows *and* columns are not supported"
- @Test
- public void generateLatex() throws Exception {
-
- File in = getTestFile("test4.rst");
- File out = getOutputTestFile("jrst-RstToLatex.tex");
-
- JRST.generate(JRST.Docutils_Formats.LATEX.name(), in, out, JRST.Overwrite.ALLTIME);
- } */
-
- /* Does not work for 'text.rst', the header causes an 'NotImplementedError'
- @Test
- public void generateMan() throws Exception {
-
- File in = getTestFile("test4.rst");
- File out = getOutputTestFile("jrst-RstToMan.man");
-
- JRST.generate(JRST.Docutils_Formats.MAN.name(), in, out, JRST.Overwrite.ALLTIME);
- } */
- /*
- @Test
- public void generateS5() throws Exception {
-
- File in = getTestFile("text.rst");
- File out = getOutputTestFile("jrst-RstToS5.s5");
-
- JRST.generate(JRST.Docutils_Formats.S5.name(), in, out, JRST.Overwrite.ALLTIME);
- }
-
- @Test
- public void generatePDF() throws Exception {
-
- File in = getTestFile("text.rst");
-
- File out = getOutputTestFile("jrst-RstToPDF.pdf");
-
- JRST.generate(JRST.TYPE_PDF, in, out, JRST.Overwrite.ALLTIME);
- } */
}
\ No newline at end of file
Modified: branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/AdmonitionTest.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/AdmonitionTest.java 2012-05-16 09:05:50 UTC (rev 663)
+++ branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/AdmonitionTest.java 2012-05-16 09:23:38 UTC (rev 664)
@@ -55,9 +55,6 @@
public void testAdmonitionInList() throws Exception {
File in = getBugTestFile("testAdminitionInList1787.rst");
File out = getOutputTestFile("jrst-testAdminitionInList1787.html");
-
-// log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " + in.getPath());
-// log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " + out.getPath());
// out.deleteOnExit();
JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME);
1
0
r663 - in branches/jrst-docutils-jython/jrst/src: main/java/org/nuiton/jrst test/java/org/nuiton/jrst/bugs
by jpages@users.nuiton.org 16 May '12
by jpages@users.nuiton.org 16 May '12
16 May '12
Author: jpages
Date: 2012-05-16 11:05:50 +0200 (Wed, 16 May 2012)
New Revision: 663
Url: http://nuiton.org/repositories/revision/jrst/663
Log:
Utilisation d'une constante pour l'encodage
Modified:
branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java
branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/AdmonitionTest.java
branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/DirectiveTest.java
branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TableTest.java
branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TextTest.java
branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TitlesTest.java
Modified: branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java 2012-05-16 08:52:25 UTC (rev 662)
+++ branches/jrst-docutils-jython/jrst/src/main/java/org/nuiton/jrst/JRST.java 2012-05-16 09:05:50 UTC (rev 663)
@@ -428,7 +428,7 @@
out = generateDocument(TYPE_XML, in, out);
SAXReader saxReader = new SAXReader();
- saxReader.setEncoding("UTF-8");
+ saxReader.setEncoding(UTF_8);
return saxReader.read(out);
}
Modified: branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/AdmonitionTest.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/AdmonitionTest.java 2012-05-16 08:52:25 UTC (rev 662)
+++ branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/AdmonitionTest.java 2012-05-16 09:05:50 UTC (rev 663)
@@ -61,7 +61,7 @@
// out.deleteOnExit();
JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME);
- String content = FileUtils.readFileToString(out, "UTF-8");
+ String content = FileUtils.readFileToString(out, JRST.UTF_8);
// Must contains <div class="note">
assertTrue(content.contains("<div class=\"note\">"));
}
Modified: branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/DirectiveTest.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/DirectiveTest.java 2012-05-16 08:52:25 UTC (rev 662)
+++ branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/DirectiveTest.java 2012-05-16 09:05:50 UTC (rev 663)
@@ -56,7 +56,7 @@
// out.deleteOnExit();
JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME);
- String content = FileUtils.readFileToString(out, "UTF-8");
+ String content = FileUtils.readFileToString(out, JRST.UTF_8);
assertTrue(content.indexOf("alt=\"alternate text\"") > 0);
assertTrue(content.indexOf("width=\"200px\"") > 0);
assertTrue(content.indexOf("align=\"center\"") > 0);
@@ -78,7 +78,7 @@
// out.deleteOnExit();
JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME);
- String content = FileUtils.readFileToString(out, "UTF-8");
+ String content = FileUtils.readFileToString(out, JRST.UTF_8);
assertTrue(content.indexOf("Table des matières") > 0);
}
@@ -94,7 +94,7 @@
// out.deleteOnExit();
JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME);
- String content = FileUtils.readFileToString(out, "UTF-8");
+ String content = FileUtils.readFileToString(out, JRST.UTF_8);
assertTrue(content.indexOf("<b>") > 0);
assertTrue(content.indexOf("<em>") > 0);
}
Modified: branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TableTest.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TableTest.java 2012-05-16 08:52:25 UTC (rev 662)
+++ branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TableTest.java 2012-05-16 09:05:50 UTC (rev 663)
@@ -56,7 +56,7 @@
// out.deleteOnExit();
JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME);
- String content = FileUtils.readFileToString(out, "UTF-8");
+ String content = FileUtils.readFileToString(out, JRST.UTF_8);
assertTrue(content.indexOf("Annee|Trait|Espece") > 0);
assertTrue(content.indexOf("<p>Fatal</p>") > 0);
}
@@ -73,7 +73,7 @@
// out.deleteOnExit();
JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME);
- String content = FileUtils.readFileToString(out, "UTF-8");
+ String content = FileUtils.readFileToString(out, JRST.UTF_8);
assertTrue(content.indexOf("<em>légérs</em>") > 0);
}
}
Modified: branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TextTest.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TextTest.java 2012-05-16 08:52:25 UTC (rev 662)
+++ branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TextTest.java 2012-05-16 09:05:50 UTC (rev 663)
@@ -58,7 +58,7 @@
JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME);
- String content = FileUtils.readFileToString(out, "UTF-8");
+ String content = FileUtils.readFileToString(out, JRST.UTF_8);
assertTrue(content.indexOf("href=\"http://labs.libre-entreprise.org/tracker/?atid=113&group_id=8&func=…"") > 0);
assertTrue(content.indexOf("href=\"http://www.docbook.org/\"") > 0);
assertTrue(content.indexOf("href=\"http://www.docbook2.org/\"") > 0);
@@ -77,7 +77,7 @@
JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME);
- String content = FileUtils.readFileToString(out, "UTF-8");
+ String content = FileUtils.readFileToString(out, JRST.UTF_8);
assertTrue(content.indexOf("nuiton's forge") > 0);
assertTrue(content.indexOf("build.xml") > 0);
}
@@ -95,7 +95,7 @@
JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME);
- String content = FileUtils.readFileToString(out, "UTF-8");
+ String content = FileUtils.readFileToString(out, JRST.UTF_8);
Pattern pattern = Pattern.compile(".*<blockquote>.*du bla bla \u00E9l\u00E9mentaire.*</blockquote>.*", Pattern.DOTALL);
Matcher matcher = pattern.matcher(content);
assertTrue(matcher.find());
@@ -112,7 +112,7 @@
JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME);
- String content = FileUtils.readFileToString(out, "UTF-8");
+ String content = FileUtils.readFileToString(out, JRST.UTF_8);
assertTrue(content.indexOf("<span class=\"option\">-a</span>") > 0);
assertTrue(content.indexOf("<p>options can have arguments\nand long descriptions</p>") > 0);
assertTrue(content.indexOf("<v3region.zip|v2region.xml|v2region.xml.gz>") > 0);
@@ -135,7 +135,7 @@
JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME);
- String content = FileUtils.readFileToString(out, "UTF-8");
+ String content = FileUtils.readFileToString(out, JRST.UTF_8);
assertTrue(content.indexOf("echapement de lien1_") > 0);
assertTrue(content.indexOf("echapement de *.txt") > 0);
}
@@ -150,7 +150,7 @@
JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME);
- String content = FileUtils.readFileToString(out, "UTF-8");
+ String content = FileUtils.readFileToString(out, JRST.UTF_8);
assertTrue(content.contains("href=\"http://www.python.org\""));
assertTrue(content.contains("href=\"./python\""));
assertTrue(content.contains("href=\"http://www.rfc-editor.org/rfc/rfc2396.txt\""));
Modified: branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TitlesTest.java
===================================================================
--- branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TitlesTest.java 2012-05-16 08:52:25 UTC (rev 662)
+++ branches/jrst-docutils-jython/jrst/src/test/java/org/nuiton/jrst/bugs/TitlesTest.java 2012-05-16 09:05:50 UTC (rev 663)
@@ -70,7 +70,7 @@
// out.deleteOnExit();
JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME);
- String content = FileUtils.readFileToString(out, "UTF-8");
+ String content = FileUtils.readFileToString(out, JRST.UTF_8);
Assert.assertTrue(content.indexOf("<h2>Prérequis</h2>") > 0);
}
}
1
0