Skip to content

Commit

Permalink
[DOXIA-671] Double quotes contained in markdown page are removed in H…
Browse files Browse the repository at this point in the history
…TML 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
  • Loading branch information
michael-o authored and hboutemy committed Dec 29, 2022
1 parent ceb7729 commit 5192294
Showing 1 changed file with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -128,7 +141,9 @@ public void parse( Reader source, Sink sink, String reference )
// 2 second parsing to process
try
{
XmlPullParser parser = new MXParser();
XmlPullParser parser = addDefaultEntities
? new MXParser( EntityReplacementMap.defaultEntityReplacementMap )
: new MXParser();

parser.setInput( src );

Expand Down Expand Up @@ -578,6 +593,23 @@ public void setValidate( boolean validate )
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
// ----------------------------------------------------------------------
Expand Down

0 comments on commit 5192294

Please sign in to comment.