Author: echatellier Date: 2011-03-01 17:19:20 +0100 (Tue, 01 Mar 2011) New Revision: 546 Url: http://nuiton.org/repositories/revision/jrst/546 Log: Apply Arnaud LIAGRE's patch for #675 Added: trunk/jrst/src/test/java/org/nuiton/jrst/bugs/TextTest.java trunk/jrst/src/test/resources/bugs/testLinks.rst Modified: trunk/jrst/src/main/java/org/nuiton/jrst/JRSTReader.java trunk/jrst/src/main/java/org/nuiton/jrst/ReStructuredText.java Modified: trunk/jrst/src/main/java/org/nuiton/jrst/JRSTReader.java =================================================================== --- trunk/jrst/src/main/java/org/nuiton/jrst/JRSTReader.java 2011-02-28 09:52:05 UTC (rev 545) +++ trunk/jrst/src/main/java/org/nuiton/jrst/JRSTReader.java 2011-03-01 16:19:20 UTC (rev 546) @@ -2092,8 +2092,8 @@ int start = matcher.start(); int end = matcher.end(); Element ref = DocumentHelper.createElement(REFERENCE); - ref.addAttribute("refuri", matcher.group(2)); - ref.setText(matcher.group(1)); + ref.addAttribute("refuri", StringEscapeUtils.unescapeXml(matcher.group(2))); + ref.setText(StringEscapeUtils.unescapeXml(matcher.group(1))); String key = "inlineReference" + index++; temporaries.put(key, ref.asXML()); text = text.substring(0, start) + "<tmp>" + key + "</tmp>" Modified: trunk/jrst/src/main/java/org/nuiton/jrst/ReStructuredText.java =================================================================== --- trunk/jrst/src/main/java/org/nuiton/jrst/ReStructuredText.java 2011-02-28 09:52:05 UTC (rev 545) +++ trunk/jrst/src/main/java/org/nuiton/jrst/ReStructuredText.java 2011-03-01 16:19:20 UTC (rev 546) @@ -205,7 +205,7 @@ public static final Pattern REGEX_REFERENCE = Pattern .compile("(https?://[-/%#[\\&&&[^(>)]]\\._\\w:]+\\w+)((\\W|&|$)+)"); public static final Pattern REGEX_INLINE_REFERENCE = Pattern - .compile("`(.+) \\<\\;(https?://[-/%#&\\._\\w:]+)(\\>\\;)`_"); + .compile("`(.+?) \\<\\;(https?://[-/%#&\\._\\w:[^ ]]+)(\\>\\;)`_"); public static final Pattern REGEX_EMAIL = Pattern .compile("(^|[^_\\w])([-\\._\\w]+@[-\\._\\w]+)([^-\\._\\w]|$)"); public static final Pattern REGEX_FOOTNOTE_REFERENCE = Pattern Added: trunk/jrst/src/test/java/org/nuiton/jrst/bugs/TextTest.java =================================================================== --- trunk/jrst/src/test/java/org/nuiton/jrst/bugs/TextTest.java (rev 0) +++ trunk/jrst/src/test/java/org/nuiton/jrst/bugs/TextTest.java 2011-03-01 16:19:20 UTC (rev 546) @@ -0,0 +1,65 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * 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 + * 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% + */ + +package org.nuiton.jrst.bugs; + +import java.io.File; + +import junit.framework.Assert; + +import org.apache.commons.io.FileUtils; +import org.junit.Test; +import org.nuiton.jrst.JRST; + +/** + * Test sur les elements de type text (liens, styles...) + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class TextTest { + + /** + * Test que les liens avec parametres sont correctement parsés. + * + * @throws Exception + */ + @Test + public void testLinksParameters() throws Exception { + File in = new File("src/test/resources/bugs/testLinks.rst"); + File out = File.createTempFile("jrst-RstToHtml2", ".html"); + out.deleteOnExit(); + JRST.generate(JRST.TYPE_HTML, in, out, JRST.Overwrite.ALLTIME); + + String content = FileUtils.readFileToString(out); + System.out.println(content); + Assert.assertTrue(content.indexOf("href=\"http://labs.libre-entreprise.org/tracker/?atid=113&group_id=8&func=browse\"") > 0); + Assert.assertTrue(content.indexOf("href=\"http://www.docbook.org/\"") > 0); + Assert.assertTrue(content.indexOf("href=\"http://www.docbook2.org/\"") > 0); + } +} Property changes on: trunk/jrst/src/test/java/org/nuiton/jrst/bugs/TextTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/jrst/src/test/resources/bugs/testLinks.rst =================================================================== --- trunk/jrst/src/test/resources/bugs/testLinks.rst (rev 0) +++ trunk/jrst/src/test/resources/bugs/testLinks.rst 2011-03-01 16:19:20 UTC (rev 546) @@ -0,0 +1,11 @@ +Test html links +=============== + + * `Report de bugs <http://labs.libre-entreprise.org/tracker/?atid=113&group_id=8&func=browse>`_ + : Il sert à la notification d'un problème lors de l'utilisation d'ISIS-Fish. + * `Demande d'amélioration <http://labs.libre-entreprise.org/tracker/?atid=116&group_id=8&func=browse>`_ + : Il sert à ajouter des idées d'amélioration ISIS-Fish. + * `Report de problèmes de traduction <http://labs.libre-entreprise.org/tracker/?atid=438&group_id=8&func=browse>`_ + : Il sert pour reporter les erreurs de traduction. + +`DocBook <http://www.docbook.org/>`_ bla bla `DocBook2 <http://www.docbook2.org/>`_