Skip to content

Commit

Permalink
method=(tagsoup|nu) for HTML parser selection, remove TagSoup options…
Browse files Browse the repository at this point in the history
… html and method (#2367)
  • Loading branch information
GuntherRademacher authored Jan 29, 2025
1 parent 4d9f8d8 commit bdc691b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
* @author Christian Gruen
*/
public final class HtmlOptions extends Options {
/** TagSoup option: html. */
public static final BooleanOption HTML = new BooleanOption("html", false);
/** TagSoup option: omit-xml-declaration. */
public static final BooleanOption OMIT_XML_DECLARATION =
new BooleanOption("omit-xml-declaration", false);
Expand Down
13 changes: 2 additions & 11 deletions basex-core/src/main/java/org/basex/build/html/HtmlParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,8 @@ private static IO toXml(final IO io, final Parser parser, final HtmlOptions hopt

/** Method option values. */
public enum Method {
/** TagSoup parser with method 'xml'. */
xml(Parser.TAGSOUP),
/** TagSoup parser with method 'html'. */
html(Parser.TAGSOUP),
/** TagSoup parser. */
tagsoup(Parser.TAGSOUP),
/** Validator.nu parser. */
nu(Parser.NU);

Expand Down Expand Up @@ -141,11 +139,6 @@ XMLReader reader(final HtmlOptions hopts, final StringWriter sw) throws SAXExcep
reader.setContentHandler(writer);

// set TagSoup options
if(hopts.get(HTML)) {
reader.setFeature("http://xml.org/sax/features/namespaces", false);
writer.setOutputProperty(METHOD.name(), "html");
writer.setOutputProperty(OMIT_XML_DECLARATION.name(), "yes");
}
if(hopts.get(NONS))
reader.setFeature("http://xml.org/sax/features/namespaces", false);
if(hopts.get(NOBOGONS))
Expand All @@ -170,8 +163,6 @@ XMLReader reader(final HtmlOptions hopts, final StringWriter sw) throws SAXExcep
reader.setProperty("http://xml.org/sax/properties/lexical-handler", writer);
if(hopts.get(OMIT_XML_DECLARATION))
writer.setOutputProperty(OMIT_XML_DECLARATION.name(), "yes");
if(hopts.contains(METHOD))
writer.setOutputProperty(METHOD.name(), hopts.get(METHOD).name());
if(hopts.contains(DOCTYPE_SYSTEM))
writer.setOutputProperty(DOCTYPE_SYSTEM.name(), hopts.get(DOCTYPE_SYSTEM));
if(hopts.contains(DOCTYPE_PUBLIC))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1915,6 +1915,7 @@ public final class FnModuleTest extends SandboxTest {
+ "<body>\u20AC</body></html>");
query(func.args("42", " map {'heuristics': 'ICU'}"),
"<html xmlns=\"http://www.w3.org/1999/xhtml\"><head/><body>42</body></html>");
query(func.args("42", " {'method': 'tagsoup'}"), "<html><body>42</body></html>");

error(func.args(42), STRBIN_X_X);
error(func.args("42", 42), INVCONVERT_X_X_X);
Expand Down

0 comments on commit bdc691b

Please sign in to comment.