You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2022/12/29 11:06:22 UTC

[maven-doxia] 03/03: [DOXIA-671] Double quotes contained in markdown page are removed in HTML output

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch doxia-1.x
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git

commit 51922943b765a36887461b9290306f9708188b13
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Sun Oct 2 00:18:38 2022 +0200

    [DOXIA-671] Double quotes contained in markdown page are removed in HTML output
    
    Ideally, one would use this list in the future:
      https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references
    
    This closes #123
---
 .../maven/doxia/parser/AbstractXmlParser.java      | 34 +++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
index c0b1ddb1..f67e3ca6 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
@@ -53,6 +53,7 @@ import org.apache.maven.doxia.util.XmlValidator;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.pull.EntityReplacementMap;
 import org.codehaus.plexus.util.xml.pull.MXParser;
 import org.codehaus.plexus.util.xml.pull.XmlPullParser;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
@@ -99,6 +100,18 @@ public abstract class AbstractXmlParser
 
     private boolean validate = false;
 
+    /**
+     * If set the parser will be loaded with all single characters
+     * from the XHTML specification.
+     * The entities used:
+     * <ul>
+     * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent</li>
+     * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent</li>
+     * <li>http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent</li>
+     * </ul>
+     */
+    private boolean addDefaultEntities = true;
+
     /** {@inheritDoc} */
     public void parse( Reader source, Sink sink, String reference )
         throws ParseException
@@ -128,7 +141,9 @@ public abstract class AbstractXmlParser
         // 2 second parsing to process
         try
         {
-            XmlPullParser parser = new MXParser();
+            XmlPullParser parser = addDefaultEntities
+                                   ? new MXParser( EntityReplacementMap.defaultEntityReplacementMap )
+                                   : new MXParser();
 
             parser.setInput( src );
             
@@ -578,6 +593,23 @@ public abstract class AbstractXmlParser
         this.validate = validate;
     }
 
+    /**
+     * @since 2.0.0-M4
+     */
+    public boolean getAddDefaultEntities()
+    {
+        return addDefaultEntities;
+    }
+
+    /**
+     * @since 2.0.0-M4
+     */
+    public void setAddDefaultEntities( boolean addDefaultEntities )
+    {
+        this.addDefaultEntities = addDefaultEntities;
+    }
+
+
     // ----------------------------------------------------------------------
     // Private methods
     // ----------------------------------------------------------------------