|
|
@@ -2640,7 +2640,7 @@ static PyObject* Tokenizer_parse(Tokenizer* self, int context, int push) |
|
|
|
} |
|
|
|
else if (this == '>' && this_context & LC_TAG_CLOSE) |
|
|
|
return Tokenizer_handle_tag_close_close(self); |
|
|
|
else if (this == next && next == '\'') { |
|
|
|
else if (this == next && next == '\'' && !self->skip_style_tags) { |
|
|
|
temp = Tokenizer_parse_style(self); |
|
|
|
if (temp != Py_None) |
|
|
|
return temp; |
|
|
@@ -2675,9 +2675,9 @@ static PyObject* Tokenizer_parse(Tokenizer* self, int context, int push) |
|
|
|
static PyObject* Tokenizer_tokenize(Tokenizer* self, PyObject* args) |
|
|
|
{ |
|
|
|
PyObject *text, *temp; |
|
|
|
int context = 0; |
|
|
|
int context = 0, skip_style_tags = 0; |
|
|
|
|
|
|
|
if (PyArg_ParseTuple(args, "U|i", &text, &context)) { |
|
|
|
if (PyArg_ParseTuple(args, "U|ii", &text, &context, &skip_style_tags)) { |
|
|
|
Py_XDECREF(self->text); |
|
|
|
self->text = PySequence_Fast(text, "expected a sequence"); |
|
|
|
} |
|
|
@@ -2686,7 +2686,8 @@ static PyObject* Tokenizer_tokenize(Tokenizer* self, PyObject* args) |
|
|
|
Py_ssize_t size; |
|
|
|
/* Failed to parse a Unicode object; try a string instead. */ |
|
|
|
PyErr_Clear(); |
|
|
|
if (!PyArg_ParseTuple(args, "s#|i", &encoded, &size, &context)) |
|
|
|
if (!PyArg_ParseTuple(args, "s#|ii", &encoded, &size, &context, |
|
|
|
&skip_style_tags)) |
|
|
|
return NULL; |
|
|
|
temp = PyUnicode_FromStringAndSize(encoded, size); |
|
|
|
if (!text) |
|
|
@@ -2698,6 +2699,7 @@ static PyObject* Tokenizer_tokenize(Tokenizer* self, PyObject* args) |
|
|
|
} |
|
|
|
self->head = self->global = self->depth = self->cycles = 0; |
|
|
|
self->length = PyList_GET_SIZE(self->text); |
|
|
|
self->skip_style_tags = skip_style_tags; |
|
|
|
return Tokenizer_parse(self, context, 1); |
|
|
|
} |
|
|
|
|
|
|
|