Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

SG optional (failing) [0.607572]

  • Loading branch information...
commit 01ba68f81cc0a341d6ca6a6e1ad059369aed4769 1 parent 494c533
Kyle Maxwell authored
View
5 Makefile.am
@@ -29,7 +29,6 @@ bench:
@echo "craigs..."; ./parsley test/craigs.let test/craigs.html > /dev/null
check-am:
- @echo "collate_regression..."; ./parsley test/collate_regression.let test/collate_regression.html 2>&1 | diff test/collate_regression.json - && echo " success."
@echo "sg_off..."; ./parsley test/sg_off.let test/sg_off.html 2>&1 | diff test/sg_off.json - && echo " success."
@echo "nth-regression..."; ./parsley test/nth-regression.let test/nth-regression.html 2>&1 | diff test/nth-regression.json - && echo " success."
@echo "array-regression..."; ./parsley test/array-regression.let test/array-regression.html 2>&1 | diff test/array-regression.json - && echo " success."
@@ -63,4 +62,6 @@ check-am:
@echo "reddit..."; ./parsley test/reddit.let test/reddit.html 2>&1 | diff test/reddit.json - && echo " success."
@echo "div..."; ./parsley test/div.let test/div.html 2>&1 | diff test/div.json - && echo " success."
@echo "default-namespace..."; ./parsley -x test/default-namespace.let test/default-namespace.xml 2>&1 | diff test/default-namespace.json - && echo " success."
- @echo "sg-wrap..."; ./parsley test/sg-wrap.let test/sg-wrap.html 2>&1 | diff test/sg-wrap.json - && echo " success."
+ @echo "sg-wrap..."; ./parsley -s test/sg-wrap.let test/sg-wrap.html 2>&1 | diff test/sg-wrap.json - && echo " success."
+ @echo "collate_regression..."; ./parsley test/collate_regression.let test/collate_regression.html 2>&1 | diff test/collate_regression.json - && echo " success."
+
View
4 Makefile.in
@@ -729,7 +729,6 @@ bench:
@echo "craigs..."; ./parsley test/craigs.let test/craigs.html > /dev/null
check-am:
- @echo "collate_regression..."; ./parsley test/collate_regression.let test/collate_regression.html 2>&1 | diff test/collate_regression.json - && echo " success."
@echo "sg_off..."; ./parsley test/sg_off.let test/sg_off.html 2>&1 | diff test/sg_off.json - && echo " success."
@echo "nth-regression..."; ./parsley test/nth-regression.let test/nth-regression.html 2>&1 | diff test/nth-regression.json - && echo " success."
@echo "array-regression..."; ./parsley test/array-regression.let test/array-regression.html 2>&1 | diff test/array-regression.json - && echo " success."
@@ -763,7 +762,8 @@ check-am:
@echo "reddit..."; ./parsley test/reddit.let test/reddit.html 2>&1 | diff test/reddit.json - && echo " success."
@echo "div..."; ./parsley test/div.let test/div.html 2>&1 | diff test/div.json - && echo " success."
@echo "default-namespace..."; ./parsley -x test/default-namespace.let test/default-namespace.xml 2>&1 | diff test/default-namespace.json - && echo " success."
- @echo "sg-wrap..."; ./parsley test/sg-wrap.let test/sg-wrap.html 2>&1 | diff test/sg-wrap.json - && echo " success."
+ @echo "sg-wrap..."; ./parsley -s test/sg-wrap.let test/sg-wrap.html 2>&1 | diff test/sg-wrap.json - && echo " success."
+ @echo "collate_regression..."; ./parsley test/collate_regression.let test/collate_regression.html 2>&1 | diff test/collate_regression.json - && echo " success."
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
View
10 README.C-LANG
@@ -46,8 +46,14 @@ parsedParsleyPtr parsley_parse_file(parsleyPtr parsley, char* file_name, int fla
- parsleyPtr parsley -- Compiled parsley struct
- char* file_name -- file to parse
- int flags -- a bitmask as follows:
- 1 - use the html parser? (instead of xml)
- 2 - prune empty subtrees, raising an error if a mandatory subtree is empty.
+ enum {
+ PARSLEY_OPTIONS_HTML = 1,
+ PARSLEY_OPTIONS_PRUNE = 2,
+ PARSLEY_OPTIONS_ALLOW_NET = 4,
+ PARSLEY_OPTIONS_ALLOW_LOCAL = 8,
+ PARSLEY_OPTIONS_COLLATE = 16,
+ PARSLEY_OPTIONS_SGWRAP = 32
+ };
Returns: A libxml2 document of the extracted data. You need to free this
with xmlFree(). To output, look at the libxml2 documentation for functions
View
3  parsley.c
@@ -459,7 +459,8 @@ parsedParsleyPtr parsley_parse_doc(parsleyPtr parsley, xmlDocPtr doc, int flags)
xsltTransformContextPtr ctxt = xsltNewTransformContext(parsley->stylesheet, doc);
xmlSetGenericErrorFunc(ctxt, parsleyXsltError);
current_ptr = ptr;
- if(true) { // TODO: potential performance optimization: only wrap if needed!
+
+ if(flags & PARSLEY_OPTIONS_SGWRAP) {
doc = parsley_apply_span_wrap(doc);
}
ptr->xml = xsltApplyStylesheetUser(parsley->stylesheet, doc, NULL, NULL, NULL, ctxt);
View
3  parsley.h
@@ -63,7 +63,8 @@ enum {
PARSLEY_OPTIONS_PRUNE = 2,
PARSLEY_OPTIONS_ALLOW_NET = 4,
PARSLEY_OPTIONS_ALLOW_LOCAL = 8,
- PARSLEY_OPTIONS_COLLATE = 16
+ PARSLEY_OPTIONS_COLLATE = 16,
+ PARSLEY_OPTIONS_SGWRAP = 32
};
typedef parsley_context * contextPtr;
View
8 parsley_main.c
@@ -44,6 +44,7 @@ static struct argp_option options[] = {
{"include", 'i', "FILE", 0, "Include the contents of FILE in the compiled XSLT" },
{"no-prune", 'n', 0, 0, "Don't prune empty subtrees" },
{"no-collate", 'N', 0, 0, "Don't collate array entries" },
+ {"sg-wrap", 's', 0, 0, "Wrap text nodes for SelectorGadget compatibility" },
{"user-agent", 'U', "USER_AGENT", 0, "Value of HTTP User-Agent header" },
{"no-net", 'z', 0, 0, "Disable ftp and http access for parselets" },
{"no-filesystem", 'Z', 0, 0, "Disable filesystem access for parselets" },
@@ -72,6 +73,9 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state)
case 'z':
arguments->flags &= ~PARSLEY_OPTIONS_ALLOW_NET;
break;
+ case 's':
+ arguments->flags |= PARSLEY_OPTIONS_SGWRAP;
+ break;
case 'Z':
arguments->flags &= ~PARSLEY_OPTIONS_ALLOW_LOCAL;
break;
@@ -117,11 +121,11 @@ int main (int argc, char **argv) {
struct list_elem *elemptr = &elem;
elem.has_next = 0;
arguments.output_xml = 0;
- arguments.flags = ~0;
+ arguments.flags = ~0 & ~PARSLEY_OPTIONS_SGWRAP;
arguments.include_files = elemptr;
arguments.output_file = "-";
argp_parse (&argp, argc, argv, 0, 0, &arguments);
-
+
struct printbuf *buf = printbuf_new();
struct printbuf *incl = printbuf_new();
sprintbuf(buf, "");
View
2  test/div.json
@@ -1 +1 @@
-{ "div": "Web Images Maps News Video Gmail more »", "a": "Images", "calc1": "Google", "calc2": "2", "calc3": "4", "calc4": "3", "prolly-nan": "NaN" }
+{ "div": "WebImagesMapsNewsVideoGmailmore »", "a": "Images", "calc1": "Google", "calc2": "2", "calc3": "4", "calc4": "3", "prolly-nan": "NaN" }
View
5 test/sg_off.html
@@ -0,0 +1,5 @@
+<html>
+ <body>
+ <p> <b>Hello</b> world!</p>
+ </body>
+</html>
View
3  test/sg_off.let
@@ -0,0 +1,3 @@
+{
+ "target": "p sg_wrap"
+}

0 comments on commit 01ba68f

Please sign in to comment.
Something went wrong with that request. Please try again.