/* Generated by Cython 0.29.28 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "depends": [
            "resiliparse/parse/html.h"
        ],
        "extra_compile_args": [
            "-std=c++17",
            "-O3",
            "-Wno-deprecated-declarations",
            "-Wno-unreachable-code",
            "-Wno-unused-function",
            "-fpermissive",
            "-Wno-c++11-narrowing"
        ],
        "extra_link_args": [
            "-std=c++17"
        ],
        "include_dirs": [
            "./resiliparse/parse"
        ],
        "language": "c++",
        "libraries": [
            "lexbor",
            "re2"
        ],
        "name": "resiliparse.extract.html2text",
        "sources": [
            "resiliparse/extract/html2text.pyx"
        ]
    },
    "module_name": "resiliparse.extract.html2text"
}
END: Cython Metadata */

#ifndef PY_SSIZE_T_CLEAN
#define PY_SSIZE_T_CLEAN
#endif /* PY_SSIZE_T_CLEAN */
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
    #error Cython requires Python 2.6+ or Python 3.3+.
#else
#define CYTHON_ABI "0_29_28"
#define CYTHON_HEX_VERSION 0x001D1CF0
#define CYTHON_FUTURE_DIVISION 1
#include <stddef.h>
#ifndef offsetof
  #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#define __PYX_COMMA ,
#ifndef HAVE_LONG_LONG
  #if PY_VERSION_HEX >= 0x02070000
    #define HAVE_LONG_LONG
  #endif
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
  #define CYTHON_COMPILING_IN_PYPY 1
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #undef CYTHON_USE_TYPE_SLOTS
  #define CYTHON_USE_TYPE_SLOTS 0
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #if PY_VERSION_HEX < 0x03050000
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #undef CYTHON_USE_UNICODE_INTERNALS
  #define CYTHON_USE_UNICODE_INTERNALS 0
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #undef CYTHON_AVOID_BORROWED_REFS
  #define CYTHON_AVOID_BORROWED_REFS 1
  #undef CYTHON_ASSUME_SAFE_MACROS
  #define CYTHON_ASSUME_SAFE_MACROS 0
  #undef CYTHON_UNPACK_METHODS
  #define CYTHON_UNPACK_METHODS 0
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#elif defined(PYSTON_VERSION)
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 1
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #undef CYTHON_USE_ASYNC_SLOTS
  #define CYTHON_USE_ASYNC_SLOTS 0
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#else
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 1
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYTYPE_LOOKUP
    #define CYTHON_USE_PYTYPE_LOOKUP 0
  #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
    #define CYTHON_USE_PYTYPE_LOOKUP 1
  #endif
  #if PY_MAJOR_VERSION < 3
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYLONG_INTERNALS
    #define CYTHON_USE_PYLONG_INTERNALS 0
  #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
    #define CYTHON_USE_PYLONG_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_PYLIST_INTERNALS
    #define CYTHON_USE_PYLIST_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2
    #undef CYTHON_USE_UNICODE_WRITER
    #define CYTHON_USE_UNICODE_WRITER 0
  #elif !defined(CYTHON_USE_UNICODE_WRITER)
    #define CYTHON_USE_UNICODE_WRITER 1
  #endif
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #if PY_VERSION_HEX >= 0x030B00A4
    #undef CYTHON_FAST_THREAD_STATE
    #define CYTHON_FAST_THREAD_STATE 0
  #elif !defined(CYTHON_FAST_THREAD_STATE)
    #define CYTHON_FAST_THREAD_STATE 1
  #endif
  #ifndef CYTHON_FAST_PYCALL
    #define CYTHON_FAST_PYCALL (PY_VERSION_HEX < 0x030B00A1)
  #endif
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  #endif
  #ifndef CYTHON_USE_DICT_VERSIONS
    #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
  #endif
  #if PY_VERSION_HEX >= 0x030B00A4
    #undef CYTHON_USE_EXC_INFO_STACK
    #define CYTHON_USE_EXC_INFO_STACK 0
  #elif !defined(CYTHON_USE_EXC_INFO_STACK)
    #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
  #endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
#define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
#endif
#if CYTHON_USE_PYLONG_INTERNALS
  #if PY_MAJOR_VERSION < 3
    #include "longintrepr.h"
  #endif
  #undef SHIFT
  #undef BASE
  #undef MASK
  #ifdef SIZEOF_VOID_P
    enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
  #endif
#endif
#ifndef __has_attribute
  #define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
  #define __has_cpp_attribute(x) 0
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER) && _MSC_VER >= 1400
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_MAYBE_UNUSED_VAR
#  if defined(__cplusplus)
     template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
#  else
#    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
#  endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
#ifdef _MSC_VER
    #ifndef _MSC_STDINT_H_
        #if _MSC_VER < 1300
           typedef unsigned char     uint8_t;
           typedef unsigned int      uint32_t;
        #else
           typedef unsigned __int8   uint8_t;
           typedef unsigned __int32  uint32_t;
        #endif
    #endif
#else
   #include <stdint.h>
#endif
#ifndef CYTHON_FALLTHROUGH
  #if defined(__cplusplus) && __cplusplus >= 201103L
    #if __has_cpp_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH [[fallthrough]]
    #elif __has_cpp_attribute(clang::fallthrough)
      #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
    #elif __has_cpp_attribute(gnu::fallthrough)
      #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
    #endif
  #endif
  #ifndef CYTHON_FALLTHROUGH
    #if __has_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
    #else
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
  #if defined(__clang__ ) && defined(__apple_build_version__)
    #if __apple_build_version__ < 7000000
      #undef  CYTHON_FALLTHROUGH
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
#endif

#ifndef __cplusplus
  #error "Cython files generated with the C++ option must be compiled with a C++ compiler."
#endif
#ifndef CYTHON_INLINE
  #if defined(__clang__)
    #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  #else
    #define CYTHON_INLINE inline
  #endif
#endif
template<typename T>
void __Pyx_call_destructor(T& x) {
    x.~T();
}
template<typename T>
class __Pyx_FakeReference {
  public:
    __Pyx_FakeReference() : ptr(NULL) { }
    __Pyx_FakeReference(const T& ref) : ptr(const_cast<T*>(&ref)) { }
    T *operator->() { return ptr; }
    T *operator&() { return ptr; }
    operator T&() { return *ptr; }
    template<typename U> bool operator ==(U other) { return *ptr == other; }
    template<typename U> bool operator !=(U other) { return *ptr != other; }
  private:
    T *ptr;
};

#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  #define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyClass_Type
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  #define __Pyx_DefaultClassType PyType_Type
#if PY_VERSION_HEX >= 0x030B00A1
    static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int k, int l, int s, int f,
                                                    PyObject *code, PyObject *c, PyObject* n, PyObject *v,
                                                    PyObject *fv, PyObject *cell, PyObject* fn,
                                                    PyObject *name, int fline, PyObject *lnos) {
        PyObject *kwds=NULL, *argcount=NULL, *posonlyargcount=NULL, *kwonlyargcount=NULL;
        PyObject *nlocals=NULL, *stacksize=NULL, *flags=NULL, *replace=NULL, *call_result=NULL, *empty=NULL;
        const char *fn_cstr=NULL;
        const char *name_cstr=NULL;
        PyCodeObject* co=NULL;
        PyObject *type, *value, *traceback;
        PyErr_Fetch(&type, &value, &traceback);
        if (!(kwds=PyDict_New())) goto end;
        if (!(argcount=PyLong_FromLong(a))) goto end;
        if (PyDict_SetItemString(kwds, "co_argcount", argcount) != 0) goto end;
        if (!(posonlyargcount=PyLong_FromLong(0))) goto end;
        if (PyDict_SetItemString(kwds, "co_posonlyargcount", posonlyargcount) != 0) goto end;
        if (!(kwonlyargcount=PyLong_FromLong(k))) goto end;
        if (PyDict_SetItemString(kwds, "co_kwonlyargcount", kwonlyargcount) != 0) goto end;
        if (!(nlocals=PyLong_FromLong(l))) goto end;
        if (PyDict_SetItemString(kwds, "co_nlocals", nlocals) != 0) goto end;
        if (!(stacksize=PyLong_FromLong(s))) goto end;
        if (PyDict_SetItemString(kwds, "co_stacksize", stacksize) != 0) goto end;
        if (!(flags=PyLong_FromLong(f))) goto end;
        if (PyDict_SetItemString(kwds, "co_flags", flags) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_code", code) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_consts", c) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_names", n) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_varnames", v) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_freevars", fv) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_cellvars", cell) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_linetable", lnos) != 0) goto end;
        if (!(fn_cstr=PyUnicode_AsUTF8AndSize(fn, NULL))) goto end;
        if (!(name_cstr=PyUnicode_AsUTF8AndSize(name, NULL))) goto end;
        if (!(co = PyCode_NewEmpty(fn_cstr, name_cstr, fline))) goto end;
        if (!(replace = PyObject_GetAttrString((PyObject*)co, "replace"))) goto cleanup_code_too;
        if (!(empty = PyTuple_New(0))) goto cleanup_code_too; // unfortunately __pyx_empty_tuple isn't available here
        if (!(call_result = PyObject_Call(replace, empty, kwds))) goto cleanup_code_too;
        Py_XDECREF((PyObject*)co);
        co = (PyCodeObject*)call_result;
        call_result = NULL;
        if (0) {
            cleanup_code_too:
            Py_XDECREF((PyObject*)co);
            co = NULL;
        }
        end:
        Py_XDECREF(kwds);
        Py_XDECREF(argcount);
        Py_XDECREF(posonlyargcount);
        Py_XDECREF(kwonlyargcount);
        Py_XDECREF(nlocals);
        Py_XDECREF(stacksize);
        Py_XDECREF(replace);
        Py_XDECREF(call_result);
        Py_XDECREF(empty);
        if (type) {
            PyErr_Restore(type, value, traceback);
        }
        return co;
    }
#else
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#endif
  #define __Pyx_DefaultClassType PyType_Type
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
  #define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
  #define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#ifndef METH_STACKLESS
  #define METH_STACKLESS 0
#endif
#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  #ifndef METH_FASTCALL
     #define METH_FASTCALL 0x80
  #endif
  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
                                                          Py_ssize_t nargs, PyObject *kwnames);
#else
  #define __Pyx_PyCFunctionFast _PyCFunctionFast
  #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
#endif
#if CYTHON_FAST_PYCCALL
#define __Pyx_PyFastCFunction_Check(func)\
    ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 0
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  #define PyObject_Malloc(s)   PyMem_Malloc(s)
  #define PyObject_Free(p)     PyMem_Free(p)
  #define PyObject_Realloc(p)  PyMem_Realloc(p)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
  #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
  #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
  #define PyMem_RawFree(p)             PyMem_Free(p)
#endif
#if CYTHON_COMPILING_IN_PYSTON
  #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
#else
  #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
#endif
#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#elif PY_VERSION_HEX >= 0x03060000
  #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
#elif PY_VERSION_HEX >= 0x03000000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#else
  #define __Pyx_PyThreadState_Current _PyThreadState_Current
#endif
#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
#include "pythread.h"
#define Py_tss_NEEDS_INIT 0
typedef int Py_tss_t;
static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  *key = PyThread_create_key();
  return 0;
}
static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  *key = Py_tss_NEEDS_INIT;
  return key;
}
static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  PyObject_Free(key);
}
static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  return *key != Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  PyThread_delete_key(*key);
  *key = Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  return PyThread_set_key_value(*key, value);
}
static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  return PyThread_get_key_value(*key);
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
#else
#define __Pyx_PyDict_NewPresized(n)  PyDict_New()
#endif
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
#define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
#else
#define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #if defined(PyUnicode_IS_READY)
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #else
  #define __Pyx_PyUnicode_READY(op)       (0)
  #endif
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
  #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
  #else
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  #endif
  #else
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_LENGTH(u))
  #endif
#else
  #define CYTHON_PEP393_ENABLED 0
  #define PyUnicode_1BYTE_KIND  1
  #define PyUnicode_2BYTE_KIND  2
  #define PyUnicode_4BYTE_KIND  4
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
#endif
#if CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
#else
  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
#endif
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
#else
  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  #define PyObject_ASCII(o)            PyObject_Repr(o)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#ifndef PyObject_Unicode
  #define PyObject_Unicode             PyObject_Str
#endif
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#if PY_VERSION_HEX >= 0x030900A4
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
#else
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
#endif
#if CYTHON_ASSUME_SAFE_MACROS
  #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
#else
  #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define PyNumber_Int                 PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  #ifndef PyUnicode_InternFromString
    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  #endif
#endif
#if PY_VERSION_HEX < 0x030200A4
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   __Pyx_PyIndex_AsHash_t
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   __Pyx_PyIndex_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if CYTHON_USE_ASYNC_SLOTS
  #if PY_VERSION_HEX >= 0x030500B1
    #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
    #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  #else
    #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  #endif
#else
  #define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef __Pyx_PyAsyncMethodsStruct
    typedef struct {
        unaryfunc am_await;
        unaryfunc am_aiter;
        unaryfunc am_anext;
    } __Pyx_PyAsyncMethodsStruct;
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
  #define _USE_MATH_DEFINES
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
#define __Pyx_truncl trunc
#else
#define __Pyx_truncl truncl
#endif

#define __PYX_MARK_ERR_POS(f_index, lineno) \
    { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
#define __PYX_ERR(f_index, lineno, Ln_error) \
    { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#define __PYX_HAVE__resiliparse__extract__html2text
#define __PYX_HAVE_API__resiliparse__extract__html2text
/* Early includes */
#include <stdint.h>
#include "ios"
#include "new"
#include "stdexcept"
#include "typeinfo"
#include <utility>

    #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)
    // move should be defined for these versions of MSVC, but __cplusplus isn't set usefully
    #include <type_traits>

    namespace cython_std {
    template <typename T> typename std::remove_reference<T>::type&& move(T& t) noexcept { return std::move(t); }
    template <typename T> typename std::remove_reference<T>::type&& move(T&& t) noexcept { return std::move(t); }
    }

    #endif
    
#include <set>
#include <string.h>
#include <memory>
#include <string>
#include <vector>
#include <cctype>
#include <map>
#include <string_view>
#include <re2/stringpiece.h>
#include <re2/re2.h>

    class RE2Stack {
    public:
        RE2Stack()
            : instance(nullptr) {}
        RE2Stack(const char* pattern)
            : instance(new re2::RE2(pattern)) {}
        RE2Stack(const std::string& pattern)
            : instance(new re2::RE2(pattern)){}
        RE2Stack(const re2::StringPiece& pattern)
            : instance(new re2::RE2(pattern)) {}
        RE2Stack(const re2::StringPiece& pattern, const re2::RE2::Options& options)
            : instance(new re2::RE2(pattern, options)) {}
        RE2Stack(const RE2Stack&) = delete;
        RE2Stack(RE2Stack&&) = delete;
        ~RE2Stack() {
            if (instance) {
                delete instance;
                instance = nullptr;
            }
        }
        RE2Stack& operator=(const RE2Stack&) = delete;
        RE2Stack& operator=(RE2Stack&& other) {
            if (this != &other) {
                instance = other.instance;
                other.instance = nullptr;
            }
            return *this;
        }

        inline const re2::RE2& operator()() const {
            return *instance;
        }

    private:
        re2::RE2* instance;
    };
    
#include <lexbor/core/core.h>
#include <lexbor/html/html.h>
#include <lexbor/dom/dom.h>
#include <lexbor/dom/interfaces/element.h>
#include "lexbor/dom/interfaces/document.h"
#include <lexbor/dom/collection.h>
#include <lexbor/css/css.h>
#include <lexbor/tag/tag.h>
#include <lexbor/selectors/selectors.h>
#include <lexbor/html/encoding.h>
#include <lexbor/encoding/encoding.h>
#include "html.h"

    struct ExtractOpts {
        bool preserve_formatting = true;
        bool list_bullets = true;
        bool links = false;
        bool alt_texts = true;
        bool form_fields = false;
        bool noscript = false;
    };

    struct ExtractContext {
        lxb_dom_node_t* root_node = NULL;
        lxb_dom_node_t* node = NULL;
        size_t depth = 0;
        ExtractOpts opts;
    };

    struct ExtractNode {
        lxb_dom_node_t* reference_node = NULL;
        lxb_tag_id_t tag_id = LXB_TAG__UNDEF;
        size_t depth = 0;
        bool space_after = false;
        bool collapse_margins = true;
        bool is_big_block = false;
        bool is_pre = false;
        bool is_end_tag = false;
        std::shared_ptr<std::string> text_contents = NULL;
    };
    
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
#define CYTHON_WITHOUT_ASSERTIONS
#endif

typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
    (sizeof(type) < sizeof(Py_ssize_t))  ||\
    (sizeof(type) > sizeof(Py_ssize_t) &&\
          likely(v < (type)PY_SSIZE_T_MAX ||\
                 v == (type)PY_SSIZE_T_MAX)  &&\
          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
                                v == (type)PY_SSIZE_T_MIN)))  ||\
    (sizeof(type) == sizeof(Py_ssize_t) &&\
          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
                               v == (type)PY_SSIZE_T_MAX)))  )
static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
    return (size_t) i < (size_t) limit;
}
#if defined (__cplusplus) && __cplusplus >= 201103L
    #include <cstdlib>
    #define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) labs(value)
#elif defined (_MSC_VER)
    #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define __Pyx_sst_abs(value) llabs(value)
#elif defined (__GNUC__)
    #define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
    #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return (size_t)(u_end - u - 1);
}
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
#define __Pyx_PySequence_Tuple(obj)\
    (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
#if CYTHON_ASSUME_SAFE_MACROS
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
#else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    const char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    if (strcmp(default_encoding_c, "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        char ascii_chars[128];
        int c;
        for (c = 0; c < 128; c++) {
            ascii_chars[c] = c;
        }
        __Pyx_sys_getdefaultencoding_not_ascii = 1;
        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
        if (!ascii_chars_u) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
            PyErr_Format(
                PyExc_ValueError,
                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
        Py_DECREF(ascii_chars_u);
        Py_DECREF(ascii_chars_b);
    }
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


/* Test for GCC > 2.95 */
#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  #define likely(x)   __builtin_expect(!!(x), 1)
  #define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */
static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }

static PyObject *__pyx_m = NULL;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_cython_runtime = NULL;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "resiliparse/extract/html2text.pyx",
  "resiliparse_common/string_util.pxd",
  "stringsource",
  "resiliparse/parse/html.pxd",
};
/* ForceInitThreads.proto */
#ifndef __PYX_FORCE_INIT_THREADS
  #define __PYX_FORCE_INIT_THREADS 0
#endif

/* NoFastGil.proto */
#define __Pyx_PyGILState_Ensure PyGILState_Ensure
#define __Pyx_PyGILState_Release PyGILState_Release
#define __Pyx_FastGIL_Remember()
#define __Pyx_FastGIL_Forget()
#define __Pyx_FastGilFuncInit()


/*--- Type declarations ---*/
struct __pyx_obj_11resiliparse_5parse_4html_DOMElementClassList;
struct __pyx_obj_11resiliparse_5parse_4html_DOMNode;
struct __pyx_obj_11resiliparse_5parse_4html_DOMCollection;
struct __pyx_obj_11resiliparse_5parse_4html_HTMLTree;
struct __pyx_opt_args_11resiliparse_5parse_4html_next_node;
struct __pyx_opt_args_11resiliparse_5parse_4html_next_element_node;
struct __pyx_opt_args_11resiliparse_5parse_4html_get_element_by_id_impl;
struct __pyx_opt_args_11resiliparse_5parse_4html_get_elements_by_attr_impl;
struct __pyx_opt_args_11resiliparse_5parse_4html_get_elements_by_class_name_impl;
struct __pyx_opt_args_11resiliparse_5parse_4html_query_selector_all_impl;
struct __pyx_opt_args_11resiliparse_5parse_4html_7DOMNode__getattr_impl;
struct __pyx_opt_args_11resiliparse_5parse_4html_7DOMNode_getattr;
struct __pyx_opt_args_11resiliparse_5parse_4html_7DOMNode_get_element_by_id;
struct __pyx_opt_args_11resiliparse_5parse_4html_7DOMNode_get_elements_by_attr;
struct __pyx_opt_args_11resiliparse_5parse_4html_7DOMNode_get_elements_by_class_name;
struct __pyx_opt_args_11resiliparse_5parse_4html_13DOMCollection_get_element_by_id;
struct __pyx_opt_args_11resiliparse_5parse_4html_13DOMCollection_get_elements_by_attr;
struct __pyx_opt_args_11resiliparse_5parse_4html_13DOMCollection_get_elements_by_class_name;
struct __pyx_opt_args_11resiliparse_5parse_4html_create_html_tree;

/* "resiliparse/parse/html.pxd":131
 * 
 * # noinspection DuplicatedCode
 * cpdef enum NodeType:             # <<<<<<<<<<<<<<
 *     ELEMENT = 0x01,
 *     ATTRIBUTE = 0x02,
 */
enum __pyx_t_11resiliparse_5parse_4html_NodeType {
  __pyx_e_11resiliparse_5parse_4html_ELEMENT = 0x01,
  __pyx_e_11resiliparse_5parse_4html_ATTRIBUTE = 0x02,
  __pyx_e_11resiliparse_5parse_4html_TEXT = 0x03,
  __pyx_e_11resiliparse_5parse_4html_CDATA_SECTION = 0x04,
  __pyx_e_11resiliparse_5parse_4html_ENTITY_REFERENCE = 0x05,
  __pyx_e_11resiliparse_5parse_4html_ENTITY = 0x06,
  __pyx_e_11resiliparse_5parse_4html_PROCESSING_INSTRUCTION = 0x07,
  __pyx_e_11resiliparse_5parse_4html_COMMENT = 0x08,
  __pyx_e_11resiliparse_5parse_4html_DOCUMENT = 0x09,
  __pyx_e_11resiliparse_5parse_4html_DOCUMENT_TYPE = 0x0A,
  __pyx_e_11resiliparse_5parse_4html_DOCUMENT_FRAGMENT = 0x0B,
  __pyx_e_11resiliparse_5parse_4html_NOTATION = 0x0C,
  __pyx_e_11resiliparse_5parse_4html_LAST_ENTRY = 0x0D
};

/* "resiliparse/parse/html.pxd":33
 *                                                   size_t selector_len) except NULL
 * 
 * cdef lxb_dom_node_t* next_node(const lxb_dom_node_t* root_node, lxb_dom_node_t* node,             # <<<<<<<<<<<<<<
 *                                size_t* depth=*, bint* end_tag=*) nogil
 * 
 */
struct __pyx_opt_args_11resiliparse_5parse_4html_next_node {
  int __pyx_n;
  size_t *depth;
  int *end_tag;
};

/* "resiliparse/parse/html.pxd":36
 *                                size_t* depth=*, bint* end_tag=*) nogil
 * 
 * cdef inline lxb_dom_node_t* next_element_node(const lxb_dom_node_t* root_node, lxb_dom_node_t* node,             # <<<<<<<<<<<<<<
 *                                               size_t* depth=NULL, bint* end_tag=NULL) nogil:
 *     node = next_node(root_node, node, depth, end_tag)
 */
struct __pyx_opt_args_11resiliparse_5parse_4html_next_element_node {
  int __pyx_n;
  size_t *depth;
  int *end_tag;
};

/* "resiliparse/parse/html.pxd":59
 * cdef string get_node_text(lxb_dom_node_t* node) nogil
 * 
 * cdef lxb_dom_node_t* get_element_by_id_impl(lxb_dom_node_t* node, bytes id_value, bint case_insensitive=*)             # <<<<<<<<<<<<<<
 * cdef lxb_dom_collection_t* get_elements_by_attr_impl(lxb_dom_node_t* node, bytes attr_name, bytes attr_value,
 *                                                      size_t init_size=*, bint case_insensitive=*)
 */
struct __pyx_opt_args_11resiliparse_5parse_4html_get_element_by_id_impl {
  int __pyx_n;
  int case_insensitive;
};

/* "resiliparse/parse/html.pxd":60
 * 
 * cdef lxb_dom_node_t* get_element_by_id_impl(lxb_dom_node_t* node, bytes id_value, bint case_insensitive=*)
 * cdef lxb_dom_collection_t* get_elements_by_attr_impl(lxb_dom_node_t* node, bytes attr_name, bytes attr_value,             # <<<<<<<<<<<<<<
 *                                                      size_t init_size=*, bint case_insensitive=*)
 * cdef lxb_dom_collection_t* get_elements_by_class_name_impl(lxb_dom_node_t* node, bytes class_name, size_t init_size=*)
 */
struct __pyx_opt_args_11resiliparse_5parse_4html_get_elements_by_attr_impl {
  int __pyx_n;
  size_t init_size;
  int case_insensitive;
};

/* "resiliparse/parse/html.pxd":62
 * cdef lxb_dom_collection_t* get_elements_by_attr_impl(lxb_dom_node_t* node, bytes attr_name, bytes attr_value,
 *                                                      size_t init_size=*, bint case_insensitive=*)
 * cdef lxb_dom_collection_t* get_elements_by_class_name_impl(lxb_dom_node_t* node, bytes class_name, size_t init_size=*)             # <<<<<<<<<<<<<<
 * cdef lxb_dom_collection_t* get_elements_by_tag_name_impl(lxb_dom_node_t* node, bytes tag_name)
 * cdef lxb_dom_node_t* query_selector_impl(lxb_dom_node_t* node, HTMLTree tree,
 */
struct __pyx_opt_args_11resiliparse_5parse_4html_get_elements_by_class_name_impl {
  int __pyx_n;
  size_t init_size;
};

/* "resiliparse/parse/html.pxd":66
 * cdef lxb_dom_node_t* query_selector_impl(lxb_dom_node_t* node, HTMLTree tree,
 *                                          bytes selector) except <lxb_dom_node_t*>-1
 * cdef lxb_dom_collection_t* query_selector_all_impl(lxb_dom_node_t* node, HTMLTree tree, bytes selector,             # <<<<<<<<<<<<<<
 *                                                    size_t init_size=*) except <lxb_dom_collection_t*>-1
 * cdef bint matches_impl(lxb_dom_node_t* node, HTMLTree tree, bytes selector)
 */
struct __pyx_opt_args_11resiliparse_5parse_4html_query_selector_all_impl {
  int __pyx_n;
  size_t init_size;
};

/* "resiliparse/parse/html.pxd":90
 * 
 *     cpdef bint hasattr(self, str attr_name) except -1
 *     cdef str _getattr_impl(self, const string& attr_name, bint raise_if_not_exists=*)             # <<<<<<<<<<<<<<
 *     cpdef str getattr(self, str attr_name, str default_value=*)
 *     cdef bint _setattr_impl(self, bytes attr_name, bytes attr_value)  except -1
 */
struct __pyx_opt_args_11resiliparse_5parse_4html_7DOMNode__getattr_impl {
  int __pyx_n;
  int raise_if_not_exists;
};

/* "resiliparse/parse/html.pxd":91
 *     cpdef bint hasattr(self, str attr_name) except -1
 *     cdef str _getattr_impl(self, const string& attr_name, bint raise_if_not_exists=*)
 *     cpdef str getattr(self, str attr_name, str default_value=*)             # <<<<<<<<<<<<<<
 *     cdef bint _setattr_impl(self, bytes attr_name, bytes attr_value)  except -1
 *     cpdef setattr(self, str attr_name, str attr_value)
 */
struct __pyx_opt_args_11resiliparse_5parse_4html_7DOMNode_getattr {
  int __pyx_n;
  PyObject *default_value;
};

/* "resiliparse/parse/html.pxd":97
 *     cpdef delattr(self, str attr_name)
 * 
 *     cpdef DOMNode get_element_by_id(self, str element_id, bint case_insensitive=*)             # <<<<<<<<<<<<<<
 *     cpdef DOMCollection get_elements_by_attr(self, str attr_name, str attr_value, bint case_insensitive=*)
 *     cpdef DOMCollection get_elements_by_class_name(self, str class_name, bint case_insensitive=*)
 */
struct __pyx_opt_args_11resiliparse_5parse_4html_7DOMNode_get_element_by_id {
  int __pyx_n;
  int case_insensitive;
};

/* "resiliparse/parse/html.pxd":98
 * 
 *     cpdef DOMNode get_element_by_id(self, str element_id, bint case_insensitive=*)
 *     cpdef DOMCollection get_elements_by_attr(self, str attr_name, str attr_value, bint case_insensitive=*)             # <<<<<<<<<<<<<<
 *     cpdef DOMCollection get_elements_by_class_name(self, str class_name, bint case_insensitive=*)
 *     cpdef DOMCollection get_elements_by_tag_name(self, str tag_name)
 */
struct __pyx_opt_args_11resiliparse_5parse_4html_7DOMNode_get_elements_by_attr {
  int __pyx_n;
  int case_insensitive;
};

/* "resiliparse/parse/html.pxd":99
 *     cpdef DOMNode get_element_by_id(self, str element_id, bint case_insensitive=*)
 *     cpdef DOMCollection get_elements_by_attr(self, str attr_name, str attr_value, bint case_insensitive=*)
 *     cpdef DOMCollection get_elements_by_class_name(self, str class_name, bint case_insensitive=*)             # <<<<<<<<<<<<<<
 *     cpdef DOMCollection get_elements_by_tag_name(self, str tag_name)
 * 
 */
struct __pyx_opt_args_11resiliparse_5parse_4html_7DOMNode_get_elements_by_class_name {
  int __pyx_n;
  int case_insensitive;
};

/* "resiliparse/parse/html.pxd":120
 *     cdef DOMCollection _forward_collection_match(self, bytes func, attrs)
 * 
 *     cpdef DOMNode get_element_by_id(self, str element_id, bint case_insensitive=*)             # <<<<<<<<<<<<<<
 *     cpdef DOMCollection get_elements_by_attr(self, str attr_name, str attr_value, bint case_insensitive=*)
 *     cpdef DOMCollection get_elements_by_class_name(self, str class_name, bint case_insensitive=*)
 */
struct __pyx_opt_args_11resiliparse_5parse_4html_13DOMCollection_get_element_by_id {
  int __pyx_n;
  int case_insensitive;
};

/* "resiliparse/parse/html.pxd":121
 * 
 *     cpdef DOMNode get_element_by_id(self, str element_id, bint case_insensitive=*)
 *     cpdef DOMCollection get_elements_by_attr(self, str attr_name, str attr_value, bint case_insensitive=*)             # <<<<<<<<<<<<<<
 *     cpdef DOMCollection get_elements_by_class_name(self, str class_name, bint case_insensitive=*)
 *     cpdef DOMCollection get_elements_by_tag_name(self, str tag_name)
 */
struct __pyx_opt_args_11resiliparse_5parse_4html_13DOMCollection_get_elements_by_attr {
  int __pyx_n;
  int case_insensitive;
};

/* "resiliparse/parse/html.pxd":122
 *     cpdef DOMNode get_element_by_id(self, str element_id, bint case_insensitive=*)
 *     cpdef DOMCollection get_elements_by_attr(self, str attr_name, str attr_value, bint case_insensitive=*)
 *     cpdef DOMCollection get_elements_by_class_name(self, str class_name, bint case_insensitive=*)             # <<<<<<<<<<<<<<
 *     cpdef DOMCollection get_elements_by_tag_name(self, str tag_name)
 * 
 */
struct __pyx_opt_args_11resiliparse_5parse_4html_13DOMCollection_get_elements_by_class_name {
  int __pyx_n;
  int case_insensitive;
};

/* "resiliparse/parse/html.pxd":147
 * 
 * 
 * cdef HTMLTree create_html_tree(bytes document, bint reencode=*, str encoding=*, str errors=*)             # <<<<<<<<<<<<<<
 * 
 * cdef class HTMLTree:
 */
struct __pyx_opt_args_11resiliparse_5parse_4html_create_html_tree {
  int __pyx_n;
  int reencode;
  PyObject *encoding;
  PyObject *errors;
};

/* "resiliparse/parse/html.pxd":75
 * 
 * 
 * cdef class DOMElementClassList:             # <<<<<<<<<<<<<<
 *     cdef DOMNode node
 * 
 */
struct __pyx_obj_11resiliparse_5parse_4html_DOMElementClassList {
  PyObject_HEAD
  struct __pyx_vtabstruct_11resiliparse_5parse_4html_DOMElementClassList *__pyx_vtab;
  struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *node;
};


/* "resiliparse/parse/html.pxd":84
 * 
 * 
 * cdef class DOMNode:             # <<<<<<<<<<<<<<
 *     cdef HTMLTree tree
 *     cdef lxb_dom_node_t* node
 */
struct __pyx_obj_11resiliparse_5parse_4html_DOMNode {
  PyObject_HEAD
  struct __pyx_vtabstruct_11resiliparse_5parse_4html_DOMNode *__pyx_vtab;
  struct __pyx_obj_11resiliparse_5parse_4html_HTMLTree *tree;
  lxb_dom_node_t *node;
  struct __pyx_obj_11resiliparse_5parse_4html_DOMElementClassList *class_list_singleton;
};


/* "resiliparse/parse/html.pxd":113
 * 
 * 
 * cdef class DOMCollection:             # <<<<<<<<<<<<<<
 *     cdef HTMLTree tree
 *     cdef lxb_dom_collection_t* coll
 */
struct __pyx_obj_11resiliparse_5parse_4html_DOMCollection {
  PyObject_HEAD
  struct __pyx_vtabstruct_11resiliparse_5parse_4html_DOMCollection *__pyx_vtab;
  struct __pyx_obj_11resiliparse_5parse_4html_HTMLTree *tree;
  lxb_dom_collection_t *coll;
};


/* "resiliparse/parse/html.pxd":149
 * cdef HTMLTree create_html_tree(bytes document, bint reencode=*, str encoding=*, str errors=*)
 * 
 * cdef class HTMLTree:             # <<<<<<<<<<<<<<
 *     cdef lxb_html_document_t* dom_document
 *     cdef str encoding
 */
struct __pyx_obj_11resiliparse_5parse_4html_HTMLTree {
  PyObject_HEAD
  struct __pyx_vtabstruct_11resiliparse_5parse_4html_HTMLTree *__pyx_vtab;
  lxb_html_document_t *dom_document;
  PyObject *encoding;
  lxb_css_parser_t *css_parser;
  lxb_selectors_t *selectors;
  lxb_css_selectors_t *css_selectors;
};



/* "resiliparse/parse/html.pxd":75
 * 
 * 
 * cdef class DOMElementClassList:             # <<<<<<<<<<<<<<
 *     cdef DOMNode node
 * 
 */

struct __pyx_vtabstruct_11resiliparse_5parse_4html_DOMElementClassList {
  PyObject *(*_create_list)(struct __pyx_obj_11resiliparse_5parse_4html_DOMElementClassList *);
  PyObject *(*_class_name_bytes)(struct __pyx_obj_11resiliparse_5parse_4html_DOMElementClassList *);
  void (*add)(struct __pyx_obj_11resiliparse_5parse_4html_DOMElementClassList *, PyObject *, int __pyx_skip_dispatch);
  void (*remove)(struct __pyx_obj_11resiliparse_5parse_4html_DOMElementClassList *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_11resiliparse_5parse_4html_DOMElementClassList *__pyx_vtabptr_11resiliparse_5parse_4html_DOMElementClassList;


/* "resiliparse/parse/html.pxd":84
 * 
 * 
 * cdef class DOMNode:             # <<<<<<<<<<<<<<
 *     cdef HTMLTree tree
 *     cdef lxb_dom_node_t* node
 */

struct __pyx_vtabstruct_11resiliparse_5parse_4html_DOMNode {
  int (*hasattr)(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*_getattr_impl)(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, std::string const &, struct __pyx_opt_args_11resiliparse_5parse_4html_7DOMNode__getattr_impl *__pyx_optional_args);
  PyObject *(*getattr)(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_11resiliparse_5parse_4html_7DOMNode_getattr *__pyx_optional_args);
  int (*_setattr_impl)(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, PyObject *, PyObject *);
  PyObject *(*setattr)(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  int (*_delattr_impl)(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, PyObject *);
  PyObject *(*delattr)(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *(*get_element_by_id)(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_11resiliparse_5parse_4html_7DOMNode_get_element_by_id *__pyx_optional_args);
  struct __pyx_obj_11resiliparse_5parse_4html_DOMCollection *(*get_elements_by_attr)(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_11resiliparse_5parse_4html_7DOMNode_get_elements_by_attr *__pyx_optional_args);
  struct __pyx_obj_11resiliparse_5parse_4html_DOMCollection *(*get_elements_by_class_name)(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_11resiliparse_5parse_4html_7DOMNode_get_elements_by_class_name *__pyx_optional_args);
  struct __pyx_obj_11resiliparse_5parse_4html_DOMCollection *(*get_elements_by_tag_name)(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *(*query_selector)(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_11resiliparse_5parse_4html_DOMCollection *(*query_selector_all)(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, PyObject *, int __pyx_skip_dispatch);
  int (*matches)(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *(*append_child)(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, int __pyx_skip_dispatch);
  struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *(*insert_before)(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, int __pyx_skip_dispatch);
  struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *(*replace_child)(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, int __pyx_skip_dispatch);
  struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *(*remove_child)(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, int __pyx_skip_dispatch);
  PyObject *(*decompose)(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_11resiliparse_5parse_4html_DOMNode *__pyx_vtabptr_11resiliparse_5parse_4html_DOMNode;


/* "resiliparse/parse/html.pxd":113
 * 
 * 
 * cdef class DOMCollection:             # <<<<<<<<<<<<<<
 *     cdef HTMLTree tree
 *     cdef lxb_dom_collection_t* coll
 */

struct __pyx_vtabstruct_11resiliparse_5parse_4html_DOMCollection {
  size_t (*_wrap_idx)(struct __pyx_obj_11resiliparse_5parse_4html_DOMCollection *, Py_ssize_t);
  struct __pyx_obj_11resiliparse_5parse_4html_DOMCollection *(*_forward_collection_match)(struct __pyx_obj_11resiliparse_5parse_4html_DOMCollection *, PyObject *, PyObject *);
  struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *(*get_element_by_id)(struct __pyx_obj_11resiliparse_5parse_4html_DOMCollection *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_11resiliparse_5parse_4html_13DOMCollection_get_element_by_id *__pyx_optional_args);
  struct __pyx_obj_11resiliparse_5parse_4html_DOMCollection *(*get_elements_by_attr)(struct __pyx_obj_11resiliparse_5parse_4html_DOMCollection *, PyObject *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_11resiliparse_5parse_4html_13DOMCollection_get_elements_by_attr *__pyx_optional_args);
  struct __pyx_obj_11resiliparse_5parse_4html_DOMCollection *(*get_elements_by_class_name)(struct __pyx_obj_11resiliparse_5parse_4html_DOMCollection *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_11resiliparse_5parse_4html_13DOMCollection_get_elements_by_class_name *__pyx_optional_args);
  struct __pyx_obj_11resiliparse_5parse_4html_DOMCollection *(*get_elements_by_tag_name)(struct __pyx_obj_11resiliparse_5parse_4html_DOMCollection *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *(*query_selector)(struct __pyx_obj_11resiliparse_5parse_4html_DOMCollection *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_11resiliparse_5parse_4html_DOMCollection *(*query_selector_all)(struct __pyx_obj_11resiliparse_5parse_4html_DOMCollection *, PyObject *, int __pyx_skip_dispatch);
  int (*matches)(struct __pyx_obj_11resiliparse_5parse_4html_DOMCollection *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_11resiliparse_5parse_4html_DOMCollection *__pyx_vtabptr_11resiliparse_5parse_4html_DOMCollection;


/* "resiliparse/parse/html.pxd":149
 * cdef HTMLTree create_html_tree(bytes document, bint reencode=*, str encoding=*, str errors=*)
 * 
 * cdef class HTMLTree:             # <<<<<<<<<<<<<<
 *     cdef lxb_html_document_t* dom_document
 *     cdef str encoding
 */

struct __pyx_vtabstruct_11resiliparse_5parse_4html_HTMLTree {
  struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *(*create_element)(struct __pyx_obj_11resiliparse_5parse_4html_HTMLTree *, PyObject *, int __pyx_skip_dispatch);
  struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *(*create_text_node)(struct __pyx_obj_11resiliparse_5parse_4html_HTMLTree *, PyObject *, int __pyx_skip_dispatch);
  void (*init_css_parser)(struct __pyx_obj_11resiliparse_5parse_4html_HTMLTree *);
};
static struct __pyx_vtabstruct_11resiliparse_5parse_4html_HTMLTree *__pyx_vtabptr_11resiliparse_5parse_4html_HTMLTree;

/* --- Runtime support code (head) --- */
/* Refnanny.proto */
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          if (acquire_gil) {\
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
              PyGILState_Release(__pyx_gilstate_save);\
          } else {\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext()\
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_XDECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_XDECREF(tmp);\
    } while (0)
#define __Pyx_DECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_DECREF(tmp);\
    } while (0)
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

/* PyObjectGetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

/* GetBuiltinName.proto */
static PyObject *__Pyx_GetBuiltinName(PyObject *name);

/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
#define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#define __Pyx_PyErr_Occurred()  PyErr_Occurred()
#endif

/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
#define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
#else
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#endif
#else
#define __Pyx_PyErr_Clear() PyErr_Clear()
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
#endif

/* WriteUnraisableException.proto */
static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename,
                                  int full_traceback, int nogil);

/* RaiseDoubleKeywords.proto */
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);

/* ParseKeywords.proto */
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
    const char* function_name);

/* RaiseArgTupleInvalid.proto */
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);

/* ArgTypeTest.proto */
#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
    ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
        __Pyx__ArgTypeTest(obj, type, name, exact))
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);

/* ExtTypeTest.proto */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);

/* PyFunctionFastCall.proto */
#if CYTHON_FAST_PYCALL
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
    __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
#else
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
#endif
#define __Pyx_BUILD_ASSERT_EXPR(cond)\
    (sizeof(char [1 - 2*!(cond)]) - 1)
#ifndef Py_MEMBER_SIZE
#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
#endif
#if CYTHON_FAST_PYCALL
  static size_t __pyx_pyframe_localsplus_offset = 0;
  #include "frameobject.h"
  #define __Pxy_PyFrame_Initialize_Offsets()\
    ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
     (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
  #define __Pyx_PyFrame_GetLocalsplus(frame)\
    (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
#endif // CYTHON_FAST_PYCALL
#endif

/* PyObjectCall.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif

/* PyObjectCallMethO.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

/* PyObjectCallNoArg.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif

/* PyCFunctionFastCall.proto */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
#else
#define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
#endif

/* PyObjectCallOneArg.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

/* UnpackUnboundCMethod.proto */
typedef struct {
    PyObject *type;
    PyObject **method_name;
    PyCFunction func;
    PyObject *method;
    int flag;
} __Pyx_CachedCFunction;

/* CallUnboundCMethod1.proto */
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#else
#define __Pyx_CallUnboundCMethod1(cfunc, self, arg)  __Pyx__CallUnboundCMethod1(cfunc, self, arg)
#endif

/* StringJoin.proto */
#if PY_MAJOR_VERSION < 3
#define __Pyx_PyString_Join __Pyx_PyBytes_Join
#define __Pyx_PyBaseString_Join(s, v) (PyUnicode_CheckExact(s) ? PyUnicode_Join(s, v) : __Pyx_PyBytes_Join(s, v))
#else
#define __Pyx_PyString_Join PyUnicode_Join
#define __Pyx_PyBaseString_Join PyUnicode_Join
#endif
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION < 3
    #define __Pyx_PyBytes_Join _PyString_Join
    #else
    #define __Pyx_PyBytes_Join _PyBytes_Join
    #endif
#else
static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values);
#endif

/* GetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* SwapException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* GetTopmostException.proto */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
#endif

/* SaveResetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
#else
#define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
#define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
#endif

/* PyDictVersioning.proto */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
#define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
#define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
    (version_var) = __PYX_GET_DICT_VERSION(dict);\
    (cache_var) = (value);
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
        (VAR) = __pyx_dict_cached_value;\
    } else {\
        (VAR) = __pyx_dict_cached_value = (LOOKUP);\
        __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
    }\
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
#else
#define __PYX_GET_DICT_VERSION(dict)  (0)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
#endif

/* GetModuleGlobalName.proto */
#if CYTHON_USE_DICT_VERSIONS
#define __Pyx_GetModuleGlobalName(var, name)  {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
        (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
        __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
#define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
    PY_UINT64_T __pyx_dict_version;\
    PyObject *__pyx_dict_cached_value;\
    (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
#else
#define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
#define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
#endif

/* PyObjectCall2Args.proto */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);

/* TypeImport.proto */
#ifndef __PYX_HAVE_RT_ImportType_proto
#define __PYX_HAVE_RT_ImportType_proto
enum __Pyx_ImportType_CheckSize {
   __Pyx_ImportType_CheckSize_Error = 0,
   __Pyx_ImportType_CheckSize_Warn = 1,
   __Pyx_ImportType_CheckSize_Ignore = 2
};
static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
#endif

/* GetVTable.proto */
static void* __Pyx_GetVtable(PyObject *dict);

/* Import.proto */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

/* ImportFrom.proto */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

/* CLineInTraceback.proto */
#ifdef CYTHON_CLINE_IN_TRACEBACK
#define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
#else
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
#endif

/* CodeObjectCache.proto */
typedef struct {
    PyCodeObject* code_object;
    int code_line;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

/* AddTraceback.proto */
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename);

/* CppExceptionConversion.proto */
#ifndef __Pyx_CppExn2PyErr
#include <new>
#include <typeinfo>
#include <stdexcept>
#include <ios>
static void __Pyx_CppExn2PyErr() {
  try {
    if (PyErr_Occurred())
      ; // let the latest Python exn pass through and ignore the current one
    else
      throw;
  } catch (const std::bad_alloc& exn) {
    PyErr_SetString(PyExc_MemoryError, exn.what());
  } catch (const std::bad_cast& exn) {
    PyErr_SetString(PyExc_TypeError, exn.what());
  } catch (const std::bad_typeid& exn) {
    PyErr_SetString(PyExc_TypeError, exn.what());
  } catch (const std::domain_error& exn) {
    PyErr_SetString(PyExc_ValueError, exn.what());
  } catch (const std::invalid_argument& exn) {
    PyErr_SetString(PyExc_ValueError, exn.what());
  } catch (const std::ios_base::failure& exn) {
    PyErr_SetString(PyExc_IOError, exn.what());
  } catch (const std::out_of_range& exn) {
    PyErr_SetString(PyExc_IndexError, exn.what());
  } catch (const std::overflow_error& exn) {
    PyErr_SetString(PyExc_OverflowError, exn.what());
  } catch (const std::range_error& exn) {
    PyErr_SetString(PyExc_ArithmeticError, exn.what());
  } catch (const std::underflow_error& exn) {
    PyErr_SetString(PyExc_ArithmeticError, exn.what());
  } catch (const std::exception& exn) {
    PyErr_SetString(PyExc_RuntimeError, exn.what());
  }
  catch (...)
  {
    PyErr_SetString(PyExc_RuntimeError, "Unknown exception");
  }
}
#endif

/* GCCDiagnostics.proto */
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
#define __Pyx_HAS_GCC_DIAGNOSTIC
#endif

/* CIntFromPy.proto */
static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

/* CIntFromPy.proto */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

/* FastTypeChecks.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
#else
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
#endif
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)

/* CheckBinaryVersion.proto */
static int __Pyx_check_binary_version(void);

/* FunctionImport.proto */
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig);

/* InitStrings.proto */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);


/* Module declarations from 'libc.stdint' */

/* Module declarations from 'libcpp.utility' */

/* Module declarations from 'libcpp.set' */

/* Module declarations from 'libc.string' */

/* Module declarations from 'libcpp' */

/* Module declarations from 'libcpp.memory' */

/* Module declarations from 'libcpp.string' */

/* Module declarations from 'libcpp.vector' */

/* Module declarations from 'resiliparse_inc.cctype' */

/* Module declarations from 'resiliparse_common.string_util' */
static CYTHON_INLINE size_t __pyx_f_18resiliparse_common_11string_util_lstrip_c_str(char const **, size_t); /*proto*/
static CYTHON_INLINE size_t __pyx_f_18resiliparse_common_11string_util_rstrip_c_str(char const **, size_t); /*proto*/
static CYTHON_INLINE size_t __pyx_f_18resiliparse_common_11string_util_strip_c_str(char const **, size_t); /*proto*/
static CYTHON_INLINE std::string __pyx_f_18resiliparse_common_11string_util_rstrip_str(std::string const &); /*proto*/
static CYTHON_INLINE std::string __pyx_f_18resiliparse_common_11string_util_strip_str(std::string const &); /*proto*/

/* Module declarations from 'libcpp.map' */

/* Module declarations from 'resiliparse_inc.string_view' */

/* Module declarations from 'resiliparse_inc.re2' */

/* Module declarations from 'resiliparse_inc.lexbor' */

/* Module declarations from 'resiliparse.parse.html' */
static PyTypeObject *__pyx_ptype_11resiliparse_5parse_4html_DOMElementClassList = 0;
static PyTypeObject *__pyx_ptype_11resiliparse_5parse_4html_DOMNode = 0;
static PyTypeObject *__pyx_ptype_11resiliparse_5parse_4html_DOMCollection = 0;
static PyTypeObject *__pyx_ptype_11resiliparse_5parse_4html_HTMLTree = 0;
static CYTHON_INLINE int __pyx_f_11resiliparse_5parse_4html_check_node(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *); /*proto*/
static int (*__pyx_f_11resiliparse_5parse_4html_init_css_parser)(lxb_css_parser_t **); /*proto*/
static void (*__pyx_f_11resiliparse_5parse_4html_destroy_css_parser)(lxb_css_parser_t *); /*proto*/
static int (*__pyx_f_11resiliparse_5parse_4html_init_css_selectors)(lxb_css_parser_t *, lxb_css_selectors_t **, lxb_selectors_t **); /*proto*/
static void (*__pyx_f_11resiliparse_5parse_4html_destroy_css_selectors)(lxb_css_selectors_t *, lxb_selectors_t *); /*proto*/
static lxb_css_selector_list_t *(*__pyx_f_11resiliparse_5parse_4html_parse_css_selectors)(lxb_css_parser_t *, lxb_char_t const *, size_t); /*proto*/
static lxb_dom_node_t *(*__pyx_f_11resiliparse_5parse_4html_next_node)(lxb_dom_node_t const *, lxb_dom_node_t *, struct __pyx_opt_args_11resiliparse_5parse_4html_next_node *__pyx_optional_args); /*proto*/
static CYTHON_INLINE lxb_dom_node_t *__pyx_f_11resiliparse_5parse_4html_next_element_node(lxb_dom_node_t const *, lxb_dom_node_t *, struct __pyx_opt_args_11resiliparse_5parse_4html_next_element_node *__pyx_optional_args); /*proto*/
static CYTHON_INLINE std::string_view __pyx_f_11resiliparse_5parse_4html_get_node_attr_sv(lxb_dom_node_t *, std::string const &); /*proto*/
static CYTHON_INLINE re2::StringPiece __pyx_f_11resiliparse_5parse_4html_get_node_attr_sp(lxb_dom_node_t *, std::string const &); /*proto*/
static std::string (*__pyx_f_11resiliparse_5parse_4html_get_node_text)(lxb_dom_node_t *); /*proto*/
static int (*__pyx_f_11resiliparse_5parse_4html_is_block_element)(lxb_tag_id_t); /*proto*/

/* Module declarations from 'resiliparse.extract.html2text' */
static std::string __pyx_v_11resiliparse_7extract_9html2text_LIST_BULLET;
static re2::RE2::Options __pyx_v_11resiliparse_7extract_9html2text_re_opts;
static RE2Stack __pyx_v_11resiliparse_7extract_9html2text_article_cls_regex;
static RE2Stack __pyx_v_11resiliparse_7extract_9html2text_nav_cls_regex;
static RE2Stack __pyx_v_11resiliparse_7extract_9html2text_recommended_cls_regex;
static RE2Stack __pyx_v_11resiliparse_7extract_9html2text_landmark_id_regex;
static RE2Stack __pyx_v_11resiliparse_7extract_9html2text_header_cls_regex;
static RE2Stack __pyx_v_11resiliparse_7extract_9html2text_footer_cls_regex;
static RE2Stack __pyx_v_11resiliparse_7extract_9html2text_post_meta_cls_regex;
static RE2Stack __pyx_v_11resiliparse_7extract_9html2text_sidebar_cls_regex;
static RE2Stack __pyx_v_11resiliparse_7extract_9html2text_search_cls_regex;
static RE2Stack __pyx_v_11resiliparse_7extract_9html2text_skip_link_cls_regex;
static RE2Stack __pyx_v_11resiliparse_7extract_9html2text_display_cls_regex;
static RE2Stack __pyx_v_11resiliparse_7extract_9html2text_display_css_regex;
static RE2Stack __pyx_v_11resiliparse_7extract_9html2text_modal_cls_regex;
static RE2Stack __pyx_v_11resiliparse_7extract_9html2text_gallery_cls_regex;
static RE2Stack __pyx_v_11resiliparse_7extract_9html2text_signin_cls_regex;
static RE2Stack __pyx_v_11resiliparse_7extract_9html2text_ads_cls_regex;
static RE2Stack __pyx_v_11resiliparse_7extract_9html2text_social_cls_regex;
static RE2Stack __pyx_v_11resiliparse_7extract_9html2text_comments_cls_regex;
static RE2Stack __pyx_v_11resiliparse_7extract_9html2text_logo_cls_regex;
static RE2Stack __pyx_v_11resiliparse_7extract_9html2text_print_cls_regex;
static std::set<std::string>  __pyx_v_11resiliparse_7extract_9html2text_blacklist_aria_roles;
static std::string __pyx_f_11resiliparse_7extract_9html2text__get_collapsed_string(std::string const &); /*proto*/
static CYTHON_INLINE void __pyx_f_11resiliparse_7extract_9html2text__ensure_text_contents(std::vector<std::shared_ptr<struct ExtractNode> >  &); /*proto*/
static void __pyx_f_11resiliparse_7extract_9html2text__extract_cb(std::vector<std::shared_ptr<struct ExtractNode> >  &, struct ExtractContext &, int); /*proto*/
static CYTHON_INLINE std::string __pyx_f_11resiliparse_7extract_9html2text__indent_newlines(std::string const &, size_t); /*proto*/
static std::string __pyx_f_11resiliparse_7extract_9html2text__serialize_extract_nodes(std::vector<std::shared_ptr<struct ExtractNode> >  &, struct ExtractOpts const &); /*proto*/
static CYTHON_INLINE int __pyx_f_11resiliparse_7extract_9html2text__is_unprintable_pua(lxb_dom_node_t *); /*proto*/
static CYTHON_INLINE int __pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(re2::StringPiece const &, RE2Stack const &); /*proto*/
static CYTHON_INLINE int __pyx_f_11resiliparse_7extract_9html2text__is_link_cluster(lxb_dom_node_t *, double, size_t); /*proto*/
static CYTHON_INLINE int __pyx_f_11resiliparse_7extract_9html2text__is_main_content_node(lxb_dom_node_t *, size_t, int); /*proto*/
static CYTHON_INLINE lxb_status_t __pyx_f_11resiliparse_7extract_9html2text__collect_selected_nodes_cb(lxb_dom_node_t *, lxb_css_selector_specificity_t *, void *); /*proto*/
static std::string __pyx_convert_string_from_py_std__in_string(PyObject *); /*proto*/
static std::set<std::string>  __pyx_convert_set_from_py_std_3a__3a_string(PyObject *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_convert_PyObject_string_to_py_std__in_string(std::string const &); /*proto*/
static CYTHON_INLINE PyObject *__pyx_convert_PyUnicode_string_to_py_std__in_string(std::string const &); /*proto*/
static CYTHON_INLINE PyObject *__pyx_convert_PyStr_string_to_py_std__in_string(std::string const &); /*proto*/
static CYTHON_INLINE PyObject *__pyx_convert_PyBytes_string_to_py_std__in_string(std::string const &); /*proto*/
static CYTHON_INLINE PyObject *__pyx_convert_PyByteArray_string_to_py_std__in_string(std::string const &); /*proto*/
#define __Pyx_MODULE_NAME "resiliparse.extract.html2text"
extern int __pyx_module_is_main_resiliparse__extract__html2text;
int __pyx_module_is_main_resiliparse__extract__html2text = 0;

/* Implementation of 'resiliparse.extract.html2text' */
static PyObject *__pyx_builtin_range;
static const char __pyx_k_[] = "";
static const char __pyx_k_e[] = "e";
static const char __pyx_k_i[] = "i";
static const char __pyx_k__2[] = ",";
static const char __pyx_k_id[] = "id";
static const char __pyx_k_alt[] = "alt";
static const char __pyx_k_ctx[] = "ctx";
static const char __pyx_k_img[] = "img";
static const char __pyx_k_rel[] = "rel";
static const char __pyx_k_svg[] = "svg";
static const char __pyx_k_tab[] = "tab";
static const char __pyx_k_area[] = "area";
static const char __pyx_k_body[] = "body";
static const char __pyx_k_href[] = "href";
static const char __pyx_k_join[] = "join";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_menu[] = "menu";
static const char __pyx_k_name[] = "__name__";
static const char __pyx_k_role[] = "role";
static const char __pyx_k_skip[] = "skip";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_tree[] = "tree";
static const char __pyx_k_type[] = "type";
static const char __pyx_k_alert[] = "alert";
static const char __pyx_k_audio[] = "audio";
static const char __pyx_k_class[] = "class";
static const char __pyx_k_frame[] = "frame";
static const char __pyx_k_input[] = "input";
static const char __pyx_k_label[] = "label";
static const char __pyx_k_links[] = "links";
static const char __pyx_k_pnode[] = "pnode";
static const char __pyx_k_radio[] = "radio";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_style[] = "style";
static const char __pyx_k_value[] = "value";
static const char __pyx_k_video[] = "video";
static const char __pyx_k_banner[] = "banner";
static const char __pyx_k_button[] = "button";
static const char __pyx_k_dialog[] = "dialog";
static const char __pyx_k_encode[] = "encode";
static const char __pyx_k_figure[] = "figure";
static const char __pyx_k_iframe[] = "iframe";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_object[] = "object";
static const char __pyx_k_option[] = "option";
static const char __pyx_k_rstrip[] = "rstrip";
static const char __pyx_k_script[] = "script";
static const char __pyx_k_search[] = "search";
static const char __pyx_k_select[] = "select";
static const char __pyx_k_update[] = "update";
static const char __pyx_k_comment[] = "comment";
static const char __pyx_k_menubar[] = "menubar";
static const char __pyx_k_toolbar[] = "toolbar";
static const char __pyx_k_tooltip[] = "tooltip";
static const char __pyx_k_checkbox[] = "checkbox";
static const char __pyx_k_comments[] = "comments";
static const char __pyx_k_embedimg[] = "embedimg";
static const char __pyx_k_itemprop[] = "itemprop";
static const char __pyx_k_menuitem[] = "menuitem";
static const char __pyx_k_noscript[] = "noscript";
static const char __pyx_k_tag_name[] = "tag_name";
static const char __pyx_k_template[] = "template";
static const char __pyx_k_textarea[] = "textarea";
static const char __pyx_k_alt_texts[] = "alt_texts";
static const char __pyx_k_searchbox[] = "searchbox";
static const char __pyx_k_selectors[] = "selectors";
static const char __pyx_k_separator[] = "separator";
static const char __pyx_k_base_depth[] = "base_depth";
static const char __pyx_k_css_parser[] = "css_parser";
static const char __pyx_k_figcaption[] = "figcaption";
static const char __pyx_k_is_end_tag[] = "is_end_tag";
static const char __pyx_k_navigation[] = "navigation";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_aria_hidden[] = "aria-hidden";
static const char __pyx_k_contentinfo[] = "contentinfo";
static const char __pyx_k_form_fields[] = "form_fields";
static const char __pyx_k_placeholder[] = "placeholder";
static const char __pyx_k_bytes_to_str[] = "bytes_to_str";
static const char __pyx_k_list_bullets[] = "list_bullets";
static const char __pyx_k_main_content[] = "main_content";
static const char __pyx_k_presentation[] = "presentation";
static const char __pyx_k_tag_name_len[] = "tag_name_len";
static const char __pyx_k_tag_name_str[] = "tag_name_str";
static const char __pyx_k_aria_expanded[] = "aria-expanded";
static const char __pyx_k_complementary[] = "complementary";
static const char __pyx_k_css_selectors[] = "css_selectors";
static const char __pyx_k_extract_nodes[] = "extract_nodes";
static const char __pyx_k_selector_list[] = "selector_list";
static const char __pyx_k_skip_elements[] = "skip_elements";
static const char __pyx_k_skip_selectors[] = "skip_selectors";
static const char __pyx_k_combined_skip_sel[] = "combined_skip_sel";
static const char __pyx_k_preselected_nodes[] = "preselected_nodes";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static const char __pyx_k_extract_plain_text[] = "extract_plain_text";
static const char __pyx_k_preserve_formatting[] = "preserve_formatting";
static const char __pyx_k_main_content_selector[] = "main_content_selector";
static const char __pyx_k_resiliparse_parse_encoding[] = "resiliparse.parse.encoding";
static const char __pyx_k_resiliparse_extract_html2text[] = "resiliparse.extract.html2text";
static const char __pyx_k_article_body_articleBody_conten[] = ".article-body, .articleBody, .contentBody, .article-text, .main-content,.postcontent, .post-content, .single-post, [role=\"main\"]";
static const char __pyx_k_resiliparse_extract_html2text_py[] = "resiliparse/extract/html2text.pyx";
static PyObject *__pyx_kp_u_;
static PyObject *__pyx_kp_b__2;
static PyObject *__pyx_n_b_alert;
static PyObject *__pyx_n_s_alt_texts;
static PyObject *__pyx_n_b_area;
static PyObject *__pyx_kp_b_article_body_articleBody_conten;
static PyObject *__pyx_n_b_audio;
static PyObject *__pyx_n_b_banner;
static PyObject *__pyx_n_s_base_depth;
static PyObject *__pyx_n_s_body;
static PyObject *__pyx_n_b_button;
static PyObject *__pyx_n_s_bytes_to_str;
static PyObject *__pyx_n_b_checkbox;
static PyObject *__pyx_n_s_cline_in_traceback;
static PyObject *__pyx_n_s_combined_skip_sel;
static PyObject *__pyx_n_b_comment;
static PyObject *__pyx_n_s_comments;
static PyObject *__pyx_n_b_complementary;
static PyObject *__pyx_n_b_contentinfo;
static PyObject *__pyx_n_s_css_parser;
static PyObject *__pyx_n_s_css_selectors;
static PyObject *__pyx_n_s_ctx;
static PyObject *__pyx_n_b_dialog;
static PyObject *__pyx_n_s_e;
static PyObject *__pyx_n_b_embedimg;
static PyObject *__pyx_n_s_encode;
static PyObject *__pyx_n_s_extract_nodes;
static PyObject *__pyx_n_s_extract_plain_text;
static PyObject *__pyx_n_b_figcaption;
static PyObject *__pyx_n_b_figure;
static PyObject *__pyx_n_s_form_fields;
static PyObject *__pyx_n_b_frame;
static PyObject *__pyx_n_s_i;
static PyObject *__pyx_n_b_iframe;
static PyObject *__pyx_n_b_img;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_b_input;
static PyObject *__pyx_n_s_is_end_tag;
static PyObject *__pyx_n_s_join;
static PyObject *__pyx_n_b_label;
static PyObject *__pyx_n_s_links;
static PyObject *__pyx_n_s_list_bullets;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_main_content;
static PyObject *__pyx_n_s_main_content_selector;
static PyObject *__pyx_n_b_menu;
static PyObject *__pyx_n_b_menubar;
static PyObject *__pyx_n_b_menuitem;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_b_navigation;
static PyObject *__pyx_n_b_noscript;
static PyObject *__pyx_n_s_noscript;
static PyObject *__pyx_n_b_object;
static PyObject *__pyx_n_b_option;
static PyObject *__pyx_n_s_pnode;
static PyObject *__pyx_n_s_preselected_nodes;
static PyObject *__pyx_n_b_presentation;
static PyObject *__pyx_n_s_preserve_formatting;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_b_radio;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_resiliparse_extract_html2text;
static PyObject *__pyx_kp_s_resiliparse_extract_html2text_py;
static PyObject *__pyx_n_s_resiliparse_parse_encoding;
static PyObject *__pyx_n_s_rstrip;
static PyObject *__pyx_n_b_script;
static PyObject *__pyx_n_b_search;
static PyObject *__pyx_n_b_searchbox;
static PyObject *__pyx_n_b_select;
static PyObject *__pyx_n_s_selector_list;
static PyObject *__pyx_n_s_selectors;
static PyObject *__pyx_n_b_separator;
static PyObject *__pyx_n_s_skip;
static PyObject *__pyx_n_s_skip_elements;
static PyObject *__pyx_n_s_skip_selectors;
static PyObject *__pyx_n_b_style;
static PyObject *__pyx_n_b_svg;
static PyObject *__pyx_n_b_tab;
static PyObject *__pyx_n_s_tag_name;
static PyObject *__pyx_n_s_tag_name_len;
static PyObject *__pyx_n_s_tag_name_str;
static PyObject *__pyx_n_b_template;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_b_textarea;
static PyObject *__pyx_n_b_toolbar;
static PyObject *__pyx_n_b_tooltip;
static PyObject *__pyx_n_s_tree;
static PyObject *__pyx_n_s_update;
static PyObject *__pyx_n_b_video;
static PyObject *__pyx_pf_11resiliparse_7extract_9html2text_extract_plain_text(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_11resiliparse_5parse_4html_HTMLTree *__pyx_v_tree, int __pyx_v_preserve_formatting, int __pyx_v_main_content, int __pyx_v_list_bullets, int __pyx_v_alt_texts, int __pyx_v_links, int __pyx_v_form_fields, int __pyx_v_noscript, int __pyx_v_comments, PyObject *__pyx_v_skip_elements); /* proto */
static __Pyx_CachedCFunction __pyx_umethod_PySet_Type_update = {0, &__pyx_n_s_update, 0, 0, 0};
static PyObject *__pyx_tuple__3;
static PyObject *__pyx_codeobj__4;
/* Late includes */

/* "resiliparse/extract/html2text.pyx":89
 * 
 * 
 * cdef string _get_collapsed_string(const string& input_str) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Collapse newlines and consecutive white space in a string to single spaces.
 */

static std::string __pyx_f_11resiliparse_7extract_9html2text__get_collapsed_string(std::string const &__pyx_v_input_str) {
  std::string __pyx_v_element_text;
  size_t __pyx_v_i;
  std::string __pyx_r;
  int __pyx_t_1;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  size_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "resiliparse/extract/html2text.pyx":94
 *     Takes into account previously extracted text from ``ctx.text``.
 *     """
 *     if input_str.empty():             # <<<<<<<<<<<<<<
 *         return input_str
 * 
 */
  __pyx_t_1 = (__pyx_v_input_str.empty() != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":95
 *     """
 *     if input_str.empty():
 *         return input_str             # <<<<<<<<<<<<<<
 * 
 *     cdef string element_text
 */
    __pyx_r = __pyx_v_input_str;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":94
 *     Takes into account previously extracted text from ``ctx.text``.
 *     """
 *     if input_str.empty():             # <<<<<<<<<<<<<<
 *         return input_str
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":98
 * 
 *     cdef string element_text
 *     element_text.reserve(input_str.size())             # <<<<<<<<<<<<<<
 *     for i in range(input_str.size()):
 *         if isspace(input_str[i]):
 */
  try {
    __pyx_v_element_text.reserve(__pyx_v_input_str.size());
  } catch(...) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
    #endif
    __Pyx_CppExn2PyErr();
    #ifdef WITH_THREAD
    __Pyx_PyGILState_Release(__pyx_gilstate_save);
    #endif
    __PYX_ERR(0, 98, __pyx_L1_error)
  }

  /* "resiliparse/extract/html2text.pyx":99
 *     cdef string element_text
 *     element_text.reserve(input_str.size())
 *     for i in range(input_str.size()):             # <<<<<<<<<<<<<<
 *         if isspace(input_str[i]):
 *             if element_text.empty() or not isspace(element_text.back()):
 */
  __pyx_t_2 = __pyx_v_input_str.size();
  __pyx_t_3 = __pyx_t_2;
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_v_i = __pyx_t_4;

    /* "resiliparse/extract/html2text.pyx":100
 *     element_text.reserve(input_str.size())
 *     for i in range(input_str.size()):
 *         if isspace(input_str[i]):             # <<<<<<<<<<<<<<
 *             if element_text.empty() or not isspace(element_text.back()):
 *                 element_text.push_back(b' ')
 */
    __pyx_t_1 = (std::isspace((__pyx_v_input_str[__pyx_v_i])) != 0);
    if (__pyx_t_1) {

      /* "resiliparse/extract/html2text.pyx":101
 *     for i in range(input_str.size()):
 *         if isspace(input_str[i]):
 *             if element_text.empty() or not isspace(element_text.back()):             # <<<<<<<<<<<<<<
 *                 element_text.push_back(b' ')
 *         else:
 */
      __pyx_t_5 = (__pyx_v_element_text.empty() != 0);
      if (!__pyx_t_5) {
      } else {
        __pyx_t_1 = __pyx_t_5;
        goto __pyx_L8_bool_binop_done;
      }
      __pyx_t_5 = ((!(std::isspace(__pyx_v_element_text.back()) != 0)) != 0);
      __pyx_t_1 = __pyx_t_5;
      __pyx_L8_bool_binop_done:;
      if (__pyx_t_1) {

        /* "resiliparse/extract/html2text.pyx":102
 *         if isspace(input_str[i]):
 *             if element_text.empty() or not isspace(element_text.back()):
 *                 element_text.push_back(b' ')             # <<<<<<<<<<<<<<
 *         else:
 *             element_text.push_back(input_str[i])
 */
        try {
          __pyx_v_element_text.push_back(' ');
        } catch(...) {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
          #endif
          __Pyx_CppExn2PyErr();
          #ifdef WITH_THREAD
          __Pyx_PyGILState_Release(__pyx_gilstate_save);
          #endif
          __PYX_ERR(0, 102, __pyx_L1_error)
        }

        /* "resiliparse/extract/html2text.pyx":101
 *     for i in range(input_str.size()):
 *         if isspace(input_str[i]):
 *             if element_text.empty() or not isspace(element_text.back()):             # <<<<<<<<<<<<<<
 *                 element_text.push_back(b' ')
 *         else:
 */
      }

      /* "resiliparse/extract/html2text.pyx":100
 *     element_text.reserve(input_str.size())
 *     for i in range(input_str.size()):
 *         if isspace(input_str[i]):             # <<<<<<<<<<<<<<
 *             if element_text.empty() or not isspace(element_text.back()):
 *                 element_text.push_back(b' ')
 */
      goto __pyx_L6;
    }

    /* "resiliparse/extract/html2text.pyx":104
 *                 element_text.push_back(b' ')
 *         else:
 *             element_text.push_back(input_str[i])             # <<<<<<<<<<<<<<
 * 
 *     return element_text
 */
    /*else*/ {
      try {
        __pyx_v_element_text.push_back((__pyx_v_input_str[__pyx_v_i]));
      } catch(...) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
        #endif
        __Pyx_CppExn2PyErr();
        #ifdef WITH_THREAD
        __Pyx_PyGILState_Release(__pyx_gilstate_save);
        #endif
        __PYX_ERR(0, 104, __pyx_L1_error)
      }
    }
    __pyx_L6:;
  }

  /* "resiliparse/extract/html2text.pyx":106
 *             element_text.push_back(input_str[i])
 * 
 *     return element_text             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_element_text;
  goto __pyx_L0;

  /* "resiliparse/extract/html2text.pyx":89
 * 
 * 
 * cdef string _get_collapsed_string(const string& input_str) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Collapse newlines and consecutive white space in a string to single spaces.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("resiliparse.extract.html2text._get_collapsed_string", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 1);
  __Pyx_pretend_to_initialize(&__pyx_r);
  __pyx_L0:;
  return __pyx_r;
}

/* "resiliparse/extract/html2text.pyx":112
 * 
 * 
 * cdef inline void _ensure_text_contents(vector[shared_ptr[ExtractNode]]& extract_nodes) nogil:             # <<<<<<<<<<<<<<
 *     if not deref(extract_nodes.back()).text_contents:
 *         deref(extract_nodes.back()).text_contents = make_shared[string]()
 */

static CYTHON_INLINE void __pyx_f_11resiliparse_7extract_9html2text__ensure_text_contents(std::vector<std::shared_ptr<struct ExtractNode> >  &__pyx_v_extract_nodes) {
  int __pyx_t_1;
  std::shared_ptr<std::string>  __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "resiliparse/extract/html2text.pyx":113
 * 
 * cdef inline void _ensure_text_contents(vector[shared_ptr[ExtractNode]]& extract_nodes) nogil:
 *     if not deref(extract_nodes.back()).text_contents:             # <<<<<<<<<<<<<<
 *         deref(extract_nodes.back()).text_contents = make_shared[string]()
 * 
 */
  __pyx_t_1 = ((!(*__pyx_v_extract_nodes.back()).text_contents) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":114
 * cdef inline void _ensure_text_contents(vector[shared_ptr[ExtractNode]]& extract_nodes) nogil:
 *     if not deref(extract_nodes.back()).text_contents:
 *         deref(extract_nodes.back()).text_contents = make_shared[string]()             # <<<<<<<<<<<<<<
 * 
 * 
 */
    try {
      __pyx_t_2 = std::make_shared<std::string>();
    } catch(...) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      __Pyx_CppExn2PyErr();
      #ifdef WITH_THREAD
      __Pyx_PyGILState_Release(__pyx_gilstate_save);
      #endif
      __PYX_ERR(0, 114, __pyx_L1_error)
    }
    (*__pyx_v_extract_nodes.back()).text_contents = __pyx_t_2;

    /* "resiliparse/extract/html2text.pyx":113
 * 
 * cdef inline void _ensure_text_contents(vector[shared_ptr[ExtractNode]]& extract_nodes) nogil:
 *     if not deref(extract_nodes.back()).text_contents:             # <<<<<<<<<<<<<<
 *         deref(extract_nodes.back()).text_contents = make_shared[string]()
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":112
 * 
 * 
 * cdef inline void _ensure_text_contents(vector[shared_ptr[ExtractNode]]& extract_nodes) nogil:             # <<<<<<<<<<<<<<
 *     if not deref(extract_nodes.back()).text_contents:
 *         deref(extract_nodes.back()).text_contents = make_shared[string]()
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("resiliparse.extract.html2text._ensure_text_contents", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 1);
  __pyx_L0:;
}

/* "resiliparse/extract/html2text.pyx":117
 * 
 * 
 * cdef inline void _ensure_space(string& in_str, char space_char) nogil:             # <<<<<<<<<<<<<<
 *     if in_str.empty() or not isspace(in_str.back()):
 *         in_str.push_back(space_char)
 */

static CYTHON_INLINE void __pyx_f_11resiliparse_7extract_9html2text__ensure_space(std::string &__pyx_v_in_str, char __pyx_v_space_char) {
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "resiliparse/extract/html2text.pyx":118
 * 
 * cdef inline void _ensure_space(string& in_str, char space_char) nogil:
 *     if in_str.empty() or not isspace(in_str.back()):             # <<<<<<<<<<<<<<
 *         in_str.push_back(space_char)
 * 
 */
  __pyx_t_2 = (__pyx_v_in_str.empty() != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = ((!(std::isspace(__pyx_v_in_str.back()) != 0)) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":119
 * cdef inline void _ensure_space(string& in_str, char space_char) nogil:
 *     if in_str.empty() or not isspace(in_str.back()):
 *         in_str.push_back(space_char)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    try {
      __pyx_v_in_str.push_back(__pyx_v_space_char);
    } catch(...) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      __Pyx_CppExn2PyErr();
      #ifdef WITH_THREAD
      __Pyx_PyGILState_Release(__pyx_gilstate_save);
      #endif
      __PYX_ERR(0, 119, __pyx_L1_error)
    }

    /* "resiliparse/extract/html2text.pyx":118
 * 
 * cdef inline void _ensure_space(string& in_str, char space_char) nogil:
 *     if in_str.empty() or not isspace(in_str.back()):             # <<<<<<<<<<<<<<
 *         in_str.push_back(space_char)
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":117
 * 
 * 
 * cdef inline void _ensure_space(string& in_str, char space_char) nogil:             # <<<<<<<<<<<<<<
 *     if in_str.empty() or not isspace(in_str.back()):
 *         in_str.push_back(space_char)
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("resiliparse.extract.html2text._ensure_space", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 1);
  __pyx_L0:;
}

/* "resiliparse/extract/html2text.pyx":122
 * 
 * 
 * cdef void _extract_cb(vector[shared_ptr[ExtractNode]]& extract_nodes, ExtractContext& ctx, bint is_end_tag) nogil:             # <<<<<<<<<<<<<<
 *     cdef shared_ptr[ExtractNode] last_node_shared
 *     cdef ExtractNode* last_node = NULL
 */

static void __pyx_f_11resiliparse_7extract_9html2text__extract_cb(std::vector<std::shared_ptr<struct ExtractNode> >  &__pyx_v_extract_nodes, struct ExtractContext &__pyx_v_ctx, int __pyx_v_is_end_tag) {
  std::shared_ptr<struct ExtractNode>  __pyx_v_last_node_shared;
  struct ExtractNode *__pyx_v_last_node;
  int __pyx_v_is_block;
  CYTHON_UNUSED lxb_dom_character_data_t *__pyx_v_char_data;
  std::string __pyx_v_element_text;
  std::string_view __pyx_v_element_text_sv;
  lxb_dom_character_data_t *__pyx_v_node_char_data;
  int __pyx_t_1;
  int __pyx_t_2;
  std::shared_ptr<struct ExtractNode>  __pyx_t_3;
  lxb_dom_node_t *__pyx_t_4;
  size_t __pyx_t_5;
  uintptr_t __pyx_t_6;
  int __pyx_t_7;
  std::string_view __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "resiliparse/extract/html2text.pyx":124
 * cdef void _extract_cb(vector[shared_ptr[ExtractNode]]& extract_nodes, ExtractContext& ctx, bint is_end_tag) nogil:
 *     cdef shared_ptr[ExtractNode] last_node_shared
 *     cdef ExtractNode* last_node = NULL             # <<<<<<<<<<<<<<
 *     cdef bint is_block = ctx.node.type == LXB_DOM_NODE_TYPE_ELEMENT and is_block_element(ctx.node.local_name)
 *     if not extract_nodes.empty():
 */
  __pyx_v_last_node = NULL;

  /* "resiliparse/extract/html2text.pyx":125
 *     cdef shared_ptr[ExtractNode] last_node_shared
 *     cdef ExtractNode* last_node = NULL
 *     cdef bint is_block = ctx.node.type == LXB_DOM_NODE_TYPE_ELEMENT and is_block_element(ctx.node.local_name)             # <<<<<<<<<<<<<<
 *     if not extract_nodes.empty():
 *         last_node = extract_nodes.back().get()
 */
  __pyx_t_2 = ((__pyx_v_ctx.node->type == LXB_DOM_NODE_TYPE_ELEMENT) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_2 = (__pyx_f_11resiliparse_5parse_4html_is_block_element(__pyx_v_ctx.node->local_name) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L3_bool_binop_done:;
  __pyx_v_is_block = __pyx_t_1;

  /* "resiliparse/extract/html2text.pyx":126
 *     cdef ExtractNode* last_node = NULL
 *     cdef bint is_block = ctx.node.type == LXB_DOM_NODE_TYPE_ELEMENT and is_block_element(ctx.node.local_name)
 *     if not extract_nodes.empty():             # <<<<<<<<<<<<<<
 *         last_node = extract_nodes.back().get()
 * 
 */
  __pyx_t_1 = ((!(__pyx_v_extract_nodes.empty() != 0)) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":127
 *     cdef bint is_block = ctx.node.type == LXB_DOM_NODE_TYPE_ELEMENT and is_block_element(ctx.node.local_name)
 *     if not extract_nodes.empty():
 *         last_node = extract_nodes.back().get()             # <<<<<<<<<<<<<<
 * 
 *     if not last_node or is_block or ctx.depth < last_node.depth or ctx.node.local_name == LXB_TAG_TEXTAREA:
 */
    __pyx_v_last_node = __pyx_v_extract_nodes.back().get();

    /* "resiliparse/extract/html2text.pyx":126
 *     cdef ExtractNode* last_node = NULL
 *     cdef bint is_block = ctx.node.type == LXB_DOM_NODE_TYPE_ELEMENT and is_block_element(ctx.node.local_name)
 *     if not extract_nodes.empty():             # <<<<<<<<<<<<<<
 *         last_node = extract_nodes.back().get()
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":129
 *         last_node = extract_nodes.back().get()
 * 
 *     if not last_node or is_block or ctx.depth < last_node.depth or ctx.node.local_name == LXB_TAG_TEXTAREA:             # <<<<<<<<<<<<<<
 *         last_node_shared = make_shared[ExtractNode]()
 *         extract_nodes.push_back(last_node_shared)
 */
  __pyx_t_2 = ((!(__pyx_v_last_node != 0)) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_2 = (__pyx_v_is_block != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_ctx.depth < __pyx_v_last_node->depth) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_ctx.node->local_name == LXB_TAG_TEXTAREA) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L7_bool_binop_done:;
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":130
 * 
 *     if not last_node or is_block or ctx.depth < last_node.depth or ctx.node.local_name == LXB_TAG_TEXTAREA:
 *         last_node_shared = make_shared[ExtractNode]()             # <<<<<<<<<<<<<<
 *         extract_nodes.push_back(last_node_shared)
 *         last_node = extract_nodes.back().get()
 */
    try {
      __pyx_t_3 = std::make_shared<struct ExtractNode>();
    } catch(...) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      __Pyx_CppExn2PyErr();
      #ifdef WITH_THREAD
      __Pyx_PyGILState_Release(__pyx_gilstate_save);
      #endif
      __PYX_ERR(0, 130, __pyx_L1_error)
    }
    __pyx_v_last_node_shared = __pyx_t_3;

    /* "resiliparse/extract/html2text.pyx":131
 *     if not last_node or is_block or ctx.depth < last_node.depth or ctx.node.local_name == LXB_TAG_TEXTAREA:
 *         last_node_shared = make_shared[ExtractNode]()
 *         extract_nodes.push_back(last_node_shared)             # <<<<<<<<<<<<<<
 *         last_node = extract_nodes.back().get()
 *         last_node.reference_node = ctx.node
 */
    try {
      __pyx_v_extract_nodes.push_back(__pyx_v_last_node_shared);
    } catch(...) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      __Pyx_CppExn2PyErr();
      #ifdef WITH_THREAD
      __Pyx_PyGILState_Release(__pyx_gilstate_save);
      #endif
      __PYX_ERR(0, 131, __pyx_L1_error)
    }

    /* "resiliparse/extract/html2text.pyx":132
 *         last_node_shared = make_shared[ExtractNode]()
 *         extract_nodes.push_back(last_node_shared)
 *         last_node = extract_nodes.back().get()             # <<<<<<<<<<<<<<
 *         last_node.reference_node = ctx.node
 *         last_node.depth = ctx.depth
 */
    __pyx_v_last_node = __pyx_v_extract_nodes.back().get();

    /* "resiliparse/extract/html2text.pyx":133
 *         extract_nodes.push_back(last_node_shared)
 *         last_node = extract_nodes.back().get()
 *         last_node.reference_node = ctx.node             # <<<<<<<<<<<<<<
 *         last_node.depth = ctx.depth
 *         last_node.is_big_block = ctx.node.local_name in [LXB_TAG_P, LXB_TAG_H1, LXB_TAG_H2, LXB_TAG_H3, LXB_TAG_H4]
 */
    __pyx_t_4 = __pyx_v_ctx.node;
    __pyx_v_last_node->reference_node = __pyx_t_4;

    /* "resiliparse/extract/html2text.pyx":134
 *         last_node = extract_nodes.back().get()
 *         last_node.reference_node = ctx.node
 *         last_node.depth = ctx.depth             # <<<<<<<<<<<<<<
 *         last_node.is_big_block = ctx.node.local_name in [LXB_TAG_P, LXB_TAG_H1, LXB_TAG_H2, LXB_TAG_H3, LXB_TAG_H4]
 *         last_node.tag_id = ctx.node.local_name
 */
    __pyx_t_5 = __pyx_v_ctx.depth;
    __pyx_v_last_node->depth = __pyx_t_5;

    /* "resiliparse/extract/html2text.pyx":135
 *         last_node.reference_node = ctx.node
 *         last_node.depth = ctx.depth
 *         last_node.is_big_block = ctx.node.local_name in [LXB_TAG_P, LXB_TAG_H1, LXB_TAG_H2, LXB_TAG_H3, LXB_TAG_H4]             # <<<<<<<<<<<<<<
 *         last_node.tag_id = ctx.node.local_name
 *         last_node.is_pre = not is_end_tag and ctx.node.local_name in [LXB_TAG_PRE, LXB_TAG_TEXTAREA]
 */
    switch (__pyx_v_ctx.node->local_name) {
      case LXB_TAG_P:
      case LXB_TAG_H1:
      case LXB_TAG_H2:
      case LXB_TAG_H3:
      case LXB_TAG_H4:
      __pyx_t_1 = 1;
      break;
      default:
      __pyx_t_1 = 0;
      break;
    }
    __pyx_v_last_node->is_big_block = __pyx_t_1;

    /* "resiliparse/extract/html2text.pyx":136
 *         last_node.depth = ctx.depth
 *         last_node.is_big_block = ctx.node.local_name in [LXB_TAG_P, LXB_TAG_H1, LXB_TAG_H2, LXB_TAG_H3, LXB_TAG_H4]
 *         last_node.tag_id = ctx.node.local_name             # <<<<<<<<<<<<<<
 *         last_node.is_pre = not is_end_tag and ctx.node.local_name in [LXB_TAG_PRE, LXB_TAG_TEXTAREA]
 *         last_node.is_end_tag = is_end_tag
 */
    __pyx_t_6 = __pyx_v_ctx.node->local_name;
    __pyx_v_last_node->tag_id = __pyx_t_6;

    /* "resiliparse/extract/html2text.pyx":137
 *         last_node.is_big_block = ctx.node.local_name in [LXB_TAG_P, LXB_TAG_H1, LXB_TAG_H2, LXB_TAG_H3, LXB_TAG_H4]
 *         last_node.tag_id = ctx.node.local_name
 *         last_node.is_pre = not is_end_tag and ctx.node.local_name in [LXB_TAG_PRE, LXB_TAG_TEXTAREA]             # <<<<<<<<<<<<<<
 *         last_node.is_end_tag = is_end_tag
 * 
 */
    __pyx_t_2 = ((!(__pyx_v_is_end_tag != 0)) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L11_bool_binop_done;
    }
    switch (__pyx_v_ctx.node->local_name) {
      case LXB_TAG_PRE:
      case LXB_TAG_TEXTAREA:
      __pyx_t_2 = 1;
      break;
      default:
      __pyx_t_2 = 0;
      break;
    }
    __pyx_t_7 = (__pyx_t_2 != 0);
    __pyx_t_1 = __pyx_t_7;
    __pyx_L11_bool_binop_done:;
    __pyx_v_last_node->is_pre = __pyx_t_1;

    /* "resiliparse/extract/html2text.pyx":138
 *         last_node.tag_id = ctx.node.local_name
 *         last_node.is_pre = not is_end_tag and ctx.node.local_name in [LXB_TAG_PRE, LXB_TAG_TEXTAREA]
 *         last_node.is_end_tag = is_end_tag             # <<<<<<<<<<<<<<
 * 
 *     cdef lxb_dom_character_data_t* char_data = NULL
 */
    __pyx_v_last_node->is_end_tag = __pyx_v_is_end_tag;

    /* "resiliparse/extract/html2text.pyx":129
 *         last_node = extract_nodes.back().get()
 * 
 *     if not last_node or is_block or ctx.depth < last_node.depth or ctx.node.local_name == LXB_TAG_TEXTAREA:             # <<<<<<<<<<<<<<
 *         last_node_shared = make_shared[ExtractNode]()
 *         extract_nodes.push_back(last_node_shared)
 */
  }

  /* "resiliparse/extract/html2text.pyx":140
 *         last_node.is_end_tag = is_end_tag
 * 
 *     cdef lxb_dom_character_data_t* char_data = NULL             # <<<<<<<<<<<<<<
 *     cdef string element_text
 *     cdef string_view element_text_sv
 */
  __pyx_v_char_data = NULL;

  /* "resiliparse/extract/html2text.pyx":144
 *     cdef string_view element_text_sv
 * 
 *     if ctx.node.type == LXB_DOM_NODE_TYPE_TEXT:             # <<<<<<<<<<<<<<
 *         _ensure_text_contents(extract_nodes)
 *         node_char_data = <lxb_dom_character_data_t*>ctx.node
 */
  __pyx_t_1 = ((__pyx_v_ctx.node->type == LXB_DOM_NODE_TYPE_TEXT) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":145
 * 
 *     if ctx.node.type == LXB_DOM_NODE_TYPE_TEXT:
 *         _ensure_text_contents(extract_nodes)             # <<<<<<<<<<<<<<
 *         node_char_data = <lxb_dom_character_data_t*>ctx.node
 *         element_text_sv = string_view(<const char*>node_char_data.data.data, node_char_data.data.length)
 */
    __pyx_f_11resiliparse_7extract_9html2text__ensure_text_contents(__pyx_v_extract_nodes);

    /* "resiliparse/extract/html2text.pyx":146
 *     if ctx.node.type == LXB_DOM_NODE_TYPE_TEXT:
 *         _ensure_text_contents(extract_nodes)
 *         node_char_data = <lxb_dom_character_data_t*>ctx.node             # <<<<<<<<<<<<<<
 *         element_text_sv = string_view(<const char*>node_char_data.data.data, node_char_data.data.length)
 *         if last_node.is_pre and ctx.opts.preserve_formatting:
 */
    __pyx_v_node_char_data = ((lxb_dom_character_data_t *)__pyx_v_ctx.node);

    /* "resiliparse/extract/html2text.pyx":147
 *         _ensure_text_contents(extract_nodes)
 *         node_char_data = <lxb_dom_character_data_t*>ctx.node
 *         element_text_sv = string_view(<const char*>node_char_data.data.data, node_char_data.data.length)             # <<<<<<<<<<<<<<
 *         if last_node.is_pre and ctx.opts.preserve_formatting:
 *             deref(last_node.text_contents).append(<string>element_text_sv)
 */
    __pyx_v_element_text_sv = std::string_view(((char const *)__pyx_v_node_char_data->data.data), __pyx_v_node_char_data->data.length);

    /* "resiliparse/extract/html2text.pyx":148
 *         node_char_data = <lxb_dom_character_data_t*>ctx.node
 *         element_text_sv = string_view(<const char*>node_char_data.data.data, node_char_data.data.length)
 *         if last_node.is_pre and ctx.opts.preserve_formatting:             # <<<<<<<<<<<<<<
 *             deref(last_node.text_contents).append(<string>element_text_sv)
 *         else:
 */
    __pyx_t_7 = (__pyx_v_last_node->is_pre != 0);
    if (__pyx_t_7) {
    } else {
      __pyx_t_1 = __pyx_t_7;
      goto __pyx_L15_bool_binop_done;
    }
    __pyx_t_7 = (__pyx_v_ctx.opts.preserve_formatting != 0);
    __pyx_t_1 = __pyx_t_7;
    __pyx_L15_bool_binop_done:;
    if (__pyx_t_1) {

      /* "resiliparse/extract/html2text.pyx":149
 *         element_text_sv = string_view(<const char*>node_char_data.data.data, node_char_data.data.length)
 *         if last_node.is_pre and ctx.opts.preserve_formatting:
 *             deref(last_node.text_contents).append(<string>element_text_sv)             # <<<<<<<<<<<<<<
 *         else:
 *             element_text = _get_collapsed_string(<string>element_text_sv)
 */
      try {
        (*__pyx_v_last_node->text_contents).append(((std::string)__pyx_v_element_text_sv));
      } catch(...) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
        #endif
        __Pyx_CppExn2PyErr();
        #ifdef WITH_THREAD
        __Pyx_PyGILState_Release(__pyx_gilstate_save);
        #endif
        __PYX_ERR(0, 149, __pyx_L1_error)
      }

      /* "resiliparse/extract/html2text.pyx":148
 *         node_char_data = <lxb_dom_character_data_t*>ctx.node
 *         element_text_sv = string_view(<const char*>node_char_data.data.data, node_char_data.data.length)
 *         if last_node.is_pre and ctx.opts.preserve_formatting:             # <<<<<<<<<<<<<<
 *             deref(last_node.text_contents).append(<string>element_text_sv)
 *         else:
 */
      goto __pyx_L14;
    }

    /* "resiliparse/extract/html2text.pyx":151
 *             deref(last_node.text_contents).append(<string>element_text_sv)
 *         else:
 *             element_text = _get_collapsed_string(<string>element_text_sv)             # <<<<<<<<<<<<<<
 *             element_text_sv = <string_view>element_text
 *             if deref(last_node.text_contents).empty() or isspace(deref(last_node.text_contents).back()):
 */
    /*else*/ {
      __pyx_v_element_text = __pyx_f_11resiliparse_7extract_9html2text__get_collapsed_string(((std::string)__pyx_v_element_text_sv));

      /* "resiliparse/extract/html2text.pyx":152
 *         else:
 *             element_text = _get_collapsed_string(<string>element_text_sv)
 *             element_text_sv = <string_view>element_text             # <<<<<<<<<<<<<<
 *             if deref(last_node.text_contents).empty() or isspace(deref(last_node.text_contents).back()):
 *                 while not element_text_sv.empty() and isspace(element_text_sv.front()):
 */
      __pyx_v_element_text_sv = ((std::string_view)__pyx_v_element_text);

      /* "resiliparse/extract/html2text.pyx":153
 *             element_text = _get_collapsed_string(<string>element_text_sv)
 *             element_text_sv = <string_view>element_text
 *             if deref(last_node.text_contents).empty() or isspace(deref(last_node.text_contents).back()):             # <<<<<<<<<<<<<<
 *                 while not element_text_sv.empty() and isspace(element_text_sv.front()):
 *                     element_text_sv.remove_prefix(1)
 */
      __pyx_t_7 = ((*__pyx_v_last_node->text_contents).empty() != 0);
      if (!__pyx_t_7) {
      } else {
        __pyx_t_1 = __pyx_t_7;
        goto __pyx_L18_bool_binop_done;
      }
      __pyx_t_7 = (std::isspace((*__pyx_v_last_node->text_contents).back()) != 0);
      __pyx_t_1 = __pyx_t_7;
      __pyx_L18_bool_binop_done:;
      if (__pyx_t_1) {

        /* "resiliparse/extract/html2text.pyx":154
 *             element_text_sv = <string_view>element_text
 *             if deref(last_node.text_contents).empty() or isspace(deref(last_node.text_contents).back()):
 *                 while not element_text_sv.empty() and isspace(element_text_sv.front()):             # <<<<<<<<<<<<<<
 *                     element_text_sv.remove_prefix(1)
 *             if not element_text_sv.empty():
 */
        while (1) {
          __pyx_t_7 = ((!(__pyx_v_element_text_sv.empty() != 0)) != 0);
          if (__pyx_t_7) {
          } else {
            __pyx_t_1 = __pyx_t_7;
            goto __pyx_L22_bool_binop_done;
          }
          __pyx_t_7 = (std::isspace(__pyx_v_element_text_sv.front()) != 0);
          __pyx_t_1 = __pyx_t_7;
          __pyx_L22_bool_binop_done:;
          if (!__pyx_t_1) break;

          /* "resiliparse/extract/html2text.pyx":155
 *             if deref(last_node.text_contents).empty() or isspace(deref(last_node.text_contents).back()):
 *                 while not element_text_sv.empty() and isspace(element_text_sv.front()):
 *                     element_text_sv.remove_prefix(1)             # <<<<<<<<<<<<<<
 *             if not element_text_sv.empty():
 *                 deref(last_node.text_contents).append(<string>element_text_sv)
 */
          (void)(__pyx_v_element_text_sv.remove_prefix(1));
        }

        /* "resiliparse/extract/html2text.pyx":153
 *             element_text = _get_collapsed_string(<string>element_text_sv)
 *             element_text_sv = <string_view>element_text
 *             if deref(last_node.text_contents).empty() or isspace(deref(last_node.text_contents).back()):             # <<<<<<<<<<<<<<
 *                 while not element_text_sv.empty() and isspace(element_text_sv.front()):
 *                     element_text_sv.remove_prefix(1)
 */
      }

      /* "resiliparse/extract/html2text.pyx":156
 *                 while not element_text_sv.empty() and isspace(element_text_sv.front()):
 *                     element_text_sv.remove_prefix(1)
 *             if not element_text_sv.empty():             # <<<<<<<<<<<<<<
 *                 deref(last_node.text_contents).append(<string>element_text_sv)
 * 
 */
      __pyx_t_1 = ((!(__pyx_v_element_text_sv.empty() != 0)) != 0);
      if (__pyx_t_1) {

        /* "resiliparse/extract/html2text.pyx":157
 *                     element_text_sv.remove_prefix(1)
 *             if not element_text_sv.empty():
 *                 deref(last_node.text_contents).append(<string>element_text_sv)             # <<<<<<<<<<<<<<
 * 
 *     elif ctx.node.type != LXB_DOM_NODE_TYPE_ELEMENT:
 */
        try {
          (*__pyx_v_last_node->text_contents).append(((std::string)__pyx_v_element_text_sv));
        } catch(...) {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
          #endif
          __Pyx_CppExn2PyErr();
          #ifdef WITH_THREAD
          __Pyx_PyGILState_Release(__pyx_gilstate_save);
          #endif
          __PYX_ERR(0, 157, __pyx_L1_error)
        }

        /* "resiliparse/extract/html2text.pyx":156
 *                 while not element_text_sv.empty() and isspace(element_text_sv.front()):
 *                     element_text_sv.remove_prefix(1)
 *             if not element_text_sv.empty():             # <<<<<<<<<<<<<<
 *                 deref(last_node.text_contents).append(<string>element_text_sv)
 * 
 */
      }
    }
    __pyx_L14:;

    /* "resiliparse/extract/html2text.pyx":144
 *     cdef string_view element_text_sv
 * 
 *     if ctx.node.type == LXB_DOM_NODE_TYPE_TEXT:             # <<<<<<<<<<<<<<
 *         _ensure_text_contents(extract_nodes)
 *         node_char_data = <lxb_dom_character_data_t*>ctx.node
 */
    goto __pyx_L13;
  }

  /* "resiliparse/extract/html2text.pyx":159
 *                 deref(last_node.text_contents).append(<string>element_text_sv)
 * 
 *     elif ctx.node.type != LXB_DOM_NODE_TYPE_ELEMENT:             # <<<<<<<<<<<<<<
 *         return
 * 
 */
  __pyx_t_1 = ((__pyx_v_ctx.node->type != LXB_DOM_NODE_TYPE_ELEMENT) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":160
 * 
 *     elif ctx.node.type != LXB_DOM_NODE_TYPE_ELEMENT:
 *         return             # <<<<<<<<<<<<<<
 * 
 *     elif ctx.node.local_name in [LXB_TAG_BR, LXB_TAG_HR]:
 */
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":159
 *                 deref(last_node.text_contents).append(<string>element_text_sv)
 * 
 *     elif ctx.node.type != LXB_DOM_NODE_TYPE_ELEMENT:             # <<<<<<<<<<<<<<
 *         return
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":162
 *         return
 * 
 *     elif ctx.node.local_name in [LXB_TAG_BR, LXB_TAG_HR]:             # <<<<<<<<<<<<<<
 *         _ensure_text_contents(extract_nodes)
 *         last_node.collapse_margins = False
 */
  switch (__pyx_v_ctx.node->local_name) {
    case LXB_TAG_BR:
    case LXB_TAG_HR:
    __pyx_t_1 = 1;
    break;
    default:
    __pyx_t_1 = 0;
    break;
  }
  __pyx_t_7 = (__pyx_t_1 != 0);
  if (__pyx_t_7) {

    /* "resiliparse/extract/html2text.pyx":163
 * 
 *     elif ctx.node.local_name in [LXB_TAG_BR, LXB_TAG_HR]:
 *         _ensure_text_contents(extract_nodes)             # <<<<<<<<<<<<<<
 *         last_node.collapse_margins = False
 * 
 */
    __pyx_f_11resiliparse_7extract_9html2text__ensure_text_contents(__pyx_v_extract_nodes);

    /* "resiliparse/extract/html2text.pyx":164
 *     elif ctx.node.local_name in [LXB_TAG_BR, LXB_TAG_HR]:
 *         _ensure_text_contents(extract_nodes)
 *         last_node.collapse_margins = False             # <<<<<<<<<<<<<<
 * 
 *     elif ctx.opts.links and is_end_tag and ctx.node.local_name == LXB_TAG_A:
 */
    __pyx_v_last_node->collapse_margins = 0;

    /* "resiliparse/extract/html2text.pyx":162
 *         return
 * 
 *     elif ctx.node.local_name in [LXB_TAG_BR, LXB_TAG_HR]:             # <<<<<<<<<<<<<<
 *         _ensure_text_contents(extract_nodes)
 *         last_node.collapse_margins = False
 */
    goto __pyx_L13;
  }

  /* "resiliparse/extract/html2text.pyx":166
 *         last_node.collapse_margins = False
 * 
 *     elif ctx.opts.links and is_end_tag and ctx.node.local_name == LXB_TAG_A:             # <<<<<<<<<<<<<<
 *         element_text_sv = <string>get_node_attr_sv(ctx.node, b'href')
 *         if not element_text_sv.empty():
 */
  __pyx_t_1 = (__pyx_v_ctx.opts.links != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_7 = __pyx_t_1;
    goto __pyx_L25_bool_binop_done;
  }
  __pyx_t_1 = (__pyx_v_is_end_tag != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_7 = __pyx_t_1;
    goto __pyx_L25_bool_binop_done;
  }
  __pyx_t_1 = ((__pyx_v_ctx.node->local_name == LXB_TAG_A) != 0);
  __pyx_t_7 = __pyx_t_1;
  __pyx_L25_bool_binop_done:;
  if (__pyx_t_7) {

    /* "resiliparse/extract/html2text.pyx":167
 * 
 *     elif ctx.opts.links and is_end_tag and ctx.node.local_name == LXB_TAG_A:
 *         element_text_sv = <string>get_node_attr_sv(ctx.node, b'href')             # <<<<<<<<<<<<<<
 *         if not element_text_sv.empty():
 *             element_text.append(b' (')
 */
    __pyx_v_element_text_sv = ((std::string)__pyx_f_11resiliparse_5parse_4html_get_node_attr_sv(__pyx_v_ctx.node, __pyx_k_href));

    /* "resiliparse/extract/html2text.pyx":168
 *     elif ctx.opts.links and is_end_tag and ctx.node.local_name == LXB_TAG_A:
 *         element_text_sv = <string>get_node_attr_sv(ctx.node, b'href')
 *         if not element_text_sv.empty():             # <<<<<<<<<<<<<<
 *             element_text.append(b' (')
 *             element_text.append(<string> element_text_sv)
 */
    __pyx_t_7 = ((!(__pyx_v_element_text_sv.empty() != 0)) != 0);
    if (__pyx_t_7) {

      /* "resiliparse/extract/html2text.pyx":169
 *         element_text_sv = <string>get_node_attr_sv(ctx.node, b'href')
 *         if not element_text_sv.empty():
 *             element_text.append(b' (')             # <<<<<<<<<<<<<<
 *             element_text.append(<string> element_text_sv)
 *             element_text.append(b') ')
 */
      try {
        __pyx_v_element_text.append(((char const *)" ("));
      } catch(...) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
        #endif
        __Pyx_CppExn2PyErr();
        #ifdef WITH_THREAD
        __Pyx_PyGILState_Release(__pyx_gilstate_save);
        #endif
        __PYX_ERR(0, 169, __pyx_L1_error)
      }

      /* "resiliparse/extract/html2text.pyx":170
 *         if not element_text_sv.empty():
 *             element_text.append(b' (')
 *             element_text.append(<string> element_text_sv)             # <<<<<<<<<<<<<<
 *             element_text.append(b') ')
 *             _ensure_text_contents(extract_nodes)
 */
      try {
        __pyx_v_element_text.append(((std::string)__pyx_v_element_text_sv));
      } catch(...) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
        #endif
        __Pyx_CppExn2PyErr();
        #ifdef WITH_THREAD
        __Pyx_PyGILState_Release(__pyx_gilstate_save);
        #endif
        __PYX_ERR(0, 170, __pyx_L1_error)
      }

      /* "resiliparse/extract/html2text.pyx":171
 *             element_text.append(b' (')
 *             element_text.append(<string> element_text_sv)
 *             element_text.append(b') ')             # <<<<<<<<<<<<<<
 *             _ensure_text_contents(extract_nodes)
 *             deref(last_node.text_contents).append(element_text)
 */
      try {
        __pyx_v_element_text.append(((char const *)") "));
      } catch(...) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
        #endif
        __Pyx_CppExn2PyErr();
        #ifdef WITH_THREAD
        __Pyx_PyGILState_Release(__pyx_gilstate_save);
        #endif
        __PYX_ERR(0, 171, __pyx_L1_error)
      }

      /* "resiliparse/extract/html2text.pyx":172
 *             element_text.append(<string> element_text_sv)
 *             element_text.append(b') ')
 *             _ensure_text_contents(extract_nodes)             # <<<<<<<<<<<<<<
 *             deref(last_node.text_contents).append(element_text)
 * 
 */
      __pyx_f_11resiliparse_7extract_9html2text__ensure_text_contents(__pyx_v_extract_nodes);

      /* "resiliparse/extract/html2text.pyx":173
 *             element_text.append(b') ')
 *             _ensure_text_contents(extract_nodes)
 *             deref(last_node.text_contents).append(element_text)             # <<<<<<<<<<<<<<
 * 
 *     elif ctx.opts.alt_texts and ctx.node.local_name in [LXB_TAG_IMG, LXB_TAG_AREA]:
 */
      try {
        (*__pyx_v_last_node->text_contents).append(__pyx_v_element_text);
      } catch(...) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
        #endif
        __Pyx_CppExn2PyErr();
        #ifdef WITH_THREAD
        __Pyx_PyGILState_Release(__pyx_gilstate_save);
        #endif
        __PYX_ERR(0, 173, __pyx_L1_error)
      }

      /* "resiliparse/extract/html2text.pyx":168
 *     elif ctx.opts.links and is_end_tag and ctx.node.local_name == LXB_TAG_A:
 *         element_text_sv = <string>get_node_attr_sv(ctx.node, b'href')
 *         if not element_text_sv.empty():             # <<<<<<<<<<<<<<
 *             element_text.append(b' (')
 *             element_text.append(<string> element_text_sv)
 */
    }

    /* "resiliparse/extract/html2text.pyx":166
 *         last_node.collapse_margins = False
 * 
 *     elif ctx.opts.links and is_end_tag and ctx.node.local_name == LXB_TAG_A:             # <<<<<<<<<<<<<<
 *         element_text_sv = <string>get_node_attr_sv(ctx.node, b'href')
 *         if not element_text_sv.empty():
 */
    goto __pyx_L13;
  }

  /* "resiliparse/extract/html2text.pyx":175
 *             deref(last_node.text_contents).append(element_text)
 * 
 *     elif ctx.opts.alt_texts and ctx.node.local_name in [LXB_TAG_IMG, LXB_TAG_AREA]:             # <<<<<<<<<<<<<<
 *         _ensure_text_contents(extract_nodes)
 *         element_text_sv = get_node_attr_sv(ctx.node, b'alt')
 */
  __pyx_t_1 = (__pyx_v_ctx.opts.alt_texts != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_7 = __pyx_t_1;
    goto __pyx_L29_bool_binop_done;
  }
  switch (__pyx_v_ctx.node->local_name) {
    case LXB_TAG_IMG:
    case LXB_TAG_AREA:
    __pyx_t_1 = 1;
    break;
    default:
    __pyx_t_1 = 0;
    break;
  }
  __pyx_t_2 = (__pyx_t_1 != 0);
  __pyx_t_7 = __pyx_t_2;
  __pyx_L29_bool_binop_done:;
  if (__pyx_t_7) {

    /* "resiliparse/extract/html2text.pyx":176
 * 
 *     elif ctx.opts.alt_texts and ctx.node.local_name in [LXB_TAG_IMG, LXB_TAG_AREA]:
 *         _ensure_text_contents(extract_nodes)             # <<<<<<<<<<<<<<
 *         element_text_sv = get_node_attr_sv(ctx.node, b'alt')
 *         if not element_text_sv.empty():
 */
    __pyx_f_11resiliparse_7extract_9html2text__ensure_text_contents(__pyx_v_extract_nodes);

    /* "resiliparse/extract/html2text.pyx":177
 *     elif ctx.opts.alt_texts and ctx.node.local_name in [LXB_TAG_IMG, LXB_TAG_AREA]:
 *         _ensure_text_contents(extract_nodes)
 *         element_text_sv = get_node_attr_sv(ctx.node, b'alt')             # <<<<<<<<<<<<<<
 *         if not element_text_sv.empty():
 *             deref(last_node.text_contents).append(<string>element_text_sv)
 */
    __pyx_v_element_text_sv = __pyx_f_11resiliparse_5parse_4html_get_node_attr_sv(__pyx_v_ctx.node, __pyx_k_alt);

    /* "resiliparse/extract/html2text.pyx":178
 *         _ensure_text_contents(extract_nodes)
 *         element_text_sv = get_node_attr_sv(ctx.node, b'alt')
 *         if not element_text_sv.empty():             # <<<<<<<<<<<<<<
 *             deref(last_node.text_contents).append(<string>element_text_sv)
 * 
 */
    __pyx_t_7 = ((!(__pyx_v_element_text_sv.empty() != 0)) != 0);
    if (__pyx_t_7) {

      /* "resiliparse/extract/html2text.pyx":179
 *         element_text_sv = get_node_attr_sv(ctx.node, b'alt')
 *         if not element_text_sv.empty():
 *             deref(last_node.text_contents).append(<string>element_text_sv)             # <<<<<<<<<<<<<<
 * 
 *     elif ctx.opts.form_fields and ctx.node.local_name in [LXB_TAG_TEXTAREA, LXB_TAG_BUTTON]:
 */
      try {
        (*__pyx_v_last_node->text_contents).append(((std::string)__pyx_v_element_text_sv));
      } catch(...) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
        #endif
        __Pyx_CppExn2PyErr();
        #ifdef WITH_THREAD
        __Pyx_PyGILState_Release(__pyx_gilstate_save);
        #endif
        __PYX_ERR(0, 179, __pyx_L1_error)
      }

      /* "resiliparse/extract/html2text.pyx":178
 *         _ensure_text_contents(extract_nodes)
 *         element_text_sv = get_node_attr_sv(ctx.node, b'alt')
 *         if not element_text_sv.empty():             # <<<<<<<<<<<<<<
 *             deref(last_node.text_contents).append(<string>element_text_sv)
 * 
 */
    }

    /* "resiliparse/extract/html2text.pyx":175
 *             deref(last_node.text_contents).append(element_text)
 * 
 *     elif ctx.opts.alt_texts and ctx.node.local_name in [LXB_TAG_IMG, LXB_TAG_AREA]:             # <<<<<<<<<<<<<<
 *         _ensure_text_contents(extract_nodes)
 *         element_text_sv = get_node_attr_sv(ctx.node, b'alt')
 */
    goto __pyx_L13;
  }

  /* "resiliparse/extract/html2text.pyx":181
 *             deref(last_node.text_contents).append(<string>element_text_sv)
 * 
 *     elif ctx.opts.form_fields and ctx.node.local_name in [LXB_TAG_TEXTAREA, LXB_TAG_BUTTON]:             # <<<<<<<<<<<<<<
 *         if not is_end_tag:
 *             element_text.append(b'[ ')
 */
  __pyx_t_2 = (__pyx_v_ctx.opts.form_fields != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_7 = __pyx_t_2;
    goto __pyx_L32_bool_binop_done;
  }
  switch (__pyx_v_ctx.node->local_name) {
    case LXB_TAG_TEXTAREA:
    case LXB_TAG_BUTTON:
    __pyx_t_2 = 1;
    break;
    default:
    __pyx_t_2 = 0;
    break;
  }
  __pyx_t_1 = (__pyx_t_2 != 0);
  __pyx_t_7 = __pyx_t_1;
  __pyx_L32_bool_binop_done:;
  if (__pyx_t_7) {

    /* "resiliparse/extract/html2text.pyx":182
 * 
 *     elif ctx.opts.form_fields and ctx.node.local_name in [LXB_TAG_TEXTAREA, LXB_TAG_BUTTON]:
 *         if not is_end_tag:             # <<<<<<<<<<<<<<
 *             element_text.append(b'[ ')
 *         else:
 */
    __pyx_t_7 = ((!(__pyx_v_is_end_tag != 0)) != 0);
    if (__pyx_t_7) {

      /* "resiliparse/extract/html2text.pyx":183
 *     elif ctx.opts.form_fields and ctx.node.local_name in [LXB_TAG_TEXTAREA, LXB_TAG_BUTTON]:
 *         if not is_end_tag:
 *             element_text.append(b'[ ')             # <<<<<<<<<<<<<<
 *         else:
 *             element_text.append(b' ]')
 */
      try {
        __pyx_v_element_text.append(((char const *)"[ "));
      } catch(...) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
        #endif
        __Pyx_CppExn2PyErr();
        #ifdef WITH_THREAD
        __Pyx_PyGILState_Release(__pyx_gilstate_save);
        #endif
        __PYX_ERR(0, 183, __pyx_L1_error)
      }

      /* "resiliparse/extract/html2text.pyx":182
 * 
 *     elif ctx.opts.form_fields and ctx.node.local_name in [LXB_TAG_TEXTAREA, LXB_TAG_BUTTON]:
 *         if not is_end_tag:             # <<<<<<<<<<<<<<
 *             element_text.append(b'[ ')
 *         else:
 */
      goto __pyx_L34;
    }

    /* "resiliparse/extract/html2text.pyx":185
 *             element_text.append(b'[ ')
 *         else:
 *             element_text.append(b' ]')             # <<<<<<<<<<<<<<
 *         _ensure_text_contents(extract_nodes)
 *         deref(last_node.text_contents).append(element_text)
 */
    /*else*/ {
      try {
        __pyx_v_element_text.append(((char const *)" ]"));
      } catch(...) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
        #endif
        __Pyx_CppExn2PyErr();
        #ifdef WITH_THREAD
        __Pyx_PyGILState_Release(__pyx_gilstate_save);
        #endif
        __PYX_ERR(0, 185, __pyx_L1_error)
      }
    }
    __pyx_L34:;

    /* "resiliparse/extract/html2text.pyx":186
 *         else:
 *             element_text.append(b' ]')
 *         _ensure_text_contents(extract_nodes)             # <<<<<<<<<<<<<<
 *         deref(last_node.text_contents).append(element_text)
 *         return
 */
    __pyx_f_11resiliparse_7extract_9html2text__ensure_text_contents(__pyx_v_extract_nodes);

    /* "resiliparse/extract/html2text.pyx":187
 *             element_text.append(b' ]')
 *         _ensure_text_contents(extract_nodes)
 *         deref(last_node.text_contents).append(element_text)             # <<<<<<<<<<<<<<
 *         return
 * 
 */
    try {
      (*__pyx_v_last_node->text_contents).append(__pyx_v_element_text);
    } catch(...) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      __Pyx_CppExn2PyErr();
      #ifdef WITH_THREAD
      __Pyx_PyGILState_Release(__pyx_gilstate_save);
      #endif
      __PYX_ERR(0, 187, __pyx_L1_error)
    }

    /* "resiliparse/extract/html2text.pyx":188
 *         _ensure_text_contents(extract_nodes)
 *         deref(last_node.text_contents).append(element_text)
 *         return             # <<<<<<<<<<<<<<
 * 
 *     elif ctx.opts.form_fields and ctx.node.local_name == LXB_TAG_INPUT:
 */
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":181
 *             deref(last_node.text_contents).append(<string>element_text_sv)
 * 
 *     elif ctx.opts.form_fields and ctx.node.local_name in [LXB_TAG_TEXTAREA, LXB_TAG_BUTTON]:             # <<<<<<<<<<<<<<
 *         if not is_end_tag:
 *             element_text.append(b'[ ')
 */
  }

  /* "resiliparse/extract/html2text.pyx":190
 *         return
 * 
 *     elif ctx.opts.form_fields and ctx.node.local_name == LXB_TAG_INPUT:             # <<<<<<<<<<<<<<
 *         element_text_sv = get_node_attr_sv(ctx.node, b'type')
 *         if element_text_sv.empty() or element_text_sv not in \
 */
  __pyx_t_1 = (__pyx_v_ctx.opts.form_fields != 0);
  if (__pyx_t_1) {
  } else {
    __pyx_t_7 = __pyx_t_1;
    goto __pyx_L35_bool_binop_done;
  }
  __pyx_t_1 = ((__pyx_v_ctx.node->local_name == LXB_TAG_INPUT) != 0);
  __pyx_t_7 = __pyx_t_1;
  __pyx_L35_bool_binop_done:;
  if (__pyx_t_7) {

    /* "resiliparse/extract/html2text.pyx":191
 * 
 *     elif ctx.opts.form_fields and ctx.node.local_name == LXB_TAG_INPUT:
 *         element_text_sv = get_node_attr_sv(ctx.node, b'type')             # <<<<<<<<<<<<<<
 *         if element_text_sv.empty() or element_text_sv not in \
 *                 [b'checkbox', b'color', b'file', b'hidden', b'radio', b'reset']:
 */
    __pyx_v_element_text_sv = __pyx_f_11resiliparse_5parse_4html_get_node_attr_sv(__pyx_v_ctx.node, __pyx_k_type);

    /* "resiliparse/extract/html2text.pyx":192
 *     elif ctx.opts.form_fields and ctx.node.local_name == LXB_TAG_INPUT:
 *         element_text_sv = get_node_attr_sv(ctx.node, b'type')
 *         if element_text_sv.empty() or element_text_sv not in \             # <<<<<<<<<<<<<<
 *                 [b'checkbox', b'color', b'file', b'hidden', b'radio', b'reset']:
 *             element_text_sv = get_node_attr_sv(ctx.node, b'value')
 */
    __pyx_t_1 = (__pyx_v_element_text_sv.empty() != 0);
    if (!__pyx_t_1) {
    } else {
      __pyx_t_7 = __pyx_t_1;
      goto __pyx_L38_bool_binop_done;
    }
    __pyx_t_8 = __pyx_v_element_text_sv;
    __pyx_t_2 = ((__pyx_t_8 != ((char const *)"checkbox")) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L40_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_t_8 != ((char const *)"color")) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L40_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_t_8 != ((char const *)"file")) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L40_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_t_8 != ((char const *)"hidden")) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L40_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_t_8 != ((char const *)"radio")) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L40_bool_binop_done;
    }
    __pyx_t_2 = ((__pyx_t_8 != ((char const *)"reset")) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L40_bool_binop_done:;
    __pyx_t_2 = (__pyx_t_1 != 0);
    __pyx_t_7 = __pyx_t_2;
    __pyx_L38_bool_binop_done:;
    if (__pyx_t_7) {

      /* "resiliparse/extract/html2text.pyx":194
 *         if element_text_sv.empty() or element_text_sv not in \
 *                 [b'checkbox', b'color', b'file', b'hidden', b'radio', b'reset']:
 *             element_text_sv = get_node_attr_sv(ctx.node, b'value')             # <<<<<<<<<<<<<<
 *             if element_text_sv.empty():
 *                 element_text_sv = get_node_attr_sv(ctx.node, b'placeholder')
 */
      __pyx_v_element_text_sv = __pyx_f_11resiliparse_5parse_4html_get_node_attr_sv(__pyx_v_ctx.node, __pyx_k_value);

      /* "resiliparse/extract/html2text.pyx":195
 *                 [b'checkbox', b'color', b'file', b'hidden', b'radio', b'reset']:
 *             element_text_sv = get_node_attr_sv(ctx.node, b'value')
 *             if element_text_sv.empty():             # <<<<<<<<<<<<<<
 *                 element_text_sv = get_node_attr_sv(ctx.node, b'placeholder')
 *             if not element_text_sv.empty():
 */
      __pyx_t_7 = (__pyx_v_element_text_sv.empty() != 0);
      if (__pyx_t_7) {

        /* "resiliparse/extract/html2text.pyx":196
 *             element_text_sv = get_node_attr_sv(ctx.node, b'value')
 *             if element_text_sv.empty():
 *                 element_text_sv = get_node_attr_sv(ctx.node, b'placeholder')             # <<<<<<<<<<<<<<
 *             if not element_text_sv.empty():
 *                 _ensure_text_contents(extract_nodes)
 */
        __pyx_v_element_text_sv = __pyx_f_11resiliparse_5parse_4html_get_node_attr_sv(__pyx_v_ctx.node, __pyx_k_placeholder);

        /* "resiliparse/extract/html2text.pyx":195
 *                 [b'checkbox', b'color', b'file', b'hidden', b'radio', b'reset']:
 *             element_text_sv = get_node_attr_sv(ctx.node, b'value')
 *             if element_text_sv.empty():             # <<<<<<<<<<<<<<
 *                 element_text_sv = get_node_attr_sv(ctx.node, b'placeholder')
 *             if not element_text_sv.empty():
 */
      }

      /* "resiliparse/extract/html2text.pyx":197
 *             if element_text_sv.empty():
 *                 element_text_sv = get_node_attr_sv(ctx.node, b'placeholder')
 *             if not element_text_sv.empty():             # <<<<<<<<<<<<<<
 *                 _ensure_text_contents(extract_nodes)
 *                 element_text.append(b'[ ')
 */
      __pyx_t_7 = ((!(__pyx_v_element_text_sv.empty() != 0)) != 0);
      if (__pyx_t_7) {

        /* "resiliparse/extract/html2text.pyx":198
 *                 element_text_sv = get_node_attr_sv(ctx.node, b'placeholder')
 *             if not element_text_sv.empty():
 *                 _ensure_text_contents(extract_nodes)             # <<<<<<<<<<<<<<
 *                 element_text.append(b'[ ')
 *                 element_text.append(<string> element_text_sv)
 */
        __pyx_f_11resiliparse_7extract_9html2text__ensure_text_contents(__pyx_v_extract_nodes);

        /* "resiliparse/extract/html2text.pyx":199
 *             if not element_text_sv.empty():
 *                 _ensure_text_contents(extract_nodes)
 *                 element_text.append(b'[ ')             # <<<<<<<<<<<<<<
 *                 element_text.append(<string> element_text_sv)
 *                 element_text.append(b' ]')
 */
        try {
          __pyx_v_element_text.append(((char const *)"[ "));
        } catch(...) {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
          #endif
          __Pyx_CppExn2PyErr();
          #ifdef WITH_THREAD
          __Pyx_PyGILState_Release(__pyx_gilstate_save);
          #endif
          __PYX_ERR(0, 199, __pyx_L1_error)
        }

        /* "resiliparse/extract/html2text.pyx":200
 *                 _ensure_text_contents(extract_nodes)
 *                 element_text.append(b'[ ')
 *                 element_text.append(<string> element_text_sv)             # <<<<<<<<<<<<<<
 *                 element_text.append(b' ]')
 *                 _ensure_text_contents(extract_nodes)
 */
        try {
          __pyx_v_element_text.append(((std::string)__pyx_v_element_text_sv));
        } catch(...) {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
          #endif
          __Pyx_CppExn2PyErr();
          #ifdef WITH_THREAD
          __Pyx_PyGILState_Release(__pyx_gilstate_save);
          #endif
          __PYX_ERR(0, 200, __pyx_L1_error)
        }

        /* "resiliparse/extract/html2text.pyx":201
 *                 element_text.append(b'[ ')
 *                 element_text.append(<string> element_text_sv)
 *                 element_text.append(b' ]')             # <<<<<<<<<<<<<<
 *                 _ensure_text_contents(extract_nodes)
 *                 deref(last_node.text_contents).append(element_text)
 */
        try {
          __pyx_v_element_text.append(((char const *)" ]"));
        } catch(...) {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
          #endif
          __Pyx_CppExn2PyErr();
          #ifdef WITH_THREAD
          __Pyx_PyGILState_Release(__pyx_gilstate_save);
          #endif
          __PYX_ERR(0, 201, __pyx_L1_error)
        }

        /* "resiliparse/extract/html2text.pyx":202
 *                 element_text.append(<string> element_text_sv)
 *                 element_text.append(b' ]')
 *                 _ensure_text_contents(extract_nodes)             # <<<<<<<<<<<<<<
 *                 deref(last_node.text_contents).append(element_text)
 * 
 */
        __pyx_f_11resiliparse_7extract_9html2text__ensure_text_contents(__pyx_v_extract_nodes);

        /* "resiliparse/extract/html2text.pyx":203
 *                 element_text.append(b' ]')
 *                 _ensure_text_contents(extract_nodes)
 *                 deref(last_node.text_contents).append(element_text)             # <<<<<<<<<<<<<<
 * 
 * 
 */
        try {
          (*__pyx_v_last_node->text_contents).append(__pyx_v_element_text);
        } catch(...) {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
          #endif
          __Pyx_CppExn2PyErr();
          #ifdef WITH_THREAD
          __Pyx_PyGILState_Release(__pyx_gilstate_save);
          #endif
          __PYX_ERR(0, 203, __pyx_L1_error)
        }

        /* "resiliparse/extract/html2text.pyx":197
 *             if element_text_sv.empty():
 *                 element_text_sv = get_node_attr_sv(ctx.node, b'placeholder')
 *             if not element_text_sv.empty():             # <<<<<<<<<<<<<<
 *                 _ensure_text_contents(extract_nodes)
 *                 element_text.append(b'[ ')
 */
      }

      /* "resiliparse/extract/html2text.pyx":192
 *     elif ctx.opts.form_fields and ctx.node.local_name == LXB_TAG_INPUT:
 *         element_text_sv = get_node_attr_sv(ctx.node, b'type')
 *         if element_text_sv.empty() or element_text_sv not in \             # <<<<<<<<<<<<<<
 *                 [b'checkbox', b'color', b'file', b'hidden', b'radio', b'reset']:
 *             element_text_sv = get_node_attr_sv(ctx.node, b'value')
 */
    }

    /* "resiliparse/extract/html2text.pyx":190
 *         return
 * 
 *     elif ctx.opts.form_fields and ctx.node.local_name == LXB_TAG_INPUT:             # <<<<<<<<<<<<<<
 *         element_text_sv = get_node_attr_sv(ctx.node, b'type')
 *         if element_text_sv.empty() or element_text_sv not in \
 */
  }
  __pyx_L13:;

  /* "resiliparse/extract/html2text.pyx":122
 * 
 * 
 * cdef void _extract_cb(vector[shared_ptr[ExtractNode]]& extract_nodes, ExtractContext& ctx, bint is_end_tag) nogil:             # <<<<<<<<<<<<<<
 *     cdef shared_ptr[ExtractNode] last_node_shared
 *     cdef ExtractNode* last_node = NULL
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("resiliparse.extract.html2text._extract_cb", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 1);
  __pyx_L0:;
}

/* "resiliparse/extract/html2text.pyx":206
 * 
 * 
 * cdef inline string _indent_newlines(const string& element_text, size_t depth) nogil:             # <<<<<<<<<<<<<<
 *     cdef string indent = string(2 * depth, <char>b' ')
 *     cdef string tmp_text
 */

static CYTHON_INLINE std::string __pyx_f_11resiliparse_7extract_9html2text__indent_newlines(std::string const &__pyx_v_element_text, size_t __pyx_v_depth) {
  std::string __pyx_v_indent;
  std::string __pyx_v_tmp_text;
  size_t __pyx_v_i;
  std::string __pyx_r;
  std::string __pyx_t_1;
  size_t __pyx_t_2;
  size_t __pyx_t_3;
  size_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "resiliparse/extract/html2text.pyx":207
 * 
 * cdef inline string _indent_newlines(const string& element_text, size_t depth) nogil:
 *     cdef string indent = string(2 * depth, <char>b' ')             # <<<<<<<<<<<<<<
 *     cdef string tmp_text
 *     tmp_text.reserve(element_text.size() + 10 * indent.size())
 */
  try {
    __pyx_t_1 = std::string((2 * __pyx_v_depth), ((char)' '));
  } catch(...) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
    #endif
    __Pyx_CppExn2PyErr();
    #ifdef WITH_THREAD
    __Pyx_PyGILState_Release(__pyx_gilstate_save);
    #endif
    __PYX_ERR(0, 207, __pyx_L1_error)
  }
  __pyx_v_indent = __pyx_t_1;

  /* "resiliparse/extract/html2text.pyx":209
 *     cdef string indent = string(2 * depth, <char>b' ')
 *     cdef string tmp_text
 *     tmp_text.reserve(element_text.size() + 10 * indent.size())             # <<<<<<<<<<<<<<
 *     for i in range(element_text.size()):
 *         tmp_text.push_back(element_text[i])
 */
  try {
    __pyx_v_tmp_text.reserve((__pyx_v_element_text.size() + (10 * __pyx_v_indent.size())));
  } catch(...) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
    #endif
    __Pyx_CppExn2PyErr();
    #ifdef WITH_THREAD
    __Pyx_PyGILState_Release(__pyx_gilstate_save);
    #endif
    __PYX_ERR(0, 209, __pyx_L1_error)
  }

  /* "resiliparse/extract/html2text.pyx":210
 *     cdef string tmp_text
 *     tmp_text.reserve(element_text.size() + 10 * indent.size())
 *     for i in range(element_text.size()):             # <<<<<<<<<<<<<<
 *         tmp_text.push_back(element_text[i])
 *         if element_text[i] == b'\n':
 */
  __pyx_t_2 = __pyx_v_element_text.size();
  __pyx_t_3 = __pyx_t_2;
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_v_i = __pyx_t_4;

    /* "resiliparse/extract/html2text.pyx":211
 *     tmp_text.reserve(element_text.size() + 10 * indent.size())
 *     for i in range(element_text.size()):
 *         tmp_text.push_back(element_text[i])             # <<<<<<<<<<<<<<
 *         if element_text[i] == b'\n':
 *             tmp_text.append(indent)
 */
    try {
      __pyx_v_tmp_text.push_back((__pyx_v_element_text[__pyx_v_i]));
    } catch(...) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      __Pyx_CppExn2PyErr();
      #ifdef WITH_THREAD
      __Pyx_PyGILState_Release(__pyx_gilstate_save);
      #endif
      __PYX_ERR(0, 211, __pyx_L1_error)
    }

    /* "resiliparse/extract/html2text.pyx":212
 *     for i in range(element_text.size()):
 *         tmp_text.push_back(element_text[i])
 *         if element_text[i] == b'\n':             # <<<<<<<<<<<<<<
 *             tmp_text.append(indent)
 * 
 */
    __pyx_t_5 = (((__pyx_v_element_text[__pyx_v_i]) == '\n') != 0);
    if (__pyx_t_5) {

      /* "resiliparse/extract/html2text.pyx":213
 *         tmp_text.push_back(element_text[i])
 *         if element_text[i] == b'\n':
 *             tmp_text.append(indent)             # <<<<<<<<<<<<<<
 * 
 *     return tmp_text
 */
      try {
        __pyx_v_tmp_text.append(__pyx_v_indent);
      } catch(...) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
        #endif
        __Pyx_CppExn2PyErr();
        #ifdef WITH_THREAD
        __Pyx_PyGILState_Release(__pyx_gilstate_save);
        #endif
        __PYX_ERR(0, 213, __pyx_L1_error)
      }

      /* "resiliparse/extract/html2text.pyx":212
 *     for i in range(element_text.size()):
 *         tmp_text.push_back(element_text[i])
 *         if element_text[i] == b'\n':             # <<<<<<<<<<<<<<
 *             tmp_text.append(indent)
 * 
 */
    }
  }

  /* "resiliparse/extract/html2text.pyx":215
 *             tmp_text.append(indent)
 * 
 *     return tmp_text             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_tmp_text;
  goto __pyx_L0;

  /* "resiliparse/extract/html2text.pyx":206
 * 
 * 
 * cdef inline string _indent_newlines(const string& element_text, size_t depth) nogil:             # <<<<<<<<<<<<<<
 *     cdef string indent = string(2 * depth, <char>b' ')
 *     cdef string tmp_text
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("resiliparse.extract.html2text._indent_newlines", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 1);
  __Pyx_pretend_to_initialize(&__pyx_r);
  __pyx_L0:;
  return __pyx_r;
}

/* "resiliparse/extract/html2text.pyx":218
 * 
 * 
 * cdef string _serialize_extract_nodes(vector[shared_ptr[ExtractNode]]& extract_nodes, const ExtractOpts& opts) nogil:             # <<<<<<<<<<<<<<
 *     cdef size_t i
 *     cdef string output
 */

static std::string __pyx_f_11resiliparse_7extract_9html2text__serialize_extract_nodes(std::vector<std::shared_ptr<struct ExtractNode> >  &__pyx_v_extract_nodes, struct ExtractOpts const &__pyx_v_opts) {
  size_t __pyx_v_i;
  std::string __pyx_v_output;
  std::string __pyx_v_element_text;
  struct ExtractNode *__pyx_v_current_node;
  int __pyx_v_bullet_deferred;
  size_t __pyx_v_list_depth;
  std::vector<size_t>  __pyx_v_list_numbering;
  std::string __pyx_v_list_item_indent;
  std::string __pyx_r;
  std::vector<std::shared_ptr<struct ExtractNode> > ::size_type __pyx_t_1;
  std::vector<std::shared_ptr<struct ExtractNode> > ::size_type __pyx_t_2;
  size_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  size_t __pyx_t_7;
  std::string __pyx_t_8;
  std::string __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "resiliparse/extract/html2text.pyx":222
 *     cdef string output
 *     cdef string element_text
 *     cdef ExtractNode* current_node = NULL             # <<<<<<<<<<<<<<
 *     cdef bint bullet_deferred = False
 *     cdef size_t list_depth = 0
 */
  __pyx_v_current_node = NULL;

  /* "resiliparse/extract/html2text.pyx":223
 *     cdef string element_text
 *     cdef ExtractNode* current_node = NULL
 *     cdef bint bullet_deferred = False             # <<<<<<<<<<<<<<
 *     cdef size_t list_depth = 0
 *     cdef vector[size_t] list_numbering
 */
  __pyx_v_bullet_deferred = 0;

  /* "resiliparse/extract/html2text.pyx":224
 *     cdef ExtractNode* current_node = NULL
 *     cdef bint bullet_deferred = False
 *     cdef size_t list_depth = 0             # <<<<<<<<<<<<<<
 *     cdef vector[size_t] list_numbering
 *     cdef string list_item_indent = <const char*>b' '
 */
  __pyx_v_list_depth = 0;

  /* "resiliparse/extract/html2text.pyx":226
 *     cdef size_t list_depth = 0
 *     cdef vector[size_t] list_numbering
 *     cdef string list_item_indent = <const char*>b' '             # <<<<<<<<<<<<<<
 * 
 *     for i in range(extract_nodes.size()):
 */
  __pyx_v_list_item_indent = ((char const *)((char const *)" "));

  /* "resiliparse/extract/html2text.pyx":228
 *     cdef string list_item_indent = <const char*>b' '
 * 
 *     for i in range(extract_nodes.size()):             # <<<<<<<<<<<<<<
 *         current_node = extract_nodes[i].get()
 * 
 */
  __pyx_t_1 = __pyx_v_extract_nodes.size();
  __pyx_t_2 = __pyx_t_1;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "resiliparse/extract/html2text.pyx":229
 * 
 *     for i in range(extract_nodes.size()):
 *         current_node = extract_nodes[i].get()             # <<<<<<<<<<<<<<
 * 
 *         if opts.preserve_formatting:
 */
    __pyx_v_current_node = (__pyx_v_extract_nodes[__pyx_v_i]).get();

    /* "resiliparse/extract/html2text.pyx":231
 *         current_node = extract_nodes[i].get()
 * 
 *         if opts.preserve_formatting:             # <<<<<<<<<<<<<<
 *             if current_node.tag_id in [LXB_TAG_UL, LXB_TAG_OL] \
 *                     or (current_node.tag_id == LXB_TAG_LI and list_depth == 0):
 */
    __pyx_t_4 = (__pyx_v_opts.preserve_formatting != 0);
    if (__pyx_t_4) {

      /* "resiliparse/extract/html2text.pyx":232
 * 
 *         if opts.preserve_formatting:
 *             if current_node.tag_id in [LXB_TAG_UL, LXB_TAG_OL] \             # <<<<<<<<<<<<<<
 *                     or (current_node.tag_id == LXB_TAG_LI and list_depth == 0):
 *                 if current_node.is_end_tag:
 */
      switch (__pyx_v_current_node->tag_id) {
        case LXB_TAG_UL:
        case LXB_TAG_OL:
        __pyx_t_5 = 1;
        break;
        default:
        __pyx_t_5 = 0;
        break;
      }
      __pyx_t_6 = (__pyx_t_5 != 0);
      if (!__pyx_t_6) {
      } else {
        __pyx_t_4 = __pyx_t_6;
        goto __pyx_L7_bool_binop_done;
      }

      /* "resiliparse/extract/html2text.pyx":233
 *         if opts.preserve_formatting:
 *             if current_node.tag_id in [LXB_TAG_UL, LXB_TAG_OL] \
 *                     or (current_node.tag_id == LXB_TAG_LI and list_depth == 0):             # <<<<<<<<<<<<<<
 *                 if current_node.is_end_tag:
 *                     predec(list_depth)
 */
      __pyx_t_6 = ((__pyx_v_current_node->tag_id == LXB_TAG_LI) != 0);
      if (__pyx_t_6) {
      } else {
        __pyx_t_4 = __pyx_t_6;
        goto __pyx_L7_bool_binop_done;
      }
      __pyx_t_6 = ((__pyx_v_list_depth == 0) != 0);
      __pyx_t_4 = __pyx_t_6;
      __pyx_L7_bool_binop_done:;

      /* "resiliparse/extract/html2text.pyx":232
 * 
 *         if opts.preserve_formatting:
 *             if current_node.tag_id in [LXB_TAG_UL, LXB_TAG_OL] \             # <<<<<<<<<<<<<<
 *                     or (current_node.tag_id == LXB_TAG_LI and list_depth == 0):
 *                 if current_node.is_end_tag:
 */
      if (__pyx_t_4) {

        /* "resiliparse/extract/html2text.pyx":234
 *             if current_node.tag_id in [LXB_TAG_UL, LXB_TAG_OL] \
 *                     or (current_node.tag_id == LXB_TAG_LI and list_depth == 0):
 *                 if current_node.is_end_tag:             # <<<<<<<<<<<<<<
 *                     predec(list_depth)
 *                     list_numbering.pop_back()
 */
        __pyx_t_4 = (__pyx_v_current_node->is_end_tag != 0);
        if (__pyx_t_4) {

          /* "resiliparse/extract/html2text.pyx":235
 *                     or (current_node.tag_id == LXB_TAG_LI and list_depth == 0):
 *                 if current_node.is_end_tag:
 *                     predec(list_depth)             # <<<<<<<<<<<<<<
 *                     list_numbering.pop_back()
 *                     bullet_deferred = False
 */
          (void)((--__pyx_v_list_depth));

          /* "resiliparse/extract/html2text.pyx":236
 *                 if current_node.is_end_tag:
 *                     predec(list_depth)
 *                     list_numbering.pop_back()             # <<<<<<<<<<<<<<
 *                     bullet_deferred = False
 *                 else:
 */
          __pyx_v_list_numbering.pop_back();

          /* "resiliparse/extract/html2text.pyx":237
 *                     predec(list_depth)
 *                     list_numbering.pop_back()
 *                     bullet_deferred = False             # <<<<<<<<<<<<<<
 *                 else:
 *                     preinc(list_depth)
 */
          __pyx_v_bullet_deferred = 0;

          /* "resiliparse/extract/html2text.pyx":234
 *             if current_node.tag_id in [LXB_TAG_UL, LXB_TAG_OL] \
 *                     or (current_node.tag_id == LXB_TAG_LI and list_depth == 0):
 *                 if current_node.is_end_tag:             # <<<<<<<<<<<<<<
 *                     predec(list_depth)
 *                     list_numbering.pop_back()
 */
          goto __pyx_L10;
        }

        /* "resiliparse/extract/html2text.pyx":239
 *                     bullet_deferred = False
 *                 else:
 *                     preinc(list_depth)             # <<<<<<<<<<<<<<
 *                     list_numbering.push_back(<size_t>(current_node.tag_id == LXB_TAG_OL))
 * 
 */
        /*else*/ {
          (void)((++__pyx_v_list_depth));

          /* "resiliparse/extract/html2text.pyx":240
 *                 else:
 *                     preinc(list_depth)
 *                     list_numbering.push_back(<size_t>(current_node.tag_id == LXB_TAG_OL))             # <<<<<<<<<<<<<<
 * 
 *             if current_node.tag_id == LXB_TAG_LI:
 */
          try {
            __pyx_v_list_numbering.push_back(((size_t)(__pyx_v_current_node->tag_id == LXB_TAG_OL)));
          } catch(...) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
            #endif
            __Pyx_CppExn2PyErr();
            #ifdef WITH_THREAD
            __Pyx_PyGILState_Release(__pyx_gilstate_save);
            #endif
            __PYX_ERR(0, 240, __pyx_L1_error)
          }
        }
        __pyx_L10:;

        /* "resiliparse/extract/html2text.pyx":232
 * 
 *         if opts.preserve_formatting:
 *             if current_node.tag_id in [LXB_TAG_UL, LXB_TAG_OL] \             # <<<<<<<<<<<<<<
 *                     or (current_node.tag_id == LXB_TAG_LI and list_depth == 0):
 *                 if current_node.is_end_tag:
 */
      }

      /* "resiliparse/extract/html2text.pyx":242
 *                     list_numbering.push_back(<size_t>(current_node.tag_id == LXB_TAG_OL))
 * 
 *             if current_node.tag_id == LXB_TAG_LI:             # <<<<<<<<<<<<<<
 *                 bullet_deferred = True
 * 
 */
      __pyx_t_4 = ((__pyx_v_current_node->tag_id == LXB_TAG_LI) != 0);
      if (__pyx_t_4) {

        /* "resiliparse/extract/html2text.pyx":243
 * 
 *             if current_node.tag_id == LXB_TAG_LI:
 *                 bullet_deferred = True             # <<<<<<<<<<<<<<
 * 
 *             # Add margins
 */
        __pyx_v_bullet_deferred = 1;

        /* "resiliparse/extract/html2text.pyx":242
 *                     list_numbering.push_back(<size_t>(current_node.tag_id == LXB_TAG_OL))
 * 
 *             if current_node.tag_id == LXB_TAG_LI:             # <<<<<<<<<<<<<<
 *                 bullet_deferred = True
 * 
 */
      }

      /* "resiliparse/extract/html2text.pyx":246
 * 
 *             # Add margins
 *             if current_node.tag_id != LXB_TAG_TEXTAREA:             # <<<<<<<<<<<<<<
 *                 if not current_node.collapse_margins or (not output.empty() and output.back() != b'\n'):
 *                     output.push_back(<char> b'\n')
 */
      __pyx_t_4 = ((__pyx_v_current_node->tag_id != LXB_TAG_TEXTAREA) != 0);
      if (__pyx_t_4) {

        /* "resiliparse/extract/html2text.pyx":247
 *             # Add margins
 *             if current_node.tag_id != LXB_TAG_TEXTAREA:
 *                 if not current_node.collapse_margins or (not output.empty() and output.back() != b'\n'):             # <<<<<<<<<<<<<<
 *                     output.push_back(<char> b'\n')
 *                 if current_node.is_big_block and not bullet_deferred and \
 */
        __pyx_t_6 = ((!(__pyx_v_current_node->collapse_margins != 0)) != 0);
        if (!__pyx_t_6) {
        } else {
          __pyx_t_4 = __pyx_t_6;
          goto __pyx_L14_bool_binop_done;
        }
        __pyx_t_6 = ((!(__pyx_v_output.empty() != 0)) != 0);
        if (__pyx_t_6) {
        } else {
          __pyx_t_4 = __pyx_t_6;
          goto __pyx_L14_bool_binop_done;
        }
        __pyx_t_6 = ((__pyx_v_output.back() != '\n') != 0);
        __pyx_t_4 = __pyx_t_6;
        __pyx_L14_bool_binop_done:;
        if (__pyx_t_4) {

          /* "resiliparse/extract/html2text.pyx":248
 *             if current_node.tag_id != LXB_TAG_TEXTAREA:
 *                 if not current_node.collapse_margins or (not output.empty() and output.back() != b'\n'):
 *                     output.push_back(<char> b'\n')             # <<<<<<<<<<<<<<
 *                 if current_node.is_big_block and not bullet_deferred and \
 *                         output.size() >= 2 and output[output.size() - 2] != b'\n':
 */
          try {
            __pyx_v_output.push_back(((char)'\n'));
          } catch(...) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
            #endif
            __Pyx_CppExn2PyErr();
            #ifdef WITH_THREAD
            __Pyx_PyGILState_Release(__pyx_gilstate_save);
            #endif
            __PYX_ERR(0, 248, __pyx_L1_error)
          }

          /* "resiliparse/extract/html2text.pyx":247
 *             # Add margins
 *             if current_node.tag_id != LXB_TAG_TEXTAREA:
 *                 if not current_node.collapse_margins or (not output.empty() and output.back() != b'\n'):             # <<<<<<<<<<<<<<
 *                     output.push_back(<char> b'\n')
 *                 if current_node.is_big_block and not bullet_deferred and \
 */
        }

        /* "resiliparse/extract/html2text.pyx":249
 *                 if not current_node.collapse_margins or (not output.empty() and output.back() != b'\n'):
 *                     output.push_back(<char> b'\n')
 *                 if current_node.is_big_block and not bullet_deferred and \             # <<<<<<<<<<<<<<
 *                         output.size() >= 2 and output[output.size() - 2] != b'\n':
 *                     output.push_back(<char> b'\n')
 */
        __pyx_t_6 = (__pyx_v_current_node->is_big_block != 0);
        if (__pyx_t_6) {
        } else {
          __pyx_t_4 = __pyx_t_6;
          goto __pyx_L18_bool_binop_done;
        }
        __pyx_t_6 = ((!(__pyx_v_bullet_deferred != 0)) != 0);
        if (__pyx_t_6) {
        } else {
          __pyx_t_4 = __pyx_t_6;
          goto __pyx_L18_bool_binop_done;
        }

        /* "resiliparse/extract/html2text.pyx":250
 *                     output.push_back(<char> b'\n')
 *                 if current_node.is_big_block and not bullet_deferred and \
 *                         output.size() >= 2 and output[output.size() - 2] != b'\n':             # <<<<<<<<<<<<<<
 *                     output.push_back(<char> b'\n')
 *         elif not output.empty() and output.back() != b' ':
 */
        __pyx_t_6 = ((__pyx_v_output.size() >= 2) != 0);
        if (__pyx_t_6) {
        } else {
          __pyx_t_4 = __pyx_t_6;
          goto __pyx_L18_bool_binop_done;
        }
        __pyx_t_6 = (((__pyx_v_output[(__pyx_v_output.size() - 2)]) != '\n') != 0);
        __pyx_t_4 = __pyx_t_6;
        __pyx_L18_bool_binop_done:;

        /* "resiliparse/extract/html2text.pyx":249
 *                 if not current_node.collapse_margins or (not output.empty() and output.back() != b'\n'):
 *                     output.push_back(<char> b'\n')
 *                 if current_node.is_big_block and not bullet_deferred and \             # <<<<<<<<<<<<<<
 *                         output.size() >= 2 and output[output.size() - 2] != b'\n':
 *                     output.push_back(<char> b'\n')
 */
        if (__pyx_t_4) {

          /* "resiliparse/extract/html2text.pyx":251
 *                 if current_node.is_big_block and not bullet_deferred and \
 *                         output.size() >= 2 and output[output.size() - 2] != b'\n':
 *                     output.push_back(<char> b'\n')             # <<<<<<<<<<<<<<
 *         elif not output.empty() and output.back() != b' ':
 *             output.push_back(<char> b' ')
 */
          try {
            __pyx_v_output.push_back(((char)'\n'));
          } catch(...) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
            #endif
            __Pyx_CppExn2PyErr();
            #ifdef WITH_THREAD
            __Pyx_PyGILState_Release(__pyx_gilstate_save);
            #endif
            __PYX_ERR(0, 251, __pyx_L1_error)
          }

          /* "resiliparse/extract/html2text.pyx":249
 *                 if not current_node.collapse_margins or (not output.empty() and output.back() != b'\n'):
 *                     output.push_back(<char> b'\n')
 *                 if current_node.is_big_block and not bullet_deferred and \             # <<<<<<<<<<<<<<
 *                         output.size() >= 2 and output[output.size() - 2] != b'\n':
 *                     output.push_back(<char> b'\n')
 */
        }

        /* "resiliparse/extract/html2text.pyx":246
 * 
 *             # Add margins
 *             if current_node.tag_id != LXB_TAG_TEXTAREA:             # <<<<<<<<<<<<<<
 *                 if not current_node.collapse_margins or (not output.empty() and output.back() != b'\n'):
 *                     output.push_back(<char> b'\n')
 */
      }

      /* "resiliparse/extract/html2text.pyx":231
 *         current_node = extract_nodes[i].get()
 * 
 *         if opts.preserve_formatting:             # <<<<<<<<<<<<<<
 *             if current_node.tag_id in [LXB_TAG_UL, LXB_TAG_OL] \
 *                     or (current_node.tag_id == LXB_TAG_LI and list_depth == 0):
 */
      goto __pyx_L5;
    }

    /* "resiliparse/extract/html2text.pyx":252
 *                         output.size() >= 2 and output[output.size() - 2] != b'\n':
 *                     output.push_back(<char> b'\n')
 *         elif not output.empty() and output.back() != b' ':             # <<<<<<<<<<<<<<
 *             output.push_back(<char> b' ')
 * 
 */
    __pyx_t_6 = ((!(__pyx_v_output.empty() != 0)) != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_4 = __pyx_t_6;
      goto __pyx_L22_bool_binop_done;
    }
    __pyx_t_6 = ((__pyx_v_output.back() != ' ') != 0);
    __pyx_t_4 = __pyx_t_6;
    __pyx_L22_bool_binop_done:;
    if (__pyx_t_4) {

      /* "resiliparse/extract/html2text.pyx":253
 *                     output.push_back(<char> b'\n')
 *         elif not output.empty() and output.back() != b' ':
 *             output.push_back(<char> b' ')             # <<<<<<<<<<<<<<
 * 
 *         if current_node.text_contents.get() == NULL:
 */
      try {
        __pyx_v_output.push_back(((char)' '));
      } catch(...) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
        #endif
        __Pyx_CppExn2PyErr();
        #ifdef WITH_THREAD
        __Pyx_PyGILState_Release(__pyx_gilstate_save);
        #endif
        __PYX_ERR(0, 253, __pyx_L1_error)
      }

      /* "resiliparse/extract/html2text.pyx":252
 *                         output.size() >= 2 and output[output.size() - 2] != b'\n':
 *                     output.push_back(<char> b'\n')
 *         elif not output.empty() and output.back() != b' ':             # <<<<<<<<<<<<<<
 *             output.push_back(<char> b' ')
 * 
 */
    }
    __pyx_L5:;

    /* "resiliparse/extract/html2text.pyx":255
 *             output.push_back(<char> b' ')
 * 
 *         if current_node.text_contents.get() == NULL:             # <<<<<<<<<<<<<<
 *             continue
 * 
 */
    __pyx_t_4 = ((__pyx_v_current_node->text_contents.get() == NULL) != 0);
    if (__pyx_t_4) {

      /* "resiliparse/extract/html2text.pyx":256
 * 
 *         if current_node.text_contents.get() == NULL:
 *             continue             # <<<<<<<<<<<<<<
 * 
 *         element_text = deref(current_node.text_contents)
 */
      goto __pyx_L3_continue;

      /* "resiliparse/extract/html2text.pyx":255
 *             output.push_back(<char> b' ')
 * 
 *         if current_node.text_contents.get() == NULL:             # <<<<<<<<<<<<<<
 *             continue
 * 
 */
    }

    /* "resiliparse/extract/html2text.pyx":258
 *             continue
 * 
 *         element_text = deref(current_node.text_contents)             # <<<<<<<<<<<<<<
 *         if not current_node.is_pre or current_node.is_end_tag:
 *             element_text = rstrip_str(element_text)
 */
    __pyx_v_element_text = (*__pyx_v_current_node->text_contents);

    /* "resiliparse/extract/html2text.pyx":259
 * 
 *         element_text = deref(current_node.text_contents)
 *         if not current_node.is_pre or current_node.is_end_tag:             # <<<<<<<<<<<<<<
 *             element_text = rstrip_str(element_text)
 * 
 */
    __pyx_t_6 = ((!(__pyx_v_current_node->is_pre != 0)) != 0);
    if (!__pyx_t_6) {
    } else {
      __pyx_t_4 = __pyx_t_6;
      goto __pyx_L26_bool_binop_done;
    }
    __pyx_t_6 = (__pyx_v_current_node->is_end_tag != 0);
    __pyx_t_4 = __pyx_t_6;
    __pyx_L26_bool_binop_done:;
    if (__pyx_t_4) {

      /* "resiliparse/extract/html2text.pyx":260
 *         element_text = deref(current_node.text_contents)
 *         if not current_node.is_pre or current_node.is_end_tag:
 *             element_text = rstrip_str(element_text)             # <<<<<<<<<<<<<<
 * 
 *         if element_text.empty():
 */
      __pyx_v_element_text = __pyx_f_18resiliparse_common_11string_util_rstrip_str(__pyx_v_element_text);

      /* "resiliparse/extract/html2text.pyx":259
 * 
 *         element_text = deref(current_node.text_contents)
 *         if not current_node.is_pre or current_node.is_end_tag:             # <<<<<<<<<<<<<<
 *             element_text = rstrip_str(element_text)
 * 
 */
    }

    /* "resiliparse/extract/html2text.pyx":262
 *             element_text = rstrip_str(element_text)
 * 
 *         if element_text.empty():             # <<<<<<<<<<<<<<
 *             continue
 * 
 */
    __pyx_t_4 = (__pyx_v_element_text.empty() != 0);
    if (__pyx_t_4) {

      /* "resiliparse/extract/html2text.pyx":263
 * 
 *         if element_text.empty():
 *             continue             # <<<<<<<<<<<<<<
 * 
 *         if list_depth > 0:
 */
      goto __pyx_L3_continue;

      /* "resiliparse/extract/html2text.pyx":262
 *             element_text = rstrip_str(element_text)
 * 
 *         if element_text.empty():             # <<<<<<<<<<<<<<
 *             continue
 * 
 */
    }

    /* "resiliparse/extract/html2text.pyx":265
 *             continue
 * 
 *         if list_depth > 0:             # <<<<<<<<<<<<<<
 *             if current_node.is_pre and opts.preserve_formatting:
 *                 element_text = _indent_newlines(element_text, list_depth + <size_t>opts.list_bullets)
 */
    __pyx_t_4 = ((__pyx_v_list_depth > 0) != 0);
    if (__pyx_t_4) {

      /* "resiliparse/extract/html2text.pyx":266
 * 
 *         if list_depth > 0:
 *             if current_node.is_pre and opts.preserve_formatting:             # <<<<<<<<<<<<<<
 *                 element_text = _indent_newlines(element_text, list_depth + <size_t>opts.list_bullets)
 *             if opts.preserve_formatting:
 */
      __pyx_t_6 = (__pyx_v_current_node->is_pre != 0);
      if (__pyx_t_6) {
      } else {
        __pyx_t_4 = __pyx_t_6;
        goto __pyx_L31_bool_binop_done;
      }
      __pyx_t_6 = (__pyx_v_opts.preserve_formatting != 0);
      __pyx_t_4 = __pyx_t_6;
      __pyx_L31_bool_binop_done:;
      if (__pyx_t_4) {

        /* "resiliparse/extract/html2text.pyx":267
 *         if list_depth > 0:
 *             if current_node.is_pre and opts.preserve_formatting:
 *                 element_text = _indent_newlines(element_text, list_depth + <size_t>opts.list_bullets)             # <<<<<<<<<<<<<<
 *             if opts.preserve_formatting:
 *                 list_item_indent = string(2 * list_depth + 2 * <size_t>(
 */
        __pyx_v_element_text = __pyx_f_11resiliparse_7extract_9html2text__indent_newlines(__pyx_v_element_text, (__pyx_v_list_depth + ((size_t)__pyx_v_opts.list_bullets)));

        /* "resiliparse/extract/html2text.pyx":266
 * 
 *         if list_depth > 0:
 *             if current_node.is_pre and opts.preserve_formatting:             # <<<<<<<<<<<<<<
 *                 element_text = _indent_newlines(element_text, list_depth + <size_t>opts.list_bullets)
 *             if opts.preserve_formatting:
 */
      }

      /* "resiliparse/extract/html2text.pyx":268
 *             if current_node.is_pre and opts.preserve_formatting:
 *                 element_text = _indent_newlines(element_text, list_depth + <size_t>opts.list_bullets)
 *             if opts.preserve_formatting:             # <<<<<<<<<<<<<<
 *                 list_item_indent = string(2 * list_depth + 2 * <size_t>(
 *                         not bullet_deferred and opts.list_bullets), <char>b' ')
 */
      __pyx_t_4 = (__pyx_v_opts.preserve_formatting != 0);
      if (__pyx_t_4) {

        /* "resiliparse/extract/html2text.pyx":270
 *             if opts.preserve_formatting:
 *                 list_item_indent = string(2 * list_depth + 2 * <size_t>(
 *                         not bullet_deferred and opts.list_bullets), <char>b' ')             # <<<<<<<<<<<<<<
 *             if bullet_deferred:
 *                 if opts.list_bullets and list_numbering.back() == 0:
 */
        __pyx_t_4 = (!(__pyx_v_bullet_deferred != 0));
        if (__pyx_t_4) {
        } else {
          __pyx_t_7 = __pyx_t_4;
          goto __pyx_L34_bool_binop_done;
        }
        __pyx_t_7 = __pyx_v_opts.list_bullets;
        __pyx_L34_bool_binop_done:;

        /* "resiliparse/extract/html2text.pyx":269
 *                 element_text = _indent_newlines(element_text, list_depth + <size_t>opts.list_bullets)
 *             if opts.preserve_formatting:
 *                 list_item_indent = string(2 * list_depth + 2 * <size_t>(             # <<<<<<<<<<<<<<
 *                         not bullet_deferred and opts.list_bullets), <char>b' ')
 *             if bullet_deferred:
 */
        try {
          __pyx_t_8 = std::string(((2 * __pyx_v_list_depth) + (2 * ((size_t)__pyx_t_7))), ((char)' '));
        } catch(...) {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
          #endif
          __Pyx_CppExn2PyErr();
          #ifdef WITH_THREAD
          __Pyx_PyGILState_Release(__pyx_gilstate_save);
          #endif
          __PYX_ERR(0, 269, __pyx_L1_error)
        }
        __pyx_v_list_item_indent = __pyx_t_8;

        /* "resiliparse/extract/html2text.pyx":268
 *             if current_node.is_pre and opts.preserve_formatting:
 *                 element_text = _indent_newlines(element_text, list_depth + <size_t>opts.list_bullets)
 *             if opts.preserve_formatting:             # <<<<<<<<<<<<<<
 *                 list_item_indent = string(2 * list_depth + 2 * <size_t>(
 *                         not bullet_deferred and opts.list_bullets), <char>b' ')
 */
      }

      /* "resiliparse/extract/html2text.pyx":271
 *                 list_item_indent = string(2 * list_depth + 2 * <size_t>(
 *                         not bullet_deferred and opts.list_bullets), <char>b' ')
 *             if bullet_deferred:             # <<<<<<<<<<<<<<
 *                 if opts.list_bullets and list_numbering.back() == 0:
 *                     list_item_indent += LIST_BULLET + <const char*>b' '
 */
      __pyx_t_4 = (__pyx_v_bullet_deferred != 0);
      if (__pyx_t_4) {

        /* "resiliparse/extract/html2text.pyx":272
 *                         not bullet_deferred and opts.list_bullets), <char>b' ')
 *             if bullet_deferred:
 *                 if opts.list_bullets and list_numbering.back() == 0:             # <<<<<<<<<<<<<<
 *                     list_item_indent += LIST_BULLET + <const char*>b' '
 *                 elif opts.list_bullets:
 */
        __pyx_t_6 = (__pyx_v_opts.list_bullets != 0);
        if (__pyx_t_6) {
        } else {
          __pyx_t_4 = __pyx_t_6;
          goto __pyx_L38_bool_binop_done;
        }
        __pyx_t_6 = ((__pyx_v_list_numbering.back() == 0) != 0);
        __pyx_t_4 = __pyx_t_6;
        __pyx_L38_bool_binop_done:;
        if (__pyx_t_4) {

          /* "resiliparse/extract/html2text.pyx":273
 *             if bullet_deferred:
 *                 if opts.list_bullets and list_numbering.back() == 0:
 *                     list_item_indent += LIST_BULLET + <const char*>b' '             # <<<<<<<<<<<<<<
 *                 elif opts.list_bullets:
 *                     list_item_indent += to_string(list_numbering.back()) + <const char*>b'. '
 */
          try {
            __pyx_t_8 = (__pyx_v_11resiliparse_7extract_9html2text_LIST_BULLET + ((char const *)((char const *)" ")));
          } catch(...) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
            #endif
            __Pyx_CppExn2PyErr();
            #ifdef WITH_THREAD
            __Pyx_PyGILState_Release(__pyx_gilstate_save);
            #endif
            __PYX_ERR(0, 273, __pyx_L1_error)
          }
          __pyx_v_list_item_indent += __pyx_t_8;

          /* "resiliparse/extract/html2text.pyx":272
 *                         not bullet_deferred and opts.list_bullets), <char>b' ')
 *             if bullet_deferred:
 *                 if opts.list_bullets and list_numbering.back() == 0:             # <<<<<<<<<<<<<<
 *                     list_item_indent += LIST_BULLET + <const char*>b' '
 *                 elif opts.list_bullets:
 */
          goto __pyx_L37;
        }

        /* "resiliparse/extract/html2text.pyx":274
 *                 if opts.list_bullets and list_numbering.back() == 0:
 *                     list_item_indent += LIST_BULLET + <const char*>b' '
 *                 elif opts.list_bullets:             # <<<<<<<<<<<<<<
 *                     list_item_indent += to_string(list_numbering.back()) + <const char*>b'. '
 *                     preinc(list_numbering.back())
 */
        __pyx_t_4 = (__pyx_v_opts.list_bullets != 0);
        if (__pyx_t_4) {

          /* "resiliparse/extract/html2text.pyx":275
 *                     list_item_indent += LIST_BULLET + <const char*>b' '
 *                 elif opts.list_bullets:
 *                     list_item_indent += to_string(list_numbering.back()) + <const char*>b'. '             # <<<<<<<<<<<<<<
 *                     preinc(list_numbering.back())
 *                 bullet_deferred = False
 */
          try {
            __pyx_t_8 = std::to_string(__pyx_v_list_numbering.back());
          } catch(...) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
            #endif
            __Pyx_CppExn2PyErr();
            #ifdef WITH_THREAD
            __Pyx_PyGILState_Release(__pyx_gilstate_save);
            #endif
            __PYX_ERR(0, 275, __pyx_L1_error)
          }
          try {
            __pyx_t_9 = (__pyx_t_8 + ((char const *)((char const *)". ")));
          } catch(...) {
            #ifdef WITH_THREAD
            PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
            #endif
            __Pyx_CppExn2PyErr();
            #ifdef WITH_THREAD
            __Pyx_PyGILState_Release(__pyx_gilstate_save);
            #endif
            __PYX_ERR(0, 275, __pyx_L1_error)
          }
          __pyx_v_list_item_indent += __pyx_t_9;

          /* "resiliparse/extract/html2text.pyx":276
 *                 elif opts.list_bullets:
 *                     list_item_indent += to_string(list_numbering.back()) + <const char*>b'. '
 *                     preinc(list_numbering.back())             # <<<<<<<<<<<<<<
 *                 bullet_deferred = False
 *             element_text = list_item_indent + element_text
 */
          (void)((++__pyx_v_list_numbering.back()));

          /* "resiliparse/extract/html2text.pyx":274
 *                 if opts.list_bullets and list_numbering.back() == 0:
 *                     list_item_indent += LIST_BULLET + <const char*>b' '
 *                 elif opts.list_bullets:             # <<<<<<<<<<<<<<
 *                     list_item_indent += to_string(list_numbering.back()) + <const char*>b'. '
 *                     preinc(list_numbering.back())
 */
        }
        __pyx_L37:;

        /* "resiliparse/extract/html2text.pyx":277
 *                     list_item_indent += to_string(list_numbering.back()) + <const char*>b'. '
 *                     preinc(list_numbering.back())
 *                 bullet_deferred = False             # <<<<<<<<<<<<<<
 *             element_text = list_item_indent + element_text
 * 
 */
        __pyx_v_bullet_deferred = 0;

        /* "resiliparse/extract/html2text.pyx":271
 *                 list_item_indent = string(2 * list_depth + 2 * <size_t>(
 *                         not bullet_deferred and opts.list_bullets), <char>b' ')
 *             if bullet_deferred:             # <<<<<<<<<<<<<<
 *                 if opts.list_bullets and list_numbering.back() == 0:
 *                     list_item_indent += LIST_BULLET + <const char*>b' '
 */
      }

      /* "resiliparse/extract/html2text.pyx":278
 *                     preinc(list_numbering.back())
 *                 bullet_deferred = False
 *             element_text = list_item_indent + element_text             # <<<<<<<<<<<<<<
 * 
 *         if opts.preserve_formatting and current_node.tag_id in [LXB_TAG_TD, LXB_TAG_TH]:
 */
      try {
        __pyx_t_9 = (__pyx_v_list_item_indent + __pyx_v_element_text);
      } catch(...) {
        #ifdef WITH_THREAD
        PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
        #endif
        __Pyx_CppExn2PyErr();
        #ifdef WITH_THREAD
        __Pyx_PyGILState_Release(__pyx_gilstate_save);
        #endif
        __PYX_ERR(0, 278, __pyx_L1_error)
      }
      __pyx_v_element_text = __pyx_t_9;

      /* "resiliparse/extract/html2text.pyx":265
 *             continue
 * 
 *         if list_depth > 0:             # <<<<<<<<<<<<<<
 *             if current_node.is_pre and opts.preserve_formatting:
 *                 element_text = _indent_newlines(element_text, list_depth + <size_t>opts.list_bullets)
 */
    }

    /* "resiliparse/extract/html2text.pyx":280
 *             element_text = list_item_indent + element_text
 * 
 *         if opts.preserve_formatting and current_node.tag_id in [LXB_TAG_TD, LXB_TAG_TH]:             # <<<<<<<<<<<<<<
 *             if not output.empty() and output.back() != b'\n':
 *                 output.append(b'\t\t')
 */
    __pyx_t_6 = (__pyx_v_opts.preserve_formatting != 0);
    if (__pyx_t_6) {
    } else {
      __pyx_t_4 = __pyx_t_6;
      goto __pyx_L41_bool_binop_done;
    }
    switch (__pyx_v_current_node->tag_id) {
      case LXB_TAG_TD:
      case LXB_TAG_TH:
      __pyx_t_6 = 1;
      break;
      default:
      __pyx_t_6 = 0;
      break;
    }
    __pyx_t_5 = (__pyx_t_6 != 0);
    __pyx_t_4 = __pyx_t_5;
    __pyx_L41_bool_binop_done:;
    if (__pyx_t_4) {

      /* "resiliparse/extract/html2text.pyx":281
 * 
 *         if opts.preserve_formatting and current_node.tag_id in [LXB_TAG_TD, LXB_TAG_TH]:
 *             if not output.empty() and output.back() != b'\n':             # <<<<<<<<<<<<<<
 *                 output.append(b'\t\t')
 * 
 */
      __pyx_t_5 = ((!(__pyx_v_output.empty() != 0)) != 0);
      if (__pyx_t_5) {
      } else {
        __pyx_t_4 = __pyx_t_5;
        goto __pyx_L44_bool_binop_done;
      }
      __pyx_t_5 = ((__pyx_v_output.back() != '\n') != 0);
      __pyx_t_4 = __pyx_t_5;
      __pyx_L44_bool_binop_done:;
      if (__pyx_t_4) {

        /* "resiliparse/extract/html2text.pyx":282
 *         if opts.preserve_formatting and current_node.tag_id in [LXB_TAG_TD, LXB_TAG_TH]:
 *             if not output.empty() and output.back() != b'\n':
 *                 output.append(b'\t\t')             # <<<<<<<<<<<<<<
 * 
 *         output.append(element_text)
 */
        try {
          __pyx_v_output.append(((char const *)"\t\t"));
        } catch(...) {
          #ifdef WITH_THREAD
          PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
          #endif
          __Pyx_CppExn2PyErr();
          #ifdef WITH_THREAD
          __Pyx_PyGILState_Release(__pyx_gilstate_save);
          #endif
          __PYX_ERR(0, 282, __pyx_L1_error)
        }

        /* "resiliparse/extract/html2text.pyx":281
 * 
 *         if opts.preserve_formatting and current_node.tag_id in [LXB_TAG_TD, LXB_TAG_TH]:
 *             if not output.empty() and output.back() != b'\n':             # <<<<<<<<<<<<<<
 *                 output.append(b'\t\t')
 * 
 */
      }

      /* "resiliparse/extract/html2text.pyx":280
 *             element_text = list_item_indent + element_text
 * 
 *         if opts.preserve_formatting and current_node.tag_id in [LXB_TAG_TD, LXB_TAG_TH]:             # <<<<<<<<<<<<<<
 *             if not output.empty() and output.back() != b'\n':
 *                 output.append(b'\t\t')
 */
    }

    /* "resiliparse/extract/html2text.pyx":284
 *                 output.append(b'\t\t')
 * 
 *         output.append(element_text)             # <<<<<<<<<<<<<<
 * 
 *     return output
 */
    try {
      __pyx_v_output.append(__pyx_v_element_text);
    } catch(...) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      __Pyx_CppExn2PyErr();
      #ifdef WITH_THREAD
      __Pyx_PyGILState_Release(__pyx_gilstate_save);
      #endif
      __PYX_ERR(0, 284, __pyx_L1_error)
    }
    __pyx_L3_continue:;
  }

  /* "resiliparse/extract/html2text.pyx":286
 *         output.append(element_text)
 * 
 *     return output             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_output;
  goto __pyx_L0;

  /* "resiliparse/extract/html2text.pyx":218
 * 
 * 
 * cdef string _serialize_extract_nodes(vector[shared_ptr[ExtractNode]]& extract_nodes, const ExtractOpts& opts) nogil:             # <<<<<<<<<<<<<<
 *     cdef size_t i
 *     cdef string output
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("resiliparse.extract.html2text._serialize_extract_nodes", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 1);
  __Pyx_pretend_to_initialize(&__pyx_r);
  __pyx_L0:;
  return __pyx_r;
}

/* "resiliparse/extract/html2text.pyx":289
 * 
 * 
 * cdef inline bint _is_unprintable_pua(lxb_dom_node_t* node) nogil:             # <<<<<<<<<<<<<<
 *     """Whether text node contains only a single unprintable code point from the private use area."""
 *     if node.first_child and (node.first_child.next or node.first_child.type != LXB_DOM_NODE_TYPE_TEXT):
 */

static CYTHON_INLINE int __pyx_f_11resiliparse_7extract_9html2text__is_unprintable_pua(lxb_dom_node_t *__pyx_v_node) {
  std::string __pyx_v_element_text;
  uint32_t __pyx_v_cp;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;

  /* "resiliparse/extract/html2text.pyx":291
 * cdef inline bint _is_unprintable_pua(lxb_dom_node_t* node) nogil:
 *     """Whether text node contains only a single unprintable code point from the private use area."""
 *     if node.first_child and (node.first_child.next or node.first_child.type != LXB_DOM_NODE_TYPE_TEXT):             # <<<<<<<<<<<<<<
 *         # Node has more than one child
 *         return False
 */
  __pyx_t_2 = (__pyx_v_node->first_child != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = (__pyx_v_node->first_child->next != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_node->first_child->type != LXB_DOM_NODE_TYPE_TEXT) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":293
 *     if node.first_child and (node.first_child.next or node.first_child.type != LXB_DOM_NODE_TYPE_TEXT):
 *         # Node has more than one child
 *         return False             # <<<<<<<<<<<<<<
 *     if not node.first_child and node.type != LXB_DOM_NODE_TYPE_TEXT:
 *         return False
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":291
 * cdef inline bint _is_unprintable_pua(lxb_dom_node_t* node) nogil:
 *     """Whether text node contains only a single unprintable code point from the private use area."""
 *     if node.first_child and (node.first_child.next or node.first_child.type != LXB_DOM_NODE_TYPE_TEXT):             # <<<<<<<<<<<<<<
 *         # Node has more than one child
 *         return False
 */
  }

  /* "resiliparse/extract/html2text.pyx":294
 *         # Node has more than one child
 *         return False
 *     if not node.first_child and node.type != LXB_DOM_NODE_TYPE_TEXT:             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_node->first_child != 0)) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_node->type != LXB_DOM_NODE_TYPE_TEXT) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L8_bool_binop_done:;
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":295
 *         return False
 *     if not node.first_child and node.type != LXB_DOM_NODE_TYPE_TEXT:
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     cdef string element_text = strip_str(get_node_text(node))
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":294
 *         # Node has more than one child
 *         return False
 *     if not node.first_child and node.type != LXB_DOM_NODE_TYPE_TEXT:             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":297
 *         return False
 * 
 *     cdef string element_text = strip_str(get_node_text(node))             # <<<<<<<<<<<<<<
 *     if element_text.size() > 3:
 *         return False
 */
  __pyx_v_element_text = __pyx_f_18resiliparse_common_11string_util_strip_str(__pyx_f_11resiliparse_5parse_4html_get_node_text(__pyx_v_node));

  /* "resiliparse/extract/html2text.pyx":298
 * 
 *     cdef string element_text = strip_str(get_node_text(node))
 *     if element_text.size() > 3:             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_1 = ((__pyx_v_element_text.size() > 3) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":299
 *     cdef string element_text = strip_str(get_node_text(node))
 *     if element_text.size() > 3:
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     # Pilcrow character (probably an anchor link)
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":298
 * 
 *     cdef string element_text = strip_str(get_node_text(node))
 *     if element_text.size() > 3:             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":302
 * 
 *     # Pilcrow character (probably an anchor link)
 *     if element_text == b'\xc2\xb6':             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  __pyx_t_1 = ((__pyx_v_element_text == ((char const *)"\302\266")) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":303
 *     # Pilcrow character (probably an anchor link)
 *     if element_text == b'\xc2\xb6':
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     # BMP private use area (probably an icon font)
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":302
 * 
 *     # Pilcrow character (probably an anchor link)
 *     if element_text == b'\xc2\xb6':             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":306
 * 
 *     # BMP private use area (probably an icon font)
 *     cdef uint32_t cp = 0             # <<<<<<<<<<<<<<
 *     if element_text.size() == 3:
 *         memcpy(&cp, element_text.data(), 3 * sizeof(char))
 */
  __pyx_v_cp = 0;

  /* "resiliparse/extract/html2text.pyx":307
 *     # BMP private use area (probably an icon font)
 *     cdef uint32_t cp = 0
 *     if element_text.size() == 3:             # <<<<<<<<<<<<<<
 *         memcpy(&cp, element_text.data(), 3 * sizeof(char))
 *         if 0x8080ee <= cp <= 0xbfa3ef:
 */
  __pyx_t_1 = ((__pyx_v_element_text.size() == 3) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":308
 *     cdef uint32_t cp = 0
 *     if element_text.size() == 3:
 *         memcpy(&cp, element_text.data(), 3 * sizeof(char))             # <<<<<<<<<<<<<<
 *         if 0x8080ee <= cp <= 0xbfa3ef:
 *             return True
 */
    (void)(memcpy((&__pyx_v_cp), __pyx_v_element_text.data(), (3 * (sizeof(char)))));

    /* "resiliparse/extract/html2text.pyx":309
 *     if element_text.size() == 3:
 *         memcpy(&cp, element_text.data(), 3 * sizeof(char))
 *         if 0x8080ee <= cp <= 0xbfa3ef:             # <<<<<<<<<<<<<<
 *             return True
 * 
 */
    __pyx_t_1 = (0x8080ee <= __pyx_v_cp);
    if (__pyx_t_1) {
      __pyx_t_1 = (__pyx_v_cp <= 0xbfa3ef);
    }
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {

      /* "resiliparse/extract/html2text.pyx":310
 *         memcpy(&cp, element_text.data(), 3 * sizeof(char))
 *         if 0x8080ee <= cp <= 0xbfa3ef:
 *             return True             # <<<<<<<<<<<<<<
 * 
 *     return False
 */
      __pyx_r = 1;
      goto __pyx_L0;

      /* "resiliparse/extract/html2text.pyx":309
 *     if element_text.size() == 3:
 *         memcpy(&cp, element_text.data(), 3 * sizeof(char))
 *         if 0x8080ee <= cp <= 0xbfa3ef:             # <<<<<<<<<<<<<<
 *             return True
 * 
 */
    }

    /* "resiliparse/extract/html2text.pyx":307
 *     # BMP private use area (probably an icon font)
 *     cdef uint32_t cp = 0
 *     if element_text.size() == 3:             # <<<<<<<<<<<<<<
 *         memcpy(&cp, element_text.data(), 3 * sizeof(char))
 *         if 0x8080ee <= cp <= 0xbfa3ef:
 */
  }

  /* "resiliparse/extract/html2text.pyx":312
 *             return True
 * 
 *     return False             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "resiliparse/extract/html2text.pyx":289
 * 
 * 
 * cdef inline bint _is_unprintable_pua(lxb_dom_node_t* node) nogil:             # <<<<<<<<<<<<<<
 *     """Whether text node contains only a single unprintable code point from the private use area."""
 *     if node.first_child and (node.first_child.next or node.first_child.type != LXB_DOM_NODE_TYPE_TEXT):
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "resiliparse/extract/html2text.pyx":340
 * 
 * 
 * cdef inline bint regex_search_not_empty(const StringPiece& s, const RE2& r) nogil:             # <<<<<<<<<<<<<<
 *     if s.empty():
 *         return False
 */

static CYTHON_INLINE int __pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(re2::StringPiece const &__pyx_v_s, RE2Stack const &__pyx_v_r) {
  int __pyx_r;
  int __pyx_t_1;

  /* "resiliparse/extract/html2text.pyx":341
 * 
 * cdef inline bint regex_search_not_empty(const StringPiece& s, const RE2& r) nogil:
 *     if s.empty():             # <<<<<<<<<<<<<<
 *         return False
 *     return PartialMatch(s, r())
 */
  __pyx_t_1 = (__pyx_v_s.empty() != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":342
 * cdef inline bint regex_search_not_empty(const StringPiece& s, const RE2& r) nogil:
 *     if s.empty():
 *         return False             # <<<<<<<<<<<<<<
 *     return PartialMatch(s, r())
 * 
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":341
 * 
 * cdef inline bint regex_search_not_empty(const StringPiece& s, const RE2& r) nogil:
 *     if s.empty():             # <<<<<<<<<<<<<<
 *         return False
 *     return PartialMatch(s, r())
 */
  }

  /* "resiliparse/extract/html2text.pyx":343
 *     if s.empty():
 *         return False
 *     return PartialMatch(s, r())             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = re2::RE2::PartialMatch(__pyx_v_s, __pyx_v_r());
  goto __pyx_L0;

  /* "resiliparse/extract/html2text.pyx":340
 * 
 * 
 * cdef inline bint regex_search_not_empty(const StringPiece& s, const RE2& r) nogil:             # <<<<<<<<<<<<<<
 *     if s.empty():
 *         return False
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "resiliparse/extract/html2text.pyx":346
 * 
 * 
 * cdef inline bint _is_link_cluster(lxb_dom_node_t* node, double max_link_ratio, size_t max_length) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Check if element contains an excessive number of links compared to the whole content length.
 */

static CYTHON_INLINE int __pyx_f_11resiliparse_7extract_9html2text__is_link_cluster(lxb_dom_node_t *__pyx_v_node, double __pyx_v_max_link_ratio, size_t __pyx_v_max_length) {
  std::string __pyx_v_element_text;
  lxb_dom_collection_t *__pyx_v_dom_coll;
  size_t __pyx_v_i;
  std::string __pyx_v_link_texts;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  size_t __pyx_t_3;
  size_t __pyx_t_4;
  size_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "resiliparse/extract/html2text.pyx":355
 *     :return: true if element is a link cluster
 *     """
 *     cdef string element_text = _get_collapsed_string(get_node_text(node))             # <<<<<<<<<<<<<<
 *     if max_length and element_text.size() > max_length:
 *         return False
 */
  __pyx_v_element_text = __pyx_f_11resiliparse_7extract_9html2text__get_collapsed_string(__pyx_f_11resiliparse_5parse_4html_get_node_text(__pyx_v_node));

  /* "resiliparse/extract/html2text.pyx":356
 *     """
 *     cdef string element_text = _get_collapsed_string(get_node_text(node))
 *     if max_length and element_text.size() > max_length:             # <<<<<<<<<<<<<<
 *         return False
 *     dom_coll = lxb_dom_collection_make(node.owner_document, 20)
 */
  __pyx_t_2 = (__pyx_v_max_length != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_element_text.size() > __pyx_v_max_length) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":357
 *     cdef string element_text = _get_collapsed_string(get_node_text(node))
 *     if max_length and element_text.size() > max_length:
 *         return False             # <<<<<<<<<<<<<<
 *     dom_coll = lxb_dom_collection_make(node.owner_document, 20)
 *     lxb_dom_elements_by_tag_name(<lxb_dom_element_t *> node, dom_coll, <const lxb_char_t *> b'a', 1)
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":356
 *     """
 *     cdef string element_text = _get_collapsed_string(get_node_text(node))
 *     if max_length and element_text.size() > max_length:             # <<<<<<<<<<<<<<
 *         return False
 *     dom_coll = lxb_dom_collection_make(node.owner_document, 20)
 */
  }

  /* "resiliparse/extract/html2text.pyx":358
 *     if max_length and element_text.size() > max_length:
 *         return False
 *     dom_coll = lxb_dom_collection_make(node.owner_document, 20)             # <<<<<<<<<<<<<<
 *     lxb_dom_elements_by_tag_name(<lxb_dom_element_t *> node, dom_coll, <const lxb_char_t *> b'a', 1)
 *     cdef size_t i
 */
  __pyx_v_dom_coll = lxb_dom_collection_make(__pyx_v_node->owner_document, 20);

  /* "resiliparse/extract/html2text.pyx":359
 *         return False
 *     dom_coll = lxb_dom_collection_make(node.owner_document, 20)
 *     lxb_dom_elements_by_tag_name(<lxb_dom_element_t *> node, dom_coll, <const lxb_char_t *> b'a', 1)             # <<<<<<<<<<<<<<
 *     cdef size_t i
 *     cdef string link_texts
 */
  (void)(lxb_dom_elements_by_tag_name(((lxb_dom_element_t *)__pyx_v_node), __pyx_v_dom_coll, ((lxb_char_t const *)((lxb_char_t const *)((char const *)"a"))), 1));

  /* "resiliparse/extract/html2text.pyx":362
 *     cdef size_t i
 *     cdef string link_texts
 *     link_texts.reserve(element_text.size())             # <<<<<<<<<<<<<<
 *     for i in range(lxb_dom_collection_length(dom_coll)):
 *         link_texts.append(_get_collapsed_string(get_node_text(lxb_dom_collection_node(dom_coll, i))))
 */
  try {
    __pyx_v_link_texts.reserve(__pyx_v_element_text.size());
  } catch(...) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
    #endif
    __Pyx_CppExn2PyErr();
    #ifdef WITH_THREAD
    __Pyx_PyGILState_Release(__pyx_gilstate_save);
    #endif
    __PYX_ERR(0, 362, __pyx_L1_error)
  }

  /* "resiliparse/extract/html2text.pyx":363
 *     cdef string link_texts
 *     link_texts.reserve(element_text.size())
 *     for i in range(lxb_dom_collection_length(dom_coll)):             # <<<<<<<<<<<<<<
 *         link_texts.append(_get_collapsed_string(get_node_text(lxb_dom_collection_node(dom_coll, i))))
 *     lxb_dom_collection_destroy(dom_coll, True)
 */
  __pyx_t_3 = lxb_dom_collection_length(__pyx_v_dom_coll);
  __pyx_t_4 = __pyx_t_3;
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "resiliparse/extract/html2text.pyx":364
 *     link_texts.reserve(element_text.size())
 *     for i in range(lxb_dom_collection_length(dom_coll)):
 *         link_texts.append(_get_collapsed_string(get_node_text(lxb_dom_collection_node(dom_coll, i))))             # <<<<<<<<<<<<<<
 *     lxb_dom_collection_destroy(dom_coll, True)
 *     if not link_texts.empty() and link_texts.size() / <double> element_text.size() > max_link_ratio:
 */
    try {
      __pyx_v_link_texts.append(__pyx_f_11resiliparse_7extract_9html2text__get_collapsed_string(__pyx_f_11resiliparse_5parse_4html_get_node_text(lxb_dom_collection_node(__pyx_v_dom_coll, __pyx_v_i))));
    } catch(...) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      __Pyx_CppExn2PyErr();
      #ifdef WITH_THREAD
      __Pyx_PyGILState_Release(__pyx_gilstate_save);
      #endif
      __PYX_ERR(0, 364, __pyx_L1_error)
    }
  }

  /* "resiliparse/extract/html2text.pyx":365
 *     for i in range(lxb_dom_collection_length(dom_coll)):
 *         link_texts.append(_get_collapsed_string(get_node_text(lxb_dom_collection_node(dom_coll, i))))
 *     lxb_dom_collection_destroy(dom_coll, True)             # <<<<<<<<<<<<<<
 *     if not link_texts.empty() and link_texts.size() / <double> element_text.size() > max_link_ratio:
 *         return True
 */
  (void)(lxb_dom_collection_destroy(__pyx_v_dom_coll, 1));

  /* "resiliparse/extract/html2text.pyx":366
 *         link_texts.append(_get_collapsed_string(get_node_text(lxb_dom_collection_node(dom_coll, i))))
 *     lxb_dom_collection_destroy(dom_coll, True)
 *     if not link_texts.empty() and link_texts.size() / <double> element_text.size() > max_link_ratio:             # <<<<<<<<<<<<<<
 *         return True
 *     return False
 */
  __pyx_t_2 = ((!(__pyx_v_link_texts.empty() != 0)) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_2 = (((((double)__pyx_v_link_texts.size()) / ((double)__pyx_v_element_text.size())) > __pyx_v_max_link_ratio) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L9_bool_binop_done:;
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":367
 *     lxb_dom_collection_destroy(dom_coll, True)
 *     if not link_texts.empty() and link_texts.size() / <double> element_text.size() > max_link_ratio:
 *         return True             # <<<<<<<<<<<<<<
 *     return False
 * 
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":366
 *         link_texts.append(_get_collapsed_string(get_node_text(lxb_dom_collection_node(dom_coll, i))))
 *     lxb_dom_collection_destroy(dom_coll, True)
 *     if not link_texts.empty() and link_texts.size() / <double> element_text.size() > max_link_ratio:             # <<<<<<<<<<<<<<
 *         return True
 *     return False
 */
  }

  /* "resiliparse/extract/html2text.pyx":368
 *     if not link_texts.empty() and link_texts.size() / <double> element_text.size() > max_link_ratio:
 *         return True
 *     return False             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 0;
  goto __pyx_L0;

  /* "resiliparse/extract/html2text.pyx":346
 * 
 * 
 * cdef inline bint _is_link_cluster(lxb_dom_node_t* node, double max_link_ratio, size_t max_length) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Check if element contains an excessive number of links compared to the whole content length.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("resiliparse.extract.html2text._is_link_cluster", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 1);
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "resiliparse/extract/html2text.pyx":378
 * 
 * # noinspection DuplicatedCode
 * cdef inline bint _is_main_content_node(lxb_dom_node_t* node, size_t body_depth, bint allow_comments) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Perform a rule-based check whether the given element is a "main-content" element.
 */

static CYTHON_INLINE int __pyx_f_11resiliparse_7extract_9html2text__is_main_content_node(lxb_dom_node_t *__pyx_v_node, size_t __pyx_v_body_depth, int __pyx_v_allow_comments) {
  lxb_dom_node_t *__pyx_v_pnode;
  std::string_view __pyx_v_rel_attr;
  std::string_view __pyx_v_itemprop_attr;
  re2::StringPiece __pyx_v_cls_attr;
  re2::StringPiece __pyx_v_id_attr;
  std::string __pyx_v_cls_and_id_attr_str;
  re2::StringPiece __pyx_v_cls_and_id_attr;
  std::string_view __pyx_v_role_attr;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  lxb_dom_node_t *__pyx_t_3;
  std::string_view __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "resiliparse/extract/html2text.pyx":388
 *     """
 * 
 *     if node.type == LXB_DOM_NODE_TYPE_TEXT:             # <<<<<<<<<<<<<<
 *         return not _is_unprintable_pua(node)
 *     elif node.type != LXB_DOM_NODE_TYPE_ELEMENT:
 */
  __pyx_t_1 = ((__pyx_v_node->type == LXB_DOM_NODE_TYPE_TEXT) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":389
 * 
 *     if node.type == LXB_DOM_NODE_TYPE_TEXT:
 *         return not _is_unprintable_pua(node)             # <<<<<<<<<<<<<<
 *     elif node.type != LXB_DOM_NODE_TYPE_ELEMENT:
 *         return True
 */
    __pyx_r = (!(__pyx_f_11resiliparse_7extract_9html2text__is_unprintable_pua(__pyx_v_node) != 0));
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":388
 *     """
 * 
 *     if node.type == LXB_DOM_NODE_TYPE_TEXT:             # <<<<<<<<<<<<<<
 *         return not _is_unprintable_pua(node)
 *     elif node.type != LXB_DOM_NODE_TYPE_ELEMENT:
 */
  }

  /* "resiliparse/extract/html2text.pyx":390
 *     if node.type == LXB_DOM_NODE_TYPE_TEXT:
 *         return not _is_unprintable_pua(node)
 *     elif node.type != LXB_DOM_NODE_TYPE_ELEMENT:             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  __pyx_t_1 = ((__pyx_v_node->type != LXB_DOM_NODE_TYPE_ELEMENT) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":391
 *         return not _is_unprintable_pua(node)
 *     elif node.type != LXB_DOM_NODE_TYPE_ELEMENT:
 *         return True             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":390
 *     if node.type == LXB_DOM_NODE_TYPE_TEXT:
 *         return not _is_unprintable_pua(node)
 *     elif node.type != LXB_DOM_NODE_TYPE_ELEMENT:             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":397
 * 
 *     # Main elements and headings
 *     if node.local_name in [LXB_TAG_BODY, LXB_TAG_MAIN, LXB_TAG_H1]:             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  switch (__pyx_v_node->local_name) {
    case LXB_TAG_BODY:
    case LXB_TAG_MAIN:
    case LXB_TAG_H1:

    /* "resiliparse/extract/html2text.pyx":398
 *     # Main elements and headings
 *     if node.local_name in [LXB_TAG_BODY, LXB_TAG_MAIN, LXB_TAG_H1]:
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     # Global footer
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":397
 * 
 *     # Main elements and headings
 *     if node.local_name in [LXB_TAG_BODY, LXB_TAG_MAIN, LXB_TAG_H1]:             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
    break;
    case LXB_TAG_FOOTER:

    /* "resiliparse/extract/html2text.pyx":402
 *     # Global footer
 *     elif node.local_name == LXB_TAG_FOOTER:
 *         if body_depth < 3 or _is_link_cluster(node, 0.2, 0):             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
    __pyx_t_2 = ((__pyx_v_body_depth < 3) != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_2 = (__pyx_f_11resiliparse_7extract_9html2text__is_link_cluster(__pyx_v_node, 0.2, 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L5_bool_binop_done:;
    if (__pyx_t_1) {

      /* "resiliparse/extract/html2text.pyx":403
 *     elif node.local_name == LXB_TAG_FOOTER:
 *         if body_depth < 3 or _is_link_cluster(node, 0.2, 0):
 *             return False             # <<<<<<<<<<<<<<
 * 
 *         # Check if footer is recursive last element node of a direct body child
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "resiliparse/extract/html2text.pyx":402
 *     # Global footer
 *     elif node.local_name == LXB_TAG_FOOTER:
 *         if body_depth < 3 or _is_link_cluster(node, 0.2, 0):             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
    }

    /* "resiliparse/extract/html2text.pyx":406
 * 
 *         # Check if footer is recursive last element node of a direct body child
 *         pnode = node             # <<<<<<<<<<<<<<
 *         while pnode and pnode.parent and pnode.parent.local_name != LXB_TAG_BODY:
 *             if pnode.next and pnode.next.type == LXB_DOM_NODE_TYPE_TEXT:
 */
    __pyx_v_pnode = __pyx_v_node;

    /* "resiliparse/extract/html2text.pyx":407
 *         # Check if footer is recursive last element node of a direct body child
 *         pnode = node
 *         while pnode and pnode.parent and pnode.parent.local_name != LXB_TAG_BODY:             # <<<<<<<<<<<<<<
 *             if pnode.next and pnode.next.type == LXB_DOM_NODE_TYPE_TEXT:
 *                 pnode = pnode.next
 */
    while (1) {
      __pyx_t_2 = (__pyx_v_pnode != 0);
      if (__pyx_t_2) {
      } else {
        __pyx_t_1 = __pyx_t_2;
        goto __pyx_L9_bool_binop_done;
      }
      __pyx_t_2 = (__pyx_v_pnode->parent != 0);
      if (__pyx_t_2) {
      } else {
        __pyx_t_1 = __pyx_t_2;
        goto __pyx_L9_bool_binop_done;
      }
      __pyx_t_2 = ((__pyx_v_pnode->parent->local_name != LXB_TAG_BODY) != 0);
      __pyx_t_1 = __pyx_t_2;
      __pyx_L9_bool_binop_done:;
      if (!__pyx_t_1) break;

      /* "resiliparse/extract/html2text.pyx":408
 *         pnode = node
 *         while pnode and pnode.parent and pnode.parent.local_name != LXB_TAG_BODY:
 *             if pnode.next and pnode.next.type == LXB_DOM_NODE_TYPE_TEXT:             # <<<<<<<<<<<<<<
 *                 pnode = pnode.next
 *             if pnode.next:
 */
      __pyx_t_2 = (__pyx_v_pnode->next != 0);
      if (__pyx_t_2) {
      } else {
        __pyx_t_1 = __pyx_t_2;
        goto __pyx_L13_bool_binop_done;
      }
      __pyx_t_2 = ((__pyx_v_pnode->next->type == LXB_DOM_NODE_TYPE_TEXT) != 0);
      __pyx_t_1 = __pyx_t_2;
      __pyx_L13_bool_binop_done:;
      if (__pyx_t_1) {

        /* "resiliparse/extract/html2text.pyx":409
 *         while pnode and pnode.parent and pnode.parent.local_name != LXB_TAG_BODY:
 *             if pnode.next and pnode.next.type == LXB_DOM_NODE_TYPE_TEXT:
 *                 pnode = pnode.next             # <<<<<<<<<<<<<<
 *             if pnode.next:
 *                 # There is at least one more element node
 */
        __pyx_t_3 = __pyx_v_pnode->next;
        __pyx_v_pnode = __pyx_t_3;

        /* "resiliparse/extract/html2text.pyx":408
 *         pnode = node
 *         while pnode and pnode.parent and pnode.parent.local_name != LXB_TAG_BODY:
 *             if pnode.next and pnode.next.type == LXB_DOM_NODE_TYPE_TEXT:             # <<<<<<<<<<<<<<
 *                 pnode = pnode.next
 *             if pnode.next:
 */
      }

      /* "resiliparse/extract/html2text.pyx":410
 *             if pnode.next and pnode.next.type == LXB_DOM_NODE_TYPE_TEXT:
 *                 pnode = pnode.next
 *             if pnode.next:             # <<<<<<<<<<<<<<
 *                 # There is at least one more element node
 *                 return True
 */
      __pyx_t_1 = (__pyx_v_pnode->next != 0);
      if (__pyx_t_1) {

        /* "resiliparse/extract/html2text.pyx":412
 *             if pnode.next:
 *                 # There is at least one more element node
 *                 return True             # <<<<<<<<<<<<<<
 *             pnode = pnode.parent
 *         return False
 */
        __pyx_r = 1;
        goto __pyx_L0;

        /* "resiliparse/extract/html2text.pyx":410
 *             if pnode.next and pnode.next.type == LXB_DOM_NODE_TYPE_TEXT:
 *                 pnode = pnode.next
 *             if pnode.next:             # <<<<<<<<<<<<<<
 *                 # There is at least one more element node
 *                 return True
 */
      }

      /* "resiliparse/extract/html2text.pyx":413
 *                 # There is at least one more element node
 *                 return True
 *             pnode = pnode.parent             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
      __pyx_t_3 = __pyx_v_pnode->parent;
      __pyx_v_pnode = __pyx_t_3;
    }

    /* "resiliparse/extract/html2text.pyx":414
 *                 return True
 *             pnode = pnode.parent
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     elif node.local_name == LXB_TAG_UL:
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":401
 * 
 *     # Global footer
 *     elif node.local_name == LXB_TAG_FOOTER:             # <<<<<<<<<<<<<<
 *         if body_depth < 3 or _is_link_cluster(node, 0.2, 0):
 *             return False
 */
    break;
    case LXB_TAG_UL:

    /* "resiliparse/extract/html2text.pyx":417
 * 
 *     elif node.local_name == LXB_TAG_UL:
 *         if body_depth < 4 or _is_link_cluster(node, 0.2, 0):             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
    __pyx_t_2 = ((__pyx_v_body_depth < 4) != 0);
    if (!__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L17_bool_binop_done;
    }
    __pyx_t_2 = (__pyx_f_11resiliparse_7extract_9html2text__is_link_cluster(__pyx_v_node, 0.2, 0) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L17_bool_binop_done:;
    if (__pyx_t_1) {

      /* "resiliparse/extract/html2text.pyx":418
 *     elif node.local_name == LXB_TAG_UL:
 *         if body_depth < 4 or _is_link_cluster(node, 0.2, 0):
 *             return False             # <<<<<<<<<<<<<<
 * 
 *     # Teaser articles
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "resiliparse/extract/html2text.pyx":417
 * 
 *     elif node.local_name == LXB_TAG_UL:
 *         if body_depth < 4 or _is_link_cluster(node, 0.2, 0):             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
    }

    /* "resiliparse/extract/html2text.pyx":416
 *         return False
 * 
 *     elif node.local_name == LXB_TAG_UL:             # <<<<<<<<<<<<<<
 *         if body_depth < 4 or _is_link_cluster(node, 0.2, 0):
 *             return False
 */
    break;
    case LXB_TAG_ARTICLE:

    /* "resiliparse/extract/html2text.pyx":422
 *     # Teaser articles
 *     elif node.local_name == LXB_TAG_ARTICLE:
 *         if body_depth > 2 and _is_link_cluster(node, 0.2, 500):             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
    __pyx_t_2 = ((__pyx_v_body_depth > 2) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L20_bool_binop_done;
    }
    __pyx_t_2 = (__pyx_f_11resiliparse_7extract_9html2text__is_link_cluster(__pyx_v_node, 0.2, 0x1F4) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L20_bool_binop_done:;
    if (__pyx_t_1) {

      /* "resiliparse/extract/html2text.pyx":423
 *     elif node.local_name == LXB_TAG_ARTICLE:
 *         if body_depth > 2 and _is_link_cluster(node, 0.2, 500):
 *             return False             # <<<<<<<<<<<<<<
 * 
 *     # Navigation, sidebar, other hard-blacklisted elements
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "resiliparse/extract/html2text.pyx":422
 *     # Teaser articles
 *     elif node.local_name == LXB_TAG_ARTICLE:
 *         if body_depth > 2 and _is_link_cluster(node, 0.2, 500):             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
    }

    /* "resiliparse/extract/html2text.pyx":421
 * 
 *     # Teaser articles
 *     elif node.local_name == LXB_TAG_ARTICLE:             # <<<<<<<<<<<<<<
 *         if body_depth > 2 and _is_link_cluster(node, 0.2, 500):
 *             return False
 */
    break;
    case LXB_TAG_NAV:

    /* "resiliparse/extract/html2text.pyx":426
 * 
 *     # Navigation, sidebar, other hard-blacklisted elements
 *     elif node.local_name in [LXB_TAG_NAV, LXB_TAG_ASIDE, LXB_TAG_AUDIO, LXB_TAG_VIDEO, LXB_TAG_TIME]:             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
    case LXB_TAG_ASIDE:
    case LXB_TAG_AUDIO:
    case LXB_TAG_VIDEO:
    case LXB_TAG_TIME:

    /* "resiliparse/extract/html2text.pyx":427
 *     # Navigation, sidebar, other hard-blacklisted elements
 *     elif node.local_name in [LXB_TAG_NAV, LXB_TAG_ASIDE, LXB_TAG_AUDIO, LXB_TAG_VIDEO, LXB_TAG_TIME]:
 *         return False             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":426
 * 
 *     # Navigation, sidebar, other hard-blacklisted elements
 *     elif node.local_name in [LXB_TAG_NAV, LXB_TAG_ASIDE, LXB_TAG_AUDIO, LXB_TAG_VIDEO, LXB_TAG_TIME]:             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
    break;
    default: break;
  }

  /* "resiliparse/extract/html2text.pyx":433
 * 
 *     # Hidden elements
 *     if lxb_dom_element_has_attribute(<lxb_dom_element_t*>node, <const lxb_char_t*>b'hidden', 6):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_1 = (lxb_dom_element_has_attribute(((lxb_dom_element_t *)__pyx_v_node), ((lxb_char_t const *)((lxb_char_t const *)((char const *)"hidden"))), 6) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":434
 *     # Hidden elements
 *     if lxb_dom_element_has_attribute(<lxb_dom_element_t*>node, <const lxb_char_t*>b'hidden', 6):
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     # rel attributes
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":433
 * 
 *     # Hidden elements
 *     if lxb_dom_element_has_attribute(<lxb_dom_element_t*>node, <const lxb_char_t*>b'hidden', 6):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":437
 * 
 *     # rel attributes
 *     cdef string_view rel_attr = get_node_attr_sv(node, b'rel')             # <<<<<<<<<<<<<<
 *     if not rel_attr.empty() and rel_attr in [b'author', b'icon', b'search', b'prev', b'next', b'tag']:
 *         return False
 */
  __pyx_v_rel_attr = __pyx_f_11resiliparse_5parse_4html_get_node_attr_sv(__pyx_v_node, __pyx_k_rel);

  /* "resiliparse/extract/html2text.pyx":438
 *     # rel attributes
 *     cdef string_view rel_attr = get_node_attr_sv(node, b'rel')
 *     if not rel_attr.empty() and rel_attr in [b'author', b'icon', b'search', b'prev', b'next', b'tag']:             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_rel_attr.empty() != 0)) != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L24_bool_binop_done;
  }
  __pyx_t_4 = __pyx_v_rel_attr;
  __pyx_t_5 = ((__pyx_t_4 == ((char const *)"author")) != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_2 = __pyx_t_5;
    goto __pyx_L26_bool_binop_done;
  }
  __pyx_t_5 = ((__pyx_t_4 == ((char const *)"icon")) != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_2 = __pyx_t_5;
    goto __pyx_L26_bool_binop_done;
  }
  __pyx_t_5 = ((__pyx_t_4 == ((char const *)"search")) != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_2 = __pyx_t_5;
    goto __pyx_L26_bool_binop_done;
  }
  __pyx_t_5 = ((__pyx_t_4 == ((char const *)"prev")) != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_2 = __pyx_t_5;
    goto __pyx_L26_bool_binop_done;
  }
  __pyx_t_5 = ((__pyx_t_4 == ((char const *)"next")) != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_2 = __pyx_t_5;
    goto __pyx_L26_bool_binop_done;
  }
  __pyx_t_5 = ((__pyx_t_4 == ((char const *)"tag")) != 0);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L26_bool_binop_done:;
  __pyx_t_5 = (__pyx_t_2 != 0);
  __pyx_t_1 = __pyx_t_5;
  __pyx_L24_bool_binop_done:;
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":439
 *     cdef string_view rel_attr = get_node_attr_sv(node, b'rel')
 *     if not rel_attr.empty() and rel_attr in [b'author', b'icon', b'search', b'prev', b'next', b'tag']:
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     # itemprop attributes
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":438
 *     # rel attributes
 *     cdef string_view rel_attr = get_node_attr_sv(node, b'rel')
 *     if not rel_attr.empty() and rel_attr in [b'author', b'icon', b'search', b'prev', b'next', b'tag']:             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":442
 * 
 *     # itemprop attributes
 *     cdef string_view itemprop_attr = get_node_attr_sv(node, b'itemprop')             # <<<<<<<<<<<<<<
 *     if not itemprop_attr.empty() and itemprop_attr in [b'datePublished', b'author', b'url']:
 *         return False
 */
  __pyx_v_itemprop_attr = __pyx_f_11resiliparse_5parse_4html_get_node_attr_sv(__pyx_v_node, __pyx_k_itemprop);

  /* "resiliparse/extract/html2text.pyx":443
 *     # itemprop attributes
 *     cdef string_view itemprop_attr = get_node_attr_sv(node, b'itemprop')
 *     if not itemprop_attr.empty() and itemprop_attr in [b'datePublished', b'author', b'url']:             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_5 = ((!(__pyx_v_itemprop_attr.empty() != 0)) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L33_bool_binop_done;
  }
  __pyx_t_4 = __pyx_v_itemprop_attr;
  __pyx_t_2 = ((__pyx_t_4 == ((char const *)"datePublished")) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_5 = __pyx_t_2;
    goto __pyx_L35_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_t_4 == ((char const *)"author")) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_5 = __pyx_t_2;
    goto __pyx_L35_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_t_4 == ((char const *)"url")) != 0);
  __pyx_t_5 = __pyx_t_2;
  __pyx_L35_bool_binop_done:;
  __pyx_t_2 = (__pyx_t_5 != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L33_bool_binop_done:;
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":444
 *     cdef string_view itemprop_attr = get_node_attr_sv(node, b'itemprop')
 *     if not itemprop_attr.empty() and itemprop_attr in [b'datePublished', b'author', b'url']:
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     # ARIA hidden
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":443
 *     # itemprop attributes
 *     cdef string_view itemprop_attr = get_node_attr_sv(node, b'itemprop')
 *     if not itemprop_attr.empty() and itemprop_attr in [b'datePublished', b'author', b'url']:             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":447
 * 
 *     # ARIA hidden
 *     if get_node_attr_sv(node, b'aria-hidden') == b'true':             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_1 = ((__pyx_f_11resiliparse_5parse_4html_get_node_attr_sv(__pyx_v_node, __pyx_k_aria_hidden) == ((char const *)"true")) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":448
 *     # ARIA hidden
 *     if get_node_attr_sv(node, b'aria-hidden') == b'true':
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     # ARIA expanded
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":447
 * 
 *     # ARIA hidden
 *     if get_node_attr_sv(node, b'aria-hidden') == b'true':             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":451
 * 
 *     # ARIA expanded
 *     if get_node_attr_sv(node, b'aria-expanded') == b'false':             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_1 = ((__pyx_f_11resiliparse_5parse_4html_get_node_attr_sv(__pyx_v_node, __pyx_k_aria_expanded) == ((char const *)"false")) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":452
 *     # ARIA expanded
 *     if get_node_attr_sv(node, b'aria-expanded') == b'false':
 *         return False             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":451
 * 
 *     # ARIA expanded
 *     if get_node_attr_sv(node, b'aria-expanded') == b'false':             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":457
 *     # ------ Section 3: General class and ID matching ------
 * 
 *     cdef StringPiece cls_attr = get_node_attr_sp(node, b'class')             # <<<<<<<<<<<<<<
 *     cdef StringPiece id_attr = get_node_attr_sp(node, b'id')
 *     # Only elements with class or id attributes from here on
 */
  __pyx_v_cls_attr = __pyx_f_11resiliparse_5parse_4html_get_node_attr_sp(__pyx_v_node, __pyx_k_class);

  /* "resiliparse/extract/html2text.pyx":458
 * 
 *     cdef StringPiece cls_attr = get_node_attr_sp(node, b'class')
 *     cdef StringPiece id_attr = get_node_attr_sp(node, b'id')             # <<<<<<<<<<<<<<
 *     # Only elements with class or id attributes from here on
 *     if cls_attr.empty() and id_attr.empty():
 */
  __pyx_v_id_attr = __pyx_f_11resiliparse_5parse_4html_get_node_attr_sp(__pyx_v_node, __pyx_k_id);

  /* "resiliparse/extract/html2text.pyx":460
 *     cdef StringPiece id_attr = get_node_attr_sp(node, b'id')
 *     # Only elements with class or id attributes from here on
 *     if cls_attr.empty() and id_attr.empty():             # <<<<<<<<<<<<<<
 *         if node.local_name == LXB_TAG_DIV:
 *             return body_depth <= 5 or not _is_link_cluster(node, 0.6, 800)
 */
  __pyx_t_2 = (__pyx_v_cls_attr.empty() != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L41_bool_binop_done;
  }
  __pyx_t_2 = (__pyx_v_id_attr.empty() != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L41_bool_binop_done:;
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":461
 *     # Only elements with class or id attributes from here on
 *     if cls_attr.empty() and id_attr.empty():
 *         if node.local_name == LXB_TAG_DIV:             # <<<<<<<<<<<<<<
 *             return body_depth <= 5 or not _is_link_cluster(node, 0.6, 800)
 *         return True
 */
    __pyx_t_1 = ((__pyx_v_node->local_name == LXB_TAG_DIV) != 0);
    if (__pyx_t_1) {

      /* "resiliparse/extract/html2text.pyx":462
 *     if cls_attr.empty() and id_attr.empty():
 *         if node.local_name == LXB_TAG_DIV:
 *             return body_depth <= 5 or not _is_link_cluster(node, 0.6, 800)             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
      __pyx_t_2 = ((__pyx_v_body_depth <= 5) != 0);
      if (!__pyx_t_2) {
      } else {
        __pyx_t_1 = __pyx_t_2;
        goto __pyx_L44_bool_binop_done;
      }
      __pyx_t_2 = ((!(__pyx_f_11resiliparse_7extract_9html2text__is_link_cluster(__pyx_v_node, 0.6, 0x320) != 0)) != 0);
      __pyx_t_1 = __pyx_t_2;
      __pyx_L44_bool_binop_done:;
      __pyx_r = __pyx_t_1;
      goto __pyx_L0;

      /* "resiliparse/extract/html2text.pyx":461
 *     # Only elements with class or id attributes from here on
 *     if cls_attr.empty() and id_attr.empty():
 *         if node.local_name == LXB_TAG_DIV:             # <<<<<<<<<<<<<<
 *             return body_depth <= 5 or not _is_link_cluster(node, 0.6, 800)
 *         return True
 */
    }

    /* "resiliparse/extract/html2text.pyx":463
 *         if node.local_name == LXB_TAG_DIV:
 *             return body_depth <= 5 or not _is_link_cluster(node, 0.6, 800)
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     cdef string cls_and_id_attr_str = cls_attr.as_string()
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":460
 *     cdef StringPiece id_attr = get_node_attr_sp(node, b'id')
 *     # Only elements with class or id attributes from here on
 *     if cls_attr.empty() and id_attr.empty():             # <<<<<<<<<<<<<<
 *         if node.local_name == LXB_TAG_DIV:
 *             return body_depth <= 5 or not _is_link_cluster(node, 0.6, 800)
 */
  }

  /* "resiliparse/extract/html2text.pyx":465
 *         return True
 * 
 *     cdef string cls_and_id_attr_str = cls_attr.as_string()             # <<<<<<<<<<<<<<
 *     if not cls_and_id_attr_str.empty():
 *         cls_and_id_attr_str.push_back(b' ')
 */
  __pyx_v_cls_and_id_attr_str = __pyx_v_cls_attr.as_string();

  /* "resiliparse/extract/html2text.pyx":466
 * 
 *     cdef string cls_and_id_attr_str = cls_attr.as_string()
 *     if not cls_and_id_attr_str.empty():             # <<<<<<<<<<<<<<
 *         cls_and_id_attr_str.push_back(b' ')
 *     cls_and_id_attr_str.append(id_attr.as_string())
 */
  __pyx_t_1 = ((!(__pyx_v_cls_and_id_attr_str.empty() != 0)) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":467
 *     cdef string cls_and_id_attr_str = cls_attr.as_string()
 *     if not cls_and_id_attr_str.empty():
 *         cls_and_id_attr_str.push_back(b' ')             # <<<<<<<<<<<<<<
 *     cls_and_id_attr_str.append(id_attr.as_string())
 *     cdef StringPiece cls_and_id_attr = StringPiece(cls_and_id_attr_str)
 */
    try {
      __pyx_v_cls_and_id_attr_str.push_back(' ');
    } catch(...) {
      #ifdef WITH_THREAD
      PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
      #endif
      __Pyx_CppExn2PyErr();
      #ifdef WITH_THREAD
      __Pyx_PyGILState_Release(__pyx_gilstate_save);
      #endif
      __PYX_ERR(0, 467, __pyx_L1_error)
    }

    /* "resiliparse/extract/html2text.pyx":466
 * 
 *     cdef string cls_and_id_attr_str = cls_attr.as_string()
 *     if not cls_and_id_attr_str.empty():             # <<<<<<<<<<<<<<
 *         cls_and_id_attr_str.push_back(b' ')
 *     cls_and_id_attr_str.append(id_attr.as_string())
 */
  }

  /* "resiliparse/extract/html2text.pyx":468
 *     if not cls_and_id_attr_str.empty():
 *         cls_and_id_attr_str.push_back(b' ')
 *     cls_and_id_attr_str.append(id_attr.as_string())             # <<<<<<<<<<<<<<
 *     cdef StringPiece cls_and_id_attr = StringPiece(cls_and_id_attr_str)
 * 
 */
  try {
    __pyx_v_cls_and_id_attr_str.append(__pyx_v_id_attr.as_string());
  } catch(...) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
    #endif
    __Pyx_CppExn2PyErr();
    #ifdef WITH_THREAD
    __Pyx_PyGILState_Release(__pyx_gilstate_save);
    #endif
    __PYX_ERR(0, 468, __pyx_L1_error)
  }

  /* "resiliparse/extract/html2text.pyx":469
 *         cls_and_id_attr_str.push_back(b' ')
 *     cls_and_id_attr_str.append(id_attr.as_string())
 *     cdef StringPiece cls_and_id_attr = StringPiece(cls_and_id_attr_str)             # <<<<<<<<<<<<<<
 * 
 *     # Hidden elements
 */
  __pyx_v_cls_and_id_attr = re2::StringPiece(__pyx_v_cls_and_id_attr_str);

  /* "resiliparse/extract/html2text.pyx":472
 * 
 *     # Hidden elements
 *     if regex_search_not_empty(cls_attr, display_cls_regex) \             # <<<<<<<<<<<<<<
 *             or regex_search_not_empty(get_node_attr_sp(node, b'style'), display_css_regex):
 *         return False
 */
  __pyx_t_2 = (__pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(__pyx_v_cls_attr, __pyx_v_11resiliparse_7extract_9html2text_display_cls_regex) != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L48_bool_binop_done;
  }

  /* "resiliparse/extract/html2text.pyx":473
 *     # Hidden elements
 *     if regex_search_not_empty(cls_attr, display_cls_regex) \
 *             or regex_search_not_empty(get_node_attr_sp(node, b'style'), display_css_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_2 = (__pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(__pyx_f_11resiliparse_5parse_4html_get_node_attr_sp(__pyx_v_node, __pyx_k_style), __pyx_v_11resiliparse_7extract_9html2text_display_css_regex) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L48_bool_binop_done:;

  /* "resiliparse/extract/html2text.pyx":472
 * 
 *     # Hidden elements
 *     if regex_search_not_empty(cls_attr, display_cls_regex) \             # <<<<<<<<<<<<<<
 *             or regex_search_not_empty(get_node_attr_sp(node, b'style'), display_css_regex):
 *         return False
 */
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":474
 *     if regex_search_not_empty(cls_attr, display_cls_regex) \
 *             or regex_search_not_empty(get_node_attr_sp(node, b'style'), display_css_regex):
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     # Skip links
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":472
 * 
 *     # Hidden elements
 *     if regex_search_not_empty(cls_attr, display_cls_regex) \             # <<<<<<<<<<<<<<
 *             or regex_search_not_empty(get_node_attr_sp(node, b'style'), display_css_regex):
 *         return False
 */
  }

  /* "resiliparse/extract/html2text.pyx":477
 * 
 *     # Skip links
 *     if node.local_name in [LXB_TAG_A, LXB_TAG_DIV, LXB_TAG_LI] and \             # <<<<<<<<<<<<<<
 *             regex_search_not_empty(cls_and_id_attr, skip_link_cls_regex):
 *         return False
 */
  switch (__pyx_v_node->local_name) {
    case LXB_TAG_A:
    case LXB_TAG_DIV:
    case LXB_TAG_LI:
    __pyx_t_2 = 1;
    break;
    default:
    __pyx_t_2 = 0;
    break;
  }
  __pyx_t_5 = (__pyx_t_2 != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L51_bool_binop_done;
  }

  /* "resiliparse/extract/html2text.pyx":478
 *     # Skip links
 *     if node.local_name in [LXB_TAG_A, LXB_TAG_DIV, LXB_TAG_LI] and \
 *             regex_search_not_empty(cls_and_id_attr, skip_link_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_5 = (__pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(__pyx_v_cls_and_id_attr, __pyx_v_11resiliparse_7extract_9html2text_skip_link_cls_regex) != 0);
  __pyx_t_1 = __pyx_t_5;
  __pyx_L51_bool_binop_done:;

  /* "resiliparse/extract/html2text.pyx":477
 * 
 *     # Skip links
 *     if node.local_name in [LXB_TAG_A, LXB_TAG_DIV, LXB_TAG_LI] and \             # <<<<<<<<<<<<<<
 *             regex_search_not_empty(cls_and_id_attr, skip_link_cls_regex):
 *         return False
 */
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":479
 *     if node.local_name in [LXB_TAG_A, LXB_TAG_DIV, LXB_TAG_LI] and \
 *             regex_search_not_empty(cls_and_id_attr, skip_link_cls_regex):
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     if body_depth > 2:
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":477
 * 
 *     # Skip links
 *     if node.local_name in [LXB_TAG_A, LXB_TAG_DIV, LXB_TAG_LI] and \             # <<<<<<<<<<<<<<
 *             regex_search_not_empty(cls_and_id_attr, skip_link_cls_regex):
 *         return False
 */
  }

  /* "resiliparse/extract/html2text.pyx":481
 *         return False
 * 
 *     if body_depth > 2:             # <<<<<<<<<<<<<<
 *         # Sign-in links
 *         if regex_search_not_empty(cls_attr, signin_cls_regex):
 */
  __pyx_t_1 = ((__pyx_v_body_depth > 2) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":483
 *     if body_depth > 2:
 *         # Sign-in links
 *         if regex_search_not_empty(cls_attr, signin_cls_regex):             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
    __pyx_t_1 = (__pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(__pyx_v_cls_attr, __pyx_v_11resiliparse_7extract_9html2text_signin_cls_regex) != 0);
    if (__pyx_t_1) {

      /* "resiliparse/extract/html2text.pyx":484
 *         # Sign-in links
 *         if regex_search_not_empty(cls_attr, signin_cls_regex):
 *             return False             # <<<<<<<<<<<<<<
 * 
 *         # Post meta
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "resiliparse/extract/html2text.pyx":483
 *     if body_depth > 2:
 *         # Sign-in links
 *         if regex_search_not_empty(cls_attr, signin_cls_regex):             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
    }

    /* "resiliparse/extract/html2text.pyx":487
 * 
 *         # Post meta
 *         if regex_search_not_empty(cls_attr, post_meta_cls_regex):             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
    __pyx_t_1 = (__pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(__pyx_v_cls_attr, __pyx_v_11resiliparse_7extract_9html2text_post_meta_cls_regex) != 0);
    if (__pyx_t_1) {

      /* "resiliparse/extract/html2text.pyx":488
 *         # Post meta
 *         if regex_search_not_empty(cls_attr, post_meta_cls_regex):
 *             return False             # <<<<<<<<<<<<<<
 * 
 *         # Social media and feedback forms
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "resiliparse/extract/html2text.pyx":487
 * 
 *         # Post meta
 *         if regex_search_not_empty(cls_attr, post_meta_cls_regex):             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
    }

    /* "resiliparse/extract/html2text.pyx":491
 * 
 *         # Social media and feedback forms
 *         if regex_search_not_empty(cls_attr, social_cls_regex):             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
    __pyx_t_1 = (__pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(__pyx_v_cls_attr, __pyx_v_11resiliparse_7extract_9html2text_social_cls_regex) != 0);
    if (__pyx_t_1) {

      /* "resiliparse/extract/html2text.pyx":492
 *         # Social media and feedback forms
 *         if regex_search_not_empty(cls_attr, social_cls_regex):
 *             return False             # <<<<<<<<<<<<<<
 * 
 *     # Logos
 */
      __pyx_r = 0;
      goto __pyx_L0;

      /* "resiliparse/extract/html2text.pyx":491
 * 
 *         # Social media and feedback forms
 *         if regex_search_not_empty(cls_attr, social_cls_regex):             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
    }

    /* "resiliparse/extract/html2text.pyx":481
 *         return False
 * 
 *     if body_depth > 2:             # <<<<<<<<<<<<<<
 *         # Sign-in links
 *         if regex_search_not_empty(cls_attr, signin_cls_regex):
 */
  }

  /* "resiliparse/extract/html2text.pyx":495
 * 
 *     # Logos
 *     if regex_search_not_empty(cls_and_id_attr, logo_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_1 = (__pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(__pyx_v_cls_and_id_attr, __pyx_v_11resiliparse_7extract_9html2text_logo_cls_regex) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":496
 *     # Logos
 *     if regex_search_not_empty(cls_and_id_attr, logo_cls_regex):
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     # Ads
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":495
 * 
 *     # Logos
 *     if regex_search_not_empty(cls_and_id_attr, logo_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":499
 * 
 *     # Ads
 *     if regex_search_not_empty(cls_and_id_attr, ads_cls_regex) \             # <<<<<<<<<<<<<<
 *             or lxb_dom_element_has_attribute(<lxb_dom_element_t*>node, <const lxb_char_t*>b'data-ad', 7) \
 *             or lxb_dom_element_has_attribute(<lxb_dom_element_t*>node, <const lxb_char_t*>b'data-advertisement', 18) \
 */
  __pyx_t_5 = (__pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(__pyx_v_cls_and_id_attr, __pyx_v_11resiliparse_7extract_9html2text_ads_cls_regex) != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L59_bool_binop_done;
  }

  /* "resiliparse/extract/html2text.pyx":500
 *     # Ads
 *     if regex_search_not_empty(cls_and_id_attr, ads_cls_regex) \
 *             or lxb_dom_element_has_attribute(<lxb_dom_element_t*>node, <const lxb_char_t*>b'data-ad', 7) \             # <<<<<<<<<<<<<<
 *             or lxb_dom_element_has_attribute(<lxb_dom_element_t*>node, <const lxb_char_t*>b'data-advertisement', 18) \
 *             or lxb_dom_element_has_attribute(<lxb_dom_element_t*>node, <const lxb_char_t*>b'data-text-ad', 12):
 */
  __pyx_t_5 = (lxb_dom_element_has_attribute(((lxb_dom_element_t *)__pyx_v_node), ((lxb_char_t const *)((lxb_char_t const *)((char const *)"data-ad"))), 7) != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L59_bool_binop_done;
  }

  /* "resiliparse/extract/html2text.pyx":501
 *     if regex_search_not_empty(cls_and_id_attr, ads_cls_regex) \
 *             or lxb_dom_element_has_attribute(<lxb_dom_element_t*>node, <const lxb_char_t*>b'data-ad', 7) \
 *             or lxb_dom_element_has_attribute(<lxb_dom_element_t*>node, <const lxb_char_t*>b'data-advertisement', 18) \             # <<<<<<<<<<<<<<
 *             or lxb_dom_element_has_attribute(<lxb_dom_element_t*>node, <const lxb_char_t*>b'data-text-ad', 12):
 *         return False
 */
  __pyx_t_5 = (lxb_dom_element_has_attribute(((lxb_dom_element_t *)__pyx_v_node), ((lxb_char_t const *)((lxb_char_t const *)((char const *)"data-advertisement"))), 18) != 0);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L59_bool_binop_done;
  }

  /* "resiliparse/extract/html2text.pyx":502
 *             or lxb_dom_element_has_attribute(<lxb_dom_element_t*>node, <const lxb_char_t*>b'data-ad', 7) \
 *             or lxb_dom_element_has_attribute(<lxb_dom_element_t*>node, <const lxb_char_t*>b'data-advertisement', 18) \
 *             or lxb_dom_element_has_attribute(<lxb_dom_element_t*>node, <const lxb_char_t*>b'data-text-ad', 12):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_5 = (lxb_dom_element_has_attribute(((lxb_dom_element_t *)__pyx_v_node), ((lxb_char_t const *)((lxb_char_t const *)((char const *)"data-text-ad"))), 12) != 0);
  __pyx_t_1 = __pyx_t_5;
  __pyx_L59_bool_binop_done:;

  /* "resiliparse/extract/html2text.pyx":499
 * 
 *     # Ads
 *     if regex_search_not_empty(cls_and_id_attr, ads_cls_regex) \             # <<<<<<<<<<<<<<
 *             or lxb_dom_element_has_attribute(<lxb_dom_element_t*>node, <const lxb_char_t*>b'data-ad', 7) \
 *             or lxb_dom_element_has_attribute(<lxb_dom_element_t*>node, <const lxb_char_t*>b'data-advertisement', 18) \
 */
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":503
 *             or lxb_dom_element_has_attribute(<lxb_dom_element_t*>node, <const lxb_char_t*>b'data-advertisement', 18) \
 *             or lxb_dom_element_has_attribute(<lxb_dom_element_t*>node, <const lxb_char_t*>b'data-text-ad', 12):
 *         return False             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":499
 * 
 *     # Ads
 *     if regex_search_not_empty(cls_and_id_attr, ads_cls_regex) \             # <<<<<<<<<<<<<<
 *             or lxb_dom_element_has_attribute(<lxb_dom_element_t*>node, <const lxb_char_t*>b'data-ad', 7) \
 *             or lxb_dom_element_has_attribute(<lxb_dom_element_t*>node, <const lxb_char_t*>b'data-advertisement', 18) \
 */
  }

  /* "resiliparse/extract/html2text.pyx":508
 *     # ------ Section 4: Class and ID matching of block elements only ------
 * 
 *     if not is_block_element(node.local_name) and node.local_name != LXB_TAG_TD:             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  __pyx_t_5 = ((!(__pyx_f_11resiliparse_5parse_4html_is_block_element(__pyx_v_node->local_name) != 0)) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L64_bool_binop_done;
  }
  __pyx_t_5 = ((__pyx_v_node->local_name != LXB_TAG_TD) != 0);
  __pyx_t_1 = __pyx_t_5;
  __pyx_L64_bool_binop_done:;
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":509
 * 
 *     if not is_block_element(node.local_name) and node.local_name != LXB_TAG_TD:
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     # ARIA roles
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":508
 *     # ------ Section 4: Class and ID matching of block elements only ------
 * 
 *     if not is_block_element(node.local_name) and node.local_name != LXB_TAG_TD:             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":512
 * 
 *     # ARIA roles
 *     cdef string_view role_attr = get_node_attr_sv(node, b'role')             # <<<<<<<<<<<<<<
 *     if rel_attr == b'main':
 *         return True
 */
  __pyx_v_role_attr = __pyx_f_11resiliparse_5parse_4html_get_node_attr_sv(__pyx_v_node, __pyx_k_role);

  /* "resiliparse/extract/html2text.pyx":513
 *     # ARIA roles
 *     cdef string_view role_attr = get_node_attr_sv(node, b'role')
 *     if rel_attr == b'main':             # <<<<<<<<<<<<<<
 *         return True
 *     if not role_attr.empty() and blacklist_aria_roles.find(<string>role_attr) != blacklist_aria_roles.end():
 */
  __pyx_t_1 = ((__pyx_v_rel_attr == ((char const *)"main")) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":514
 *     cdef string_view role_attr = get_node_attr_sv(node, b'role')
 *     if rel_attr == b'main':
 *         return True             # <<<<<<<<<<<<<<
 *     if not role_attr.empty() and blacklist_aria_roles.find(<string>role_attr) != blacklist_aria_roles.end():
 *         return False
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":513
 *     # ARIA roles
 *     cdef string_view role_attr = get_node_attr_sv(node, b'role')
 *     if rel_attr == b'main':             # <<<<<<<<<<<<<<
 *         return True
 *     if not role_attr.empty() and blacklist_aria_roles.find(<string>role_attr) != blacklist_aria_roles.end():
 */
  }

  /* "resiliparse/extract/html2text.pyx":515
 *     if rel_attr == b'main':
 *         return True
 *     if not role_attr.empty() and blacklist_aria_roles.find(<string>role_attr) != blacklist_aria_roles.end():             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_5 = ((!(__pyx_v_role_attr.empty() != 0)) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L68_bool_binop_done;
  }
  __pyx_t_5 = ((__pyx_v_11resiliparse_7extract_9html2text_blacklist_aria_roles.find(((std::string)__pyx_v_role_attr)) != __pyx_v_11resiliparse_7extract_9html2text_blacklist_aria_roles.end()) != 0);
  __pyx_t_1 = __pyx_t_5;
  __pyx_L68_bool_binop_done:;
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":516
 *         return True
 *     if not role_attr.empty() and blacklist_aria_roles.find(<string>role_attr) != blacklist_aria_roles.end():
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     # Whitelist article elements
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":515
 *     if rel_attr == b'main':
 *         return True
 *     if not role_attr.empty() and blacklist_aria_roles.find(<string>role_attr) != blacklist_aria_roles.end():             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":519
 * 
 *     # Whitelist article elements
 *     if regex_search_not_empty(cls_and_id_attr, article_cls_regex):             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  __pyx_t_1 = (__pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(__pyx_v_cls_and_id_attr, __pyx_v_11resiliparse_7extract_9html2text_article_cls_regex) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":520
 *     # Whitelist article elements
 *     if regex_search_not_empty(cls_and_id_attr, article_cls_regex):
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     # Global landmarks by ID
 */
    __pyx_r = 1;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":519
 * 
 *     # Whitelist article elements
 *     if regex_search_not_empty(cls_and_id_attr, article_cls_regex):             # <<<<<<<<<<<<<<
 *         return True
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":523
 * 
 *     # Global landmarks by ID
 *     if regex_search_not_empty(id_attr, landmark_id_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_1 = (__pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(__pyx_v_id_attr, __pyx_v_11resiliparse_7extract_9html2text_landmark_id_regex) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":524
 *     # Global landmarks by ID
 *     if regex_search_not_empty(id_attr, landmark_id_regex):
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     # Global header
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":523
 * 
 *     # Global landmarks by ID
 *     if regex_search_not_empty(id_attr, landmark_id_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":527
 * 
 *     # Global header
 *     if regex_search_not_empty(cls_and_id_attr, header_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_1 = (__pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(__pyx_v_cls_and_id_attr, __pyx_v_11resiliparse_7extract_9html2text_header_cls_regex) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":528
 *     # Global header
 *     if regex_search_not_empty(cls_and_id_attr, header_cls_regex):
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     # Global footer
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":527
 * 
 *     # Global header
 *     if regex_search_not_empty(cls_and_id_attr, header_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":531
 * 
 *     # Global footer
 *     if regex_search_not_empty(cls_and_id_attr, footer_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_1 = (__pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(__pyx_v_cls_and_id_attr, __pyx_v_11resiliparse_7extract_9html2text_footer_cls_regex) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":532
 *     # Global footer
 *     if regex_search_not_empty(cls_and_id_attr, footer_cls_regex):
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     # Global navigation
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":531
 * 
 *     # Global footer
 *     if regex_search_not_empty(cls_and_id_attr, footer_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":535
 * 
 *     # Global navigation
 *     if regex_search_not_empty(cls_and_id_attr, nav_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_1 = (__pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(__pyx_v_cls_and_id_attr, __pyx_v_11resiliparse_7extract_9html2text_nav_cls_regex) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":536
 *     # Global navigation
 *     if regex_search_not_empty(cls_and_id_attr, nav_cls_regex):
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     # Recommended articles
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":535
 * 
 *     # Global navigation
 *     if regex_search_not_empty(cls_and_id_attr, nav_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":539
 * 
 *     # Recommended articles
 *     if regex_search_not_empty(cls_and_id_attr, recommended_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_1 = (__pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(__pyx_v_cls_and_id_attr, __pyx_v_11resiliparse_7extract_9html2text_recommended_cls_regex) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":540
 *     # Recommended articles
 *     if regex_search_not_empty(cls_and_id_attr, recommended_cls_regex):
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     # Comments section
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":539
 * 
 *     # Recommended articles
 *     if regex_search_not_empty(cls_and_id_attr, recommended_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":543
 * 
 *     # Comments section
 *     if not allow_comments and node.local_name and regex_search_not_empty(cls_and_id_attr, comments_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_5 = ((!(__pyx_v_allow_comments != 0)) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L77_bool_binop_done;
  }
  __pyx_t_5 = (__pyx_v_node->local_name != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L77_bool_binop_done;
  }
  __pyx_t_5 = (__pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(__pyx_v_cls_and_id_attr, __pyx_v_11resiliparse_7extract_9html2text_comments_cls_regex) != 0);
  __pyx_t_1 = __pyx_t_5;
  __pyx_L77_bool_binop_done:;
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":544
 *     # Comments section
 *     if not allow_comments and node.local_name and regex_search_not_empty(cls_and_id_attr, comments_cls_regex):
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     # Global search bar
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":543
 * 
 *     # Comments section
 *     if not allow_comments and node.local_name and regex_search_not_empty(cls_and_id_attr, comments_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":547
 * 
 *     # Global search bar
 *     if regex_search_not_empty(cls_and_id_attr, search_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_1 = (__pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(__pyx_v_cls_and_id_attr, __pyx_v_11resiliparse_7extract_9html2text_search_cls_regex) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":548
 *     # Global search bar
 *     if regex_search_not_empty(cls_and_id_attr, search_cls_regex):
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     # Global sidebar
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":547
 * 
 *     # Global search bar
 *     if regex_search_not_empty(cls_and_id_attr, search_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":551
 * 
 *     # Global sidebar
 *     if regex_search_not_empty(cls_and_id_attr, sidebar_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_1 = (__pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(__pyx_v_cls_and_id_attr, __pyx_v_11resiliparse_7extract_9html2text_sidebar_cls_regex) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":552
 *     # Global sidebar
 *     if regex_search_not_empty(cls_and_id_attr, sidebar_cls_regex):
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     # Modals
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":551
 * 
 *     # Global sidebar
 *     if regex_search_not_empty(cls_and_id_attr, sidebar_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":555
 * 
 *     # Modals
 *     if regex_search_not_empty(cls_and_id_attr, modal_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_1 = (__pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(__pyx_v_cls_and_id_attr, __pyx_v_11resiliparse_7extract_9html2text_modal_cls_regex) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":556
 *     # Modals
 *     if regex_search_not_empty(cls_and_id_attr, modal_cls_regex):
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     # Image galleries and carousels
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":555
 * 
 *     # Modals
 *     if regex_search_not_empty(cls_and_id_attr, modal_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":559
 * 
 *     # Image galleries and carousels
 *     if regex_search_not_empty(cls_and_id_attr, gallery_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_1 = (__pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(__pyx_v_cls_and_id_attr, __pyx_v_11resiliparse_7extract_9html2text_gallery_cls_regex) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":560
 *     # Image galleries and carousels
 *     if regex_search_not_empty(cls_and_id_attr, gallery_cls_regex):
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     # Print content
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":559
 * 
 *     # Image galleries and carousels
 *     if regex_search_not_empty(cls_and_id_attr, gallery_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":563
 * 
 *     # Print content
 *     if regex_search_not_empty(cls_and_id_attr, print_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_1 = (__pyx_f_11resiliparse_7extract_9html2text_regex_search_not_empty(__pyx_v_cls_and_id_attr, __pyx_v_11resiliparse_7extract_9html2text_print_cls_regex) != 0);
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":564
 *     # Print content
 *     if regex_search_not_empty(cls_and_id_attr, print_cls_regex):
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     if body_depth > 2 and node.local_name == LXB_TAG_DIV and _is_link_cluster(node, 0.6, 1500):
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":563
 * 
 *     # Print content
 *     if regex_search_not_empty(cls_and_id_attr, print_cls_regex):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":566
 *         return False
 * 
 *     if body_depth > 2 and node.local_name == LXB_TAG_DIV and _is_link_cluster(node, 0.6, 1500):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  __pyx_t_5 = ((__pyx_v_body_depth > 2) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L86_bool_binop_done;
  }
  __pyx_t_5 = ((__pyx_v_node->local_name == LXB_TAG_DIV) != 0);
  if (__pyx_t_5) {
  } else {
    __pyx_t_1 = __pyx_t_5;
    goto __pyx_L86_bool_binop_done;
  }
  __pyx_t_5 = (__pyx_f_11resiliparse_7extract_9html2text__is_link_cluster(__pyx_v_node, 0.6, 0x5DC) != 0);
  __pyx_t_1 = __pyx_t_5;
  __pyx_L86_bool_binop_done:;
  if (__pyx_t_1) {

    /* "resiliparse/extract/html2text.pyx":567
 * 
 *     if body_depth > 2 and node.local_name == LXB_TAG_DIV and _is_link_cluster(node, 0.6, 1500):
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     return True
 */
    __pyx_r = 0;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":566
 *         return False
 * 
 *     if body_depth > 2 and node.local_name == LXB_TAG_DIV and _is_link_cluster(node, 0.6, 1500):             # <<<<<<<<<<<<<<
 *         return False
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":569
 *         return False
 * 
 *     return True             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 1;
  goto __pyx_L0;

  /* "resiliparse/extract/html2text.pyx":378
 * 
 * # noinspection DuplicatedCode
 * cdef inline bint _is_main_content_node(lxb_dom_node_t* node, size_t body_depth, bint allow_comments) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     Perform a rule-based check whether the given element is a "main-content" element.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("resiliparse.extract.html2text._is_main_content_node", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 1);
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "resiliparse/extract/html2text.pyx":572
 * 
 * 
 * cdef inline lxb_status_t _collect_selected_nodes_cb(lxb_dom_node_t *node,             # <<<<<<<<<<<<<<
 *                                                     lxb_css_selector_specificity_t *spec, void *ctx) nogil:
 *     (<stl_set[lxb_dom_node_t*]*>ctx).insert(node)
 */

static CYTHON_INLINE lxb_status_t __pyx_f_11resiliparse_7extract_9html2text__collect_selected_nodes_cb(lxb_dom_node_t *__pyx_v_node, CYTHON_UNUSED lxb_css_selector_specificity_t *__pyx_v_spec, void *__pyx_v_ctx) {
  lxb_status_t __pyx_r;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "resiliparse/extract/html2text.pyx":574
 * cdef inline lxb_status_t _collect_selected_nodes_cb(lxb_dom_node_t *node,
 *                                                     lxb_css_selector_specificity_t *spec, void *ctx) nogil:
 *     (<stl_set[lxb_dom_node_t*]*>ctx).insert(node)             # <<<<<<<<<<<<<<
 *     return LXB_STATUS_OK
 * 
 */
  try {
    ((std::set<lxb_dom_node_t *>  *)__pyx_v_ctx)->insert(__pyx_v_node);
  } catch(...) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
    #endif
    __Pyx_CppExn2PyErr();
    #ifdef WITH_THREAD
    __Pyx_PyGILState_Release(__pyx_gilstate_save);
    #endif
    __PYX_ERR(0, 574, __pyx_L1_error)
  }

  /* "resiliparse/extract/html2text.pyx":575
 *                                                     lxb_css_selector_specificity_t *spec, void *ctx) nogil:
 *     (<stl_set[lxb_dom_node_t*]*>ctx).insert(node)
 *     return LXB_STATUS_OK             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = LXB_STATUS_OK;
  goto __pyx_L0;

  /* "resiliparse/extract/html2text.pyx":572
 * 
 * 
 * cdef inline lxb_status_t _collect_selected_nodes_cb(lxb_dom_node_t *node,             # <<<<<<<<<<<<<<
 *                                                     lxb_css_selector_specificity_t *spec, void *ctx) nogil:
 *     (<stl_set[lxb_dom_node_t*]*>ctx).insert(node)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("resiliparse.extract.html2text._collect_selected_nodes_cb", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 1);
  __pyx_r = 0;
  __pyx_L0:;
  return __pyx_r;
}

/* "resiliparse/extract/html2text.pyx":578
 * 
 * 
 * cdef inline lxb_status_t _exists_cb(lxb_dom_node_t *node, lxb_css_selector_specificity_t *spec, void *ctx) nogil:             # <<<<<<<<<<<<<<
 *     (<bint*>ctx)[0] = True
 *     return LXB_STATUS_STOP
 */

static CYTHON_INLINE lxb_status_t __pyx_f_11resiliparse_7extract_9html2text__exists_cb(CYTHON_UNUSED lxb_dom_node_t *__pyx_v_node, CYTHON_UNUSED lxb_css_selector_specificity_t *__pyx_v_spec, void *__pyx_v_ctx) {
  lxb_status_t __pyx_r;

  /* "resiliparse/extract/html2text.pyx":579
 * 
 * cdef inline lxb_status_t _exists_cb(lxb_dom_node_t *node, lxb_css_selector_specificity_t *spec, void *ctx) nogil:
 *     (<bint*>ctx)[0] = True             # <<<<<<<<<<<<<<
 *     return LXB_STATUS_STOP
 * 
 */
  (((int *)__pyx_v_ctx)[0]) = 1;

  /* "resiliparse/extract/html2text.pyx":580
 * cdef inline lxb_status_t _exists_cb(lxb_dom_node_t *node, lxb_css_selector_specificity_t *spec, void *ctx) nogil:
 *     (<bint*>ctx)[0] = True
 *     return LXB_STATUS_STOP             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = LXB_STATUS_STOP;
  goto __pyx_L0;

  /* "resiliparse/extract/html2text.pyx":578
 * 
 * 
 * cdef inline lxb_status_t _exists_cb(lxb_dom_node_t *node, lxb_css_selector_specificity_t *spec, void *ctx) nogil:             # <<<<<<<<<<<<<<
 *     (<bint*>ctx)[0] = True
 *     return LXB_STATUS_STOP
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "resiliparse/extract/html2text.pyx":583
 * 
 * 
 * def extract_plain_text(HTMLTree tree, bint preserve_formatting=True, bint main_content=False,             # <<<<<<<<<<<<<<
 *                        bint list_bullets=True,  bint alt_texts=True, bint links=False, bint form_fields=False,
 *                        bint noscript=False, bint comments=True, skip_elements=None):
 */

/* Python wrapper */
static PyObject *__pyx_pw_11resiliparse_7extract_9html2text_1extract_plain_text(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_11resiliparse_7extract_9html2text_extract_plain_text[] = "\n    extract_plain_text(tree, preserve_formatting=True, main_content=False, list_bullets=True, alt_texts=False,                        links=True, form_fields=False, noscript=False, comments=None, skip_elements=None)\n\n    Perform a simple plain-text extraction from the given DOM node and its children.\n\n    Extracts all visible text (excluding script/style elements, comment nodes etc.)\n    and collapses consecutive white space characters. If ``preserve_formatting`` is\n    ``True``, line breaks, paragraphs, other block-level elements, list elements, and\n    ``<pre>``-formatted text will be preserved.\n\n    Extraction of particular elements and attributes such as links, alt texts, or form fields\n    can be be configured individually by setting the corresponding parameter to ``True``.\n    Defaults to ``False`` for most elements (i.e., only basic text will be extracted).\n\n    :param tree: HTML DOM tree\n    :type tree: DOMNode\n    :param preserve_formatting: preserve basic block-level formatting\n    :type preserve_formatting: bool\n    :param main_content: apply simple heuristics for extracting only \"main-content\" elements\n    :type main_content: bool\n    :param list_bullets: insert bullets / numbers for list items\n    :type list_bullets: bool\n    :param alt_texts: preserve alternative text descriptions\n    :type alt_texts: bool\n    :param links: extract link target URLs\n    :type links: bool\n    :param form_fields: extract form fields and their values\n    :type form_fields: bool\n    :param noscript: extract contents of <noscript> elements\n    :param comments: treat comment sections as main content\n    :type comments: bool\n    :param skip_elements: list of CSS selectors for elements to skip\n    :type skip_elements: t.Iterable[str] or None\n    :type noscript: bool\n    :return: extracted plain text\n    :rtype: str\n    ";
static PyMethodDef __pyx_mdef_11resiliparse_7extract_9html2text_1extract_plain_text = {"extract_plain_text", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11resiliparse_7extract_9html2text_1extract_plain_text, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11resiliparse_7extract_9html2text_extract_plain_text};
static PyObject *__pyx_pw_11resiliparse_7extract_9html2text_1extract_plain_text(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_11resiliparse_5parse_4html_HTMLTree *__pyx_v_tree = 0;
  int __pyx_v_preserve_formatting;
  int __pyx_v_main_content;
  int __pyx_v_list_bullets;
  int __pyx_v_alt_texts;
  int __pyx_v_links;
  int __pyx_v_form_fields;
  int __pyx_v_noscript;
  int __pyx_v_comments;
  PyObject *__pyx_v_skip_elements = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("extract_plain_text (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_tree,&__pyx_n_s_preserve_formatting,&__pyx_n_s_main_content,&__pyx_n_s_list_bullets,&__pyx_n_s_alt_texts,&__pyx_n_s_links,&__pyx_n_s_form_fields,&__pyx_n_s_noscript,&__pyx_n_s_comments,&__pyx_n_s_skip_elements,0};
    PyObject* values[10] = {0,0,0,0,0,0,0,0,0,0};

    /* "resiliparse/extract/html2text.pyx":585
 * def extract_plain_text(HTMLTree tree, bint preserve_formatting=True, bint main_content=False,
 *                        bint list_bullets=True,  bint alt_texts=True, bint links=False, bint form_fields=False,
 *                        bint noscript=False, bint comments=True, skip_elements=None):             # <<<<<<<<<<<<<<
 *     """
 *     extract_plain_text(tree, preserve_formatting=True, main_content=False, list_bullets=True, alt_texts=False, \
 */
    values[9] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tree)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_preserve_formatting);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_main_content);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_list_bullets);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_alt_texts);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_links);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_form_fields);
          if (value) { values[6] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_noscript);
          if (value) { values[7] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_comments);
          if (value) { values[8] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_skip_elements);
          if (value) { values[9] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "extract_plain_text") < 0)) __PYX_ERR(0, 583, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_tree = ((struct __pyx_obj_11resiliparse_5parse_4html_HTMLTree *)values[0]);
    if (values[1]) {
      __pyx_v_preserve_formatting = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_preserve_formatting == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 583, __pyx_L3_error)
    } else {

      /* "resiliparse/extract/html2text.pyx":583
 * 
 * 
 * def extract_plain_text(HTMLTree tree, bint preserve_formatting=True, bint main_content=False,             # <<<<<<<<<<<<<<
 *                        bint list_bullets=True,  bint alt_texts=True, bint links=False, bint form_fields=False,
 *                        bint noscript=False, bint comments=True, skip_elements=None):
 */
      __pyx_v_preserve_formatting = ((int)1);
    }
    if (values[2]) {
      __pyx_v_main_content = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_main_content == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 583, __pyx_L3_error)
    } else {
      __pyx_v_main_content = ((int)0);
    }
    if (values[3]) {
      __pyx_v_list_bullets = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_list_bullets == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 584, __pyx_L3_error)
    } else {

      /* "resiliparse/extract/html2text.pyx":584
 * 
 * def extract_plain_text(HTMLTree tree, bint preserve_formatting=True, bint main_content=False,
 *                        bint list_bullets=True,  bint alt_texts=True, bint links=False, bint form_fields=False,             # <<<<<<<<<<<<<<
 *                        bint noscript=False, bint comments=True, skip_elements=None):
 *     """
 */
      __pyx_v_list_bullets = ((int)1);
    }
    if (values[4]) {
      __pyx_v_alt_texts = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_alt_texts == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 584, __pyx_L3_error)
    } else {
      __pyx_v_alt_texts = ((int)1);
    }
    if (values[5]) {
      __pyx_v_links = __Pyx_PyObject_IsTrue(values[5]); if (unlikely((__pyx_v_links == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 584, __pyx_L3_error)
    } else {
      __pyx_v_links = ((int)0);
    }
    if (values[6]) {
      __pyx_v_form_fields = __Pyx_PyObject_IsTrue(values[6]); if (unlikely((__pyx_v_form_fields == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 584, __pyx_L3_error)
    } else {
      __pyx_v_form_fields = ((int)0);
    }
    if (values[7]) {
      __pyx_v_noscript = __Pyx_PyObject_IsTrue(values[7]); if (unlikely((__pyx_v_noscript == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 585, __pyx_L3_error)
    } else {

      /* "resiliparse/extract/html2text.pyx":585
 * def extract_plain_text(HTMLTree tree, bint preserve_formatting=True, bint main_content=False,
 *                        bint list_bullets=True,  bint alt_texts=True, bint links=False, bint form_fields=False,
 *                        bint noscript=False, bint comments=True, skip_elements=None):             # <<<<<<<<<<<<<<
 *     """
 *     extract_plain_text(tree, preserve_formatting=True, main_content=False, list_bullets=True, alt_texts=False, \
 */
      __pyx_v_noscript = ((int)0);
    }
    if (values[8]) {
      __pyx_v_comments = __Pyx_PyObject_IsTrue(values[8]); if (unlikely((__pyx_v_comments == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 585, __pyx_L3_error)
    } else {
      __pyx_v_comments = ((int)1);
    }
    __pyx_v_skip_elements = values[9];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("extract_plain_text", 0, 1, 10, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 583, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("resiliparse.extract.html2text.extract_plain_text", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tree), __pyx_ptype_11resiliparse_5parse_4html_HTMLTree, 1, "tree", 0))) __PYX_ERR(0, 583, __pyx_L1_error)
  __pyx_r = __pyx_pf_11resiliparse_7extract_9html2text_extract_plain_text(__pyx_self, __pyx_v_tree, __pyx_v_preserve_formatting, __pyx_v_main_content, __pyx_v_list_bullets, __pyx_v_alt_texts, __pyx_v_links, __pyx_v_form_fields, __pyx_v_noscript, __pyx_v_comments, __pyx_v_skip_elements);

  /* "resiliparse/extract/html2text.pyx":583
 * 
 * 
 * def extract_plain_text(HTMLTree tree, bint preserve_formatting=True, bint main_content=False,             # <<<<<<<<<<<<<<
 *                        bint list_bullets=True,  bint alt_texts=True, bint links=False, bint form_fields=False,
 *                        bint noscript=False, bint comments=True, skip_elements=None):
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_11resiliparse_7extract_9html2text_extract_plain_text(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_11resiliparse_5parse_4html_HTMLTree *__pyx_v_tree, int __pyx_v_preserve_formatting, int __pyx_v_main_content, int __pyx_v_list_bullets, int __pyx_v_alt_texts, int __pyx_v_links, int __pyx_v_form_fields, int __pyx_v_noscript, int __pyx_v_comments, PyObject *__pyx_v_skip_elements) {
  PyObject *__pyx_v_skip_selectors = NULL;
  struct ExtractContext __pyx_v_ctx;
  CYTHON_UNUSED lxb_char_t const *__pyx_v_tag_name;
  CYTHON_UNUSED int __pyx_v_skip;
  int __pyx_v_is_end_tag;
  lxb_css_parser_t *__pyx_v_css_parser;
  lxb_css_selectors_t *__pyx_v_css_selectors;
  lxb_selectors_t *__pyx_v_selectors;
  lxb_css_selector_list_t *__pyx_v_selector_list;
  std::set<lxb_dom_node_t *>  __pyx_v_preselected_nodes;
  std::string __pyx_v_main_content_selector;
  PyObject *__pyx_v_combined_skip_sel = NULL;
  size_t __pyx_v_base_depth;
  lxb_dom_node_t *__pyx_v_pnode;
  std::vector<std::shared_ptr<struct ExtractNode> >  __pyx_v_extract_nodes;
  PyObject *__pyx_7genexpr__pyx_v_e = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  lxb_dom_node_t *__pyx_t_10;
  struct ExtractOpts __pyx_t_11;
  std::string __pyx_t_12;
  lxb_css_selector_list_t *__pyx_t_13;
  lxb_char_t const *__pyx_t_14;
  int __pyx_t_15;
  int __pyx_t_16;
  char const *__pyx_t_17;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  int __pyx_t_24;
  struct __pyx_opt_args_11resiliparse_5parse_4html_next_node __pyx_t_25;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("extract_plain_text", 0);

  /* "resiliparse/extract/html2text.pyx":624
 *     :rtype: str
 *     """
 *     if not check_node(tree.body):             # <<<<<<<<<<<<<<
 *         return ''
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_tree), __pyx_n_s_body); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 624, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_11resiliparse_5parse_4html_DOMNode))))) __PYX_ERR(0, 624, __pyx_L1_error)
  __pyx_t_2 = ((!(__pyx_f_11resiliparse_5parse_4html_check_node(((struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *)__pyx_t_1)) != 0)) != 0);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "resiliparse/extract/html2text.pyx":625
 *     """
 *     if not check_node(tree.body):
 *         return ''             # <<<<<<<<<<<<<<
 * 
 *     skip_selectors = {e.encode() for e in skip_elements or []}
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_kp_u_);
    __pyx_r = __pyx_kp_u_;
    goto __pyx_L0;

    /* "resiliparse/extract/html2text.pyx":624
 *     :rtype: str
 *     """
 *     if not check_node(tree.body):             # <<<<<<<<<<<<<<
 *         return ''
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":627
 *         return ''
 * 
 *     skip_selectors = {e.encode() for e in skip_elements or []}             # <<<<<<<<<<<<<<
 *     skip_selectors.update({b'script', b'style', b'iframe', b'frame', b'template'})
 *     if not alt_texts:
 */
  { /* enter inner scope */
    __pyx_t_1 = PySet_New(NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 627, __pyx_L6_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_skip_elements); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 627, __pyx_L6_error)
    if (!__pyx_t_2) {
    } else {
      __Pyx_INCREF(__pyx_v_skip_elements);
      __pyx_t_3 = __pyx_v_skip_elements;
      goto __pyx_L9_bool_binop_done;
    }
    __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 627, __pyx_L6_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_3 = __pyx_t_4;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_L9_bool_binop_done:;
    if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
      __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 627, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 627, __pyx_L6_error)
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (likely(!__pyx_t_6)) {
        if (likely(PyList_CheckExact(__pyx_t_4))) {
          if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 627, __pyx_L6_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 627, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        } else {
          if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 627, __pyx_L6_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 627, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_6(__pyx_t_4);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 627, __pyx_L6_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_e, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_7genexpr__pyx_v_e, __pyx_n_s_encode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 627, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      __pyx_t_3 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_7);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 627, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(PySet_Add(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 627, __pyx_L6_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_e); __pyx_7genexpr__pyx_v_e = 0;
    goto __pyx_L11_exit_scope;
    __pyx_L6_error:;
    __Pyx_XDECREF(__pyx_7genexpr__pyx_v_e); __pyx_7genexpr__pyx_v_e = 0;
    goto __pyx_L1_error;
    __pyx_L11_exit_scope:;
  } /* exit inner scope */
  __pyx_v_skip_selectors = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "resiliparse/extract/html2text.pyx":628
 * 
 *     skip_selectors = {e.encode() for e in skip_elements or []}
 *     skip_selectors.update({b'script', b'style', b'iframe', b'frame', b'template'})             # <<<<<<<<<<<<<<
 *     if not alt_texts:
 *         skip_selectors.update({b'object', b'video', b'audio', b'embed' b'img', b'area',
 */
  __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 628, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PySet_Add(__pyx_t_1, __pyx_n_b_script) < 0) __PYX_ERR(0, 628, __pyx_L1_error)
  if (PySet_Add(__pyx_t_1, __pyx_n_b_style) < 0) __PYX_ERR(0, 628, __pyx_L1_error)
  if (PySet_Add(__pyx_t_1, __pyx_n_b_iframe) < 0) __PYX_ERR(0, 628, __pyx_L1_error)
  if (PySet_Add(__pyx_t_1, __pyx_n_b_frame) < 0) __PYX_ERR(0, 628, __pyx_L1_error)
  if (PySet_Add(__pyx_t_1, __pyx_n_b_template) < 0) __PYX_ERR(0, 628, __pyx_L1_error)
  __pyx_t_4 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PySet_Type_update, __pyx_v_skip_selectors, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 628, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "resiliparse/extract/html2text.pyx":629
 *     skip_selectors = {e.encode() for e in skip_elements or []}
 *     skip_selectors.update({b'script', b'style', b'iframe', b'frame', b'template'})
 *     if not alt_texts:             # <<<<<<<<<<<<<<
 *         skip_selectors.update({b'object', b'video', b'audio', b'embed' b'img', b'area',
 *                                b'svg', b'figcaption', b'figure'})
 */
  __pyx_t_2 = ((!(__pyx_v_alt_texts != 0)) != 0);
  if (__pyx_t_2) {

    /* "resiliparse/extract/html2text.pyx":630
 *     skip_selectors.update({b'script', b'style', b'iframe', b'frame', b'template'})
 *     if not alt_texts:
 *         skip_selectors.update({b'object', b'video', b'audio', b'embed' b'img', b'area',             # <<<<<<<<<<<<<<
 *                                b'svg', b'figcaption', b'figure'})
 *     if not noscript:
 */
    __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 630, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (PySet_Add(__pyx_t_4, __pyx_n_b_object) < 0) __PYX_ERR(0, 630, __pyx_L1_error)
    if (PySet_Add(__pyx_t_4, __pyx_n_b_video) < 0) __PYX_ERR(0, 630, __pyx_L1_error)
    if (PySet_Add(__pyx_t_4, __pyx_n_b_audio) < 0) __PYX_ERR(0, 630, __pyx_L1_error)
    if (PySet_Add(__pyx_t_4, __pyx_n_b_embedimg) < 0) __PYX_ERR(0, 630, __pyx_L1_error)
    if (PySet_Add(__pyx_t_4, __pyx_n_b_area) < 0) __PYX_ERR(0, 630, __pyx_L1_error)
    if (PySet_Add(__pyx_t_4, __pyx_n_b_svg) < 0) __PYX_ERR(0, 630, __pyx_L1_error)
    if (PySet_Add(__pyx_t_4, __pyx_n_b_figcaption) < 0) __PYX_ERR(0, 630, __pyx_L1_error)
    if (PySet_Add(__pyx_t_4, __pyx_n_b_figure) < 0) __PYX_ERR(0, 630, __pyx_L1_error)
    __pyx_t_1 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PySet_Type_update, __pyx_v_skip_selectors, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 630, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "resiliparse/extract/html2text.pyx":629
 *     skip_selectors = {e.encode() for e in skip_elements or []}
 *     skip_selectors.update({b'script', b'style', b'iframe', b'frame', b'template'})
 *     if not alt_texts:             # <<<<<<<<<<<<<<
 *         skip_selectors.update({b'object', b'video', b'audio', b'embed' b'img', b'area',
 *                                b'svg', b'figcaption', b'figure'})
 */
  }

  /* "resiliparse/extract/html2text.pyx":632
 *         skip_selectors.update({b'object', b'video', b'audio', b'embed' b'img', b'area',
 *                                b'svg', b'figcaption', b'figure'})
 *     if not noscript:             # <<<<<<<<<<<<<<
 *         skip_selectors.add(b'noscript')
 *     if not form_fields:
 */
  __pyx_t_2 = ((!(__pyx_v_noscript != 0)) != 0);
  if (__pyx_t_2) {

    /* "resiliparse/extract/html2text.pyx":633
 *                                b'svg', b'figcaption', b'figure'})
 *     if not noscript:
 *         skip_selectors.add(b'noscript')             # <<<<<<<<<<<<<<
 *     if not form_fields:
 *         skip_selectors.update({b'textarea', b'input', b'button', b'select', b'option', b'label',})
 */
    __pyx_t_9 = PySet_Add(__pyx_v_skip_selectors, __pyx_n_b_noscript); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 633, __pyx_L1_error)

    /* "resiliparse/extract/html2text.pyx":632
 *         skip_selectors.update({b'object', b'video', b'audio', b'embed' b'img', b'area',
 *                                b'svg', b'figcaption', b'figure'})
 *     if not noscript:             # <<<<<<<<<<<<<<
 *         skip_selectors.add(b'noscript')
 *     if not form_fields:
 */
  }

  /* "resiliparse/extract/html2text.pyx":634
 *     if not noscript:
 *         skip_selectors.add(b'noscript')
 *     if not form_fields:             # <<<<<<<<<<<<<<
 *         skip_selectors.update({b'textarea', b'input', b'button', b'select', b'option', b'label',})
 * 
 */
  __pyx_t_2 = ((!(__pyx_v_form_fields != 0)) != 0);
  if (__pyx_t_2) {

    /* "resiliparse/extract/html2text.pyx":635
 *         skip_selectors.add(b'noscript')
 *     if not form_fields:
 *         skip_selectors.update({b'textarea', b'input', b'button', b'select', b'option', b'label',})             # <<<<<<<<<<<<<<
 * 
 *     cdef ExtractContext ctx
 */
    __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 635, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PySet_Add(__pyx_t_1, __pyx_n_b_textarea) < 0) __PYX_ERR(0, 635, __pyx_L1_error)
    if (PySet_Add(__pyx_t_1, __pyx_n_b_input) < 0) __PYX_ERR(0, 635, __pyx_L1_error)
    if (PySet_Add(__pyx_t_1, __pyx_n_b_button) < 0) __PYX_ERR(0, 635, __pyx_L1_error)
    if (PySet_Add(__pyx_t_1, __pyx_n_b_select) < 0) __PYX_ERR(0, 635, __pyx_L1_error)
    if (PySet_Add(__pyx_t_1, __pyx_n_b_option) < 0) __PYX_ERR(0, 635, __pyx_L1_error)
    if (PySet_Add(__pyx_t_1, __pyx_n_b_label) < 0) __PYX_ERR(0, 635, __pyx_L1_error)
    __pyx_t_4 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PySet_Type_update, __pyx_v_skip_selectors, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 635, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "resiliparse/extract/html2text.pyx":634
 *     if not noscript:
 *         skip_selectors.add(b'noscript')
 *     if not form_fields:             # <<<<<<<<<<<<<<
 *         skip_selectors.update({b'textarea', b'input', b'button', b'select', b'option', b'label',})
 * 
 */
  }

  /* "resiliparse/extract/html2text.pyx":638
 * 
 *     cdef ExtractContext ctx
 *     ctx.root_node = <lxb_dom_node_t*>tree.dom_document.body             # <<<<<<<<<<<<<<
 *     ctx.node = ctx.root_node
 *     ctx.opts = [
 */
  __pyx_v_ctx.root_node = ((lxb_dom_node_t *)__pyx_v_tree->dom_document->body);

  /* "resiliparse/extract/html2text.pyx":639
 *     cdef ExtractContext ctx
 *     ctx.root_node = <lxb_dom_node_t*>tree.dom_document.body
 *     ctx.node = ctx.root_node             # <<<<<<<<<<<<<<
 *     ctx.opts = [
 *         preserve_formatting,
 */
  __pyx_t_10 = __pyx_v_ctx.root_node;
  __pyx_v_ctx.node = __pyx_t_10;

  /* "resiliparse/extract/html2text.pyx":640
 *     ctx.root_node = <lxb_dom_node_t*>tree.dom_document.body
 *     ctx.node = ctx.root_node
 *     ctx.opts = [             # <<<<<<<<<<<<<<
 *         preserve_formatting,
 *         list_bullets,
 */
  __pyx_t_11.preserve_formatting = __pyx_v_preserve_formatting;
  __pyx_t_11.list_bullets = __pyx_v_list_bullets;
  __pyx_t_11.links = __pyx_v_links;
  __pyx_t_11.alt_texts = __pyx_v_alt_texts;
  __pyx_t_11.form_fields = __pyx_v_form_fields;
  __pyx_t_11.noscript = __pyx_v_noscript;
  __pyx_v_ctx.opts = __pyx_t_11;

  /* "resiliparse/extract/html2text.pyx":648
 *         noscript]
 * 
 *     cdef const lxb_char_t* tag_name = NULL             # <<<<<<<<<<<<<<
 *     cdef size_t tag_name_len
 *     cdef string tag_name_str
 */
  __pyx_v_tag_name = NULL;

  /* "resiliparse/extract/html2text.pyx":652
 *     cdef string tag_name_str
 *     cdef size_t i
 *     cdef bint skip = False             # <<<<<<<<<<<<<<
 *     cdef bint is_end_tag = False
 * 
 */
  __pyx_v_skip = 0;

  /* "resiliparse/extract/html2text.pyx":653
 *     cdef size_t i
 *     cdef bint skip = False
 *     cdef bint is_end_tag = False             # <<<<<<<<<<<<<<
 * 
 *     if ctx.node.type == LXB_DOM_NODE_TYPE_DOCUMENT:
 */
  __pyx_v_is_end_tag = 0;

  /* "resiliparse/extract/html2text.pyx":655
 *     cdef bint is_end_tag = False
 * 
 *     if ctx.node.type == LXB_DOM_NODE_TYPE_DOCUMENT:             # <<<<<<<<<<<<<<
 *         ctx.root_node = next_element_node(ctx.node, ctx.node.first_child)
 *         ctx.node = ctx.root_node
 */
  __pyx_t_2 = ((__pyx_v_ctx.node->type == LXB_DOM_NODE_TYPE_DOCUMENT) != 0);
  if (__pyx_t_2) {

    /* "resiliparse/extract/html2text.pyx":656
 * 
 *     if ctx.node.type == LXB_DOM_NODE_TYPE_DOCUMENT:
 *         ctx.root_node = next_element_node(ctx.node, ctx.node.first_child)             # <<<<<<<<<<<<<<
 *         ctx.node = ctx.root_node
 * 
 */
    __pyx_v_ctx.root_node = __pyx_f_11resiliparse_5parse_4html_next_element_node(__pyx_v_ctx.node, __pyx_v_ctx.node->first_child, NULL);

    /* "resiliparse/extract/html2text.pyx":657
 *     if ctx.node.type == LXB_DOM_NODE_TYPE_DOCUMENT:
 *         ctx.root_node = next_element_node(ctx.node, ctx.node.first_child)
 *         ctx.node = ctx.root_node             # <<<<<<<<<<<<<<
 * 
 *     cdef lxb_css_parser_t* css_parser = NULL
 */
    __pyx_t_10 = __pyx_v_ctx.root_node;
    __pyx_v_ctx.node = __pyx_t_10;

    /* "resiliparse/extract/html2text.pyx":655
 *     cdef bint is_end_tag = False
 * 
 *     if ctx.node.type == LXB_DOM_NODE_TYPE_DOCUMENT:             # <<<<<<<<<<<<<<
 *         ctx.root_node = next_element_node(ctx.node, ctx.node.first_child)
 *         ctx.node = ctx.root_node
 */
  }

  /* "resiliparse/extract/html2text.pyx":659
 *         ctx.node = ctx.root_node
 * 
 *     cdef lxb_css_parser_t* css_parser = NULL             # <<<<<<<<<<<<<<
 *     cdef lxb_css_selectors_t* css_selectors = NULL
 *     cdef lxb_selectors_t* selectors = NULL
 */
  __pyx_v_css_parser = NULL;

  /* "resiliparse/extract/html2text.pyx":660
 * 
 *     cdef lxb_css_parser_t* css_parser = NULL
 *     cdef lxb_css_selectors_t* css_selectors = NULL             # <<<<<<<<<<<<<<
 *     cdef lxb_selectors_t* selectors = NULL
 * 
 */
  __pyx_v_css_selectors = NULL;

  /* "resiliparse/extract/html2text.pyx":661
 *     cdef lxb_css_parser_t* css_parser = NULL
 *     cdef lxb_css_selectors_t* css_selectors = NULL
 *     cdef lxb_selectors_t* selectors = NULL             # <<<<<<<<<<<<<<
 * 
 *     cdef lxb_css_selector_list_t* selector_list = NULL
 */
  __pyx_v_selectors = NULL;

  /* "resiliparse/extract/html2text.pyx":663
 *     cdef lxb_selectors_t* selectors = NULL
 * 
 *     cdef lxb_css_selector_list_t* selector_list = NULL             # <<<<<<<<<<<<<<
 *     cdef stl_set[lxb_dom_node_t*] preselected_nodes
 *     cdef string main_content_selector = b'.article-body, .articleBody, .contentBody, .article-text, .main-content,' \
 */
  __pyx_v_selector_list = NULL;

  /* "resiliparse/extract/html2text.pyx":665
 *     cdef lxb_css_selector_list_t* selector_list = NULL
 *     cdef stl_set[lxb_dom_node_t*] preselected_nodes
 *     cdef string main_content_selector = b'.article-body, .articleBody, .contentBody, .article-text, .main-content,' \             # <<<<<<<<<<<<<<
 *                                         b'.postcontent, .post-content, .single-post, [role="main"]'
 * 
 */
  __pyx_t_12 = __pyx_convert_string_from_py_std__in_string(__pyx_kp_b_article_body_articleBody_conten); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 665, __pyx_L1_error)
  __pyx_v_main_content_selector = __pyx_t_12;

  /* "resiliparse/extract/html2text.pyx":668
 *                                         b'.postcontent, .post-content, .single-post, [role="main"]'
 * 
 *     try:             # <<<<<<<<<<<<<<
 *         init_css_parser(&css_parser)
 *         init_css_selectors(css_parser, &css_selectors, &selectors)
 */
  /*try:*/ {

    /* "resiliparse/extract/html2text.pyx":669
 * 
 *     try:
 *         init_css_parser(&css_parser)             # <<<<<<<<<<<<<<
 *         init_css_selectors(css_parser, &css_selectors, &selectors)
 * 
 */
    __pyx_t_2 = __pyx_f_11resiliparse_5parse_4html_init_css_parser((&__pyx_v_css_parser)); if (unlikely(__pyx_t_2 == ((int)0))) __PYX_ERR(0, 669, __pyx_L17_error)

    /* "resiliparse/extract/html2text.pyx":670
 *     try:
 *         init_css_parser(&css_parser)
 *         init_css_selectors(css_parser, &css_selectors, &selectors)             # <<<<<<<<<<<<<<
 * 
 *         if main_content:
 */
    __pyx_t_2 = __pyx_f_11resiliparse_5parse_4html_init_css_selectors(__pyx_v_css_parser, (&__pyx_v_css_selectors), (&__pyx_v_selectors)); if (unlikely(__pyx_t_2 == ((int)0))) __PYX_ERR(0, 670, __pyx_L17_error)

    /* "resiliparse/extract/html2text.pyx":672
 *         init_css_selectors(css_parser, &css_selectors, &selectors)
 * 
 *         if main_content:             # <<<<<<<<<<<<<<
 *             # Opportunistically try to find general main content zone
 *             selector_list = parse_css_selectors(css_parser, <const lxb_char_t*>main_content_selector.data(),
 */
    __pyx_t_2 = (__pyx_v_main_content != 0);
    if (__pyx_t_2) {

      /* "resiliparse/extract/html2text.pyx":674
 *         if main_content:
 *             # Opportunistically try to find general main content zone
 *             selector_list = parse_css_selectors(css_parser, <const lxb_char_t*>main_content_selector.data(),             # <<<<<<<<<<<<<<
 *                                                 main_content_selector.size())
 *             lxb_selectors_find(selectors, ctx.root_node, selector_list,
 */
      __pyx_t_13 = __pyx_f_11resiliparse_5parse_4html_parse_css_selectors(__pyx_v_css_parser, ((lxb_char_t const *)__pyx_v_main_content_selector.data()), __pyx_v_main_content_selector.size()); if (unlikely(__pyx_t_13 == ((lxb_css_selector_list_t *)NULL))) __PYX_ERR(0, 674, __pyx_L17_error)
      __pyx_v_selector_list = __pyx_t_13;

      /* "resiliparse/extract/html2text.pyx":676
 *             selector_list = parse_css_selectors(css_parser, <const lxb_char_t*>main_content_selector.data(),
 *                                                 main_content_selector.size())
 *             lxb_selectors_find(selectors, ctx.root_node, selector_list,             # <<<<<<<<<<<<<<
 *                                <lxb_selectors_cb_f>_collect_selected_nodes_cb, &preselected_nodes)
 *             if preselected_nodes.size() == 1:
 */
      (void)(lxb_selectors_find(__pyx_v_selectors, __pyx_v_ctx.root_node, __pyx_v_selector_list, ((lxb_selectors_cb_f)__pyx_f_11resiliparse_7extract_9html2text__collect_selected_nodes_cb), (&__pyx_v_preselected_nodes)));

      /* "resiliparse/extract/html2text.pyx":678
 *             lxb_selectors_find(selectors, ctx.root_node, selector_list,
 *                                <lxb_selectors_cb_f>_collect_selected_nodes_cb, &preselected_nodes)
 *             if preselected_nodes.size() == 1:             # <<<<<<<<<<<<<<
 *                 # Use result only if there is exactly one match
 *                 ctx.root_node = deref(preselected_nodes.begin())
 */
      __pyx_t_2 = ((__pyx_v_preselected_nodes.size() == 1) != 0);
      if (__pyx_t_2) {

        /* "resiliparse/extract/html2text.pyx":680
 *             if preselected_nodes.size() == 1:
 *                 # Use result only if there is exactly one match
 *                 ctx.root_node = deref(preselected_nodes.begin())             # <<<<<<<<<<<<<<
 *                 ctx.node = ctx.root_node
 *             preselected_nodes.clear()
 */
        __pyx_v_ctx.root_node = (*__pyx_v_preselected_nodes.begin());

        /* "resiliparse/extract/html2text.pyx":681
 *                 # Use result only if there is exactly one match
 *                 ctx.root_node = deref(preselected_nodes.begin())
 *                 ctx.node = ctx.root_node             # <<<<<<<<<<<<<<
 *             preselected_nodes.clear()
 * 
 */
        __pyx_t_10 = __pyx_v_ctx.root_node;
        __pyx_v_ctx.node = __pyx_t_10;

        /* "resiliparse/extract/html2text.pyx":678
 *             lxb_selectors_find(selectors, ctx.root_node, selector_list,
 *                                <lxb_selectors_cb_f>_collect_selected_nodes_cb, &preselected_nodes)
 *             if preselected_nodes.size() == 1:             # <<<<<<<<<<<<<<
 *                 # Use result only if there is exactly one match
 *                 ctx.root_node = deref(preselected_nodes.begin())
 */
      }

      /* "resiliparse/extract/html2text.pyx":682
 *                 ctx.root_node = deref(preselected_nodes.begin())
 *                 ctx.node = ctx.root_node
 *             preselected_nodes.clear()             # <<<<<<<<<<<<<<
 * 
 *         # Select all blacklisted elements and save them in an ordered set
 */
      __pyx_v_preselected_nodes.clear();

      /* "resiliparse/extract/html2text.pyx":672
 *         init_css_selectors(css_parser, &css_selectors, &selectors)
 * 
 *         if main_content:             # <<<<<<<<<<<<<<
 *             # Opportunistically try to find general main content zone
 *             selector_list = parse_css_selectors(css_parser, <const lxb_char_t*>main_content_selector.data(),
 */
    }

    /* "resiliparse/extract/html2text.pyx":685
 * 
 *         # Select all blacklisted elements and save them in an ordered set
 *         combined_skip_sel = b','.join(skip_selectors)             # <<<<<<<<<<<<<<
 *         selector_list = parse_css_selectors(css_parser, <const lxb_char_t*>combined_skip_sel, len(combined_skip_sel))
 *         lxb_selectors_find(selectors, ctx.root_node, selector_list,
 */
    __pyx_t_4 = __Pyx_PyBytes_Join(__pyx_kp_b__2, __pyx_v_skip_selectors); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 685, __pyx_L17_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_combined_skip_sel = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "resiliparse/extract/html2text.pyx":686
 *         # Select all blacklisted elements and save them in an ordered set
 *         combined_skip_sel = b','.join(skip_selectors)
 *         selector_list = parse_css_selectors(css_parser, <const lxb_char_t*>combined_skip_sel, len(combined_skip_sel))             # <<<<<<<<<<<<<<
 *         lxb_selectors_find(selectors, ctx.root_node, selector_list,
 *                            <lxb_selectors_cb_f>_collect_selected_nodes_cb, &preselected_nodes)
 */
    __pyx_t_14 = __Pyx_PyObject_AsUString(__pyx_v_combined_skip_sel); if (unlikely((!__pyx_t_14) && PyErr_Occurred())) __PYX_ERR(0, 686, __pyx_L17_error)
    __pyx_t_5 = PyObject_Length(__pyx_v_combined_skip_sel); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 686, __pyx_L17_error)
    __pyx_t_13 = __pyx_f_11resiliparse_5parse_4html_parse_css_selectors(__pyx_v_css_parser, ((lxb_char_t const *)__pyx_t_14), __pyx_t_5); if (unlikely(__pyx_t_13 == ((lxb_css_selector_list_t *)NULL))) __PYX_ERR(0, 686, __pyx_L17_error)
    __pyx_v_selector_list = __pyx_t_13;

    /* "resiliparse/extract/html2text.pyx":687
 *         combined_skip_sel = b','.join(skip_selectors)
 *         selector_list = parse_css_selectors(css_parser, <const lxb_char_t*>combined_skip_sel, len(combined_skip_sel))
 *         lxb_selectors_find(selectors, ctx.root_node, selector_list,             # <<<<<<<<<<<<<<
 *                            <lxb_selectors_cb_f>_collect_selected_nodes_cb, &preselected_nodes)
 *     finally:
 */
    (void)(lxb_selectors_find(__pyx_v_selectors, __pyx_v_ctx.root_node, __pyx_v_selector_list, ((lxb_selectors_cb_f)__pyx_f_11resiliparse_7extract_9html2text__collect_selected_nodes_cb), (&__pyx_v_preselected_nodes)));
  }

  /* "resiliparse/extract/html2text.pyx":690
 *                            <lxb_selectors_cb_f>_collect_selected_nodes_cb, &preselected_nodes)
 *     finally:
 *         destroy_css_selectors(css_selectors, selectors)             # <<<<<<<<<<<<<<
 *         destroy_css_parser(css_parser)
 * 
 */
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_f_11resiliparse_5parse_4html_destroy_css_selectors(__pyx_v_css_selectors, __pyx_v_selectors);

      /* "resiliparse/extract/html2text.pyx":691
 *     finally:
 *         destroy_css_selectors(css_selectors, selectors)
 *         destroy_css_parser(css_parser)             # <<<<<<<<<<<<<<
 * 
 *     cdef size_t base_depth = 0
 */
      __pyx_f_11resiliparse_5parse_4html_destroy_css_parser(__pyx_v_css_parser);
      goto __pyx_L18;
    }
    __pyx_L17_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
      if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20) < 0)) __Pyx_ErrFetch(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
      __Pyx_XGOTREF(__pyx_t_18);
      __Pyx_XGOTREF(__pyx_t_19);
      __Pyx_XGOTREF(__pyx_t_20);
      __Pyx_XGOTREF(__pyx_t_21);
      __Pyx_XGOTREF(__pyx_t_22);
      __Pyx_XGOTREF(__pyx_t_23);
      __pyx_t_15 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_17 = __pyx_filename;
      {

        /* "resiliparse/extract/html2text.pyx":690
 *                            <lxb_selectors_cb_f>_collect_selected_nodes_cb, &preselected_nodes)
 *     finally:
 *         destroy_css_selectors(css_selectors, selectors)             # <<<<<<<<<<<<<<
 *         destroy_css_parser(css_parser)
 * 
 */
        __pyx_f_11resiliparse_5parse_4html_destroy_css_selectors(__pyx_v_css_selectors, __pyx_v_selectors);

        /* "resiliparse/extract/html2text.pyx":691
 *     finally:
 *         destroy_css_selectors(css_selectors, selectors)
 *         destroy_css_parser(css_parser)             # <<<<<<<<<<<<<<
 * 
 *     cdef size_t base_depth = 0
 */
        __pyx_f_11resiliparse_5parse_4html_destroy_css_parser(__pyx_v_css_parser);
      }
      if (PY_MAJOR_VERSION >= 3) {
        __Pyx_XGIVEREF(__pyx_t_21);
        __Pyx_XGIVEREF(__pyx_t_22);
        __Pyx_XGIVEREF(__pyx_t_23);
        __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23);
      }
      __Pyx_XGIVEREF(__pyx_t_18);
      __Pyx_XGIVEREF(__pyx_t_19);
      __Pyx_XGIVEREF(__pyx_t_20);
      __Pyx_ErrRestore(__pyx_t_18, __pyx_t_19, __pyx_t_20);
      __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
      __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_17;
      goto __pyx_L1_error;
    }
    __pyx_L18:;
  }

  /* "resiliparse/extract/html2text.pyx":693
 *         destroy_css_parser(css_parser)
 * 
 *     cdef size_t base_depth = 0             # <<<<<<<<<<<<<<
 *     cdef lxb_dom_node_t* pnode = ctx.node
 *     while pnode.local_name != LXB_TAG_BODY and pnode.parent:
 */
  __pyx_v_base_depth = 0;

  /* "resiliparse/extract/html2text.pyx":694
 * 
 *     cdef size_t base_depth = 0
 *     cdef lxb_dom_node_t* pnode = ctx.node             # <<<<<<<<<<<<<<
 *     while pnode.local_name != LXB_TAG_BODY and pnode.parent:
 *         preinc(base_depth)
 */
  __pyx_t_10 = __pyx_v_ctx.node;
  __pyx_v_pnode = __pyx_t_10;

  /* "resiliparse/extract/html2text.pyx":695
 *     cdef size_t base_depth = 0
 *     cdef lxb_dom_node_t* pnode = ctx.node
 *     while pnode.local_name != LXB_TAG_BODY and pnode.parent:             # <<<<<<<<<<<<<<
 *         preinc(base_depth)
 *         pnode = pnode.parent
 */
  while (1) {
    __pyx_t_24 = ((__pyx_v_pnode->local_name != LXB_TAG_BODY) != 0);
    if (__pyx_t_24) {
    } else {
      __pyx_t_2 = __pyx_t_24;
      goto __pyx_L25_bool_binop_done;
    }
    __pyx_t_24 = (__pyx_v_pnode->parent != 0);
    __pyx_t_2 = __pyx_t_24;
    __pyx_L25_bool_binop_done:;
    if (!__pyx_t_2) break;

    /* "resiliparse/extract/html2text.pyx":696
 *     cdef lxb_dom_node_t* pnode = ctx.node
 *     while pnode.local_name != LXB_TAG_BODY and pnode.parent:
 *         preinc(base_depth)             # <<<<<<<<<<<<<<
 *         pnode = pnode.parent
 * 
 */
    (void)((++__pyx_v_base_depth));

    /* "resiliparse/extract/html2text.pyx":697
 *     while pnode.local_name != LXB_TAG_BODY and pnode.parent:
 *         preinc(base_depth)
 *         pnode = pnode.parent             # <<<<<<<<<<<<<<
 * 
 *     cdef vector[shared_ptr[ExtractNode]] extract_nodes
 */
    __pyx_t_10 = __pyx_v_pnode->parent;
    __pyx_v_pnode = __pyx_t_10;
  }

  /* "resiliparse/extract/html2text.pyx":700
 * 
 *     cdef vector[shared_ptr[ExtractNode]] extract_nodes
 *     extract_nodes.reserve(150)             # <<<<<<<<<<<<<<
 *     with nogil:
 *         while ctx.node:
 */
  __pyx_v_extract_nodes.reserve(0x96);

  /* "resiliparse/extract/html2text.pyx":701
 *     cdef vector[shared_ptr[ExtractNode]] extract_nodes
 *     extract_nodes.reserve(150)
 *     with nogil:             # <<<<<<<<<<<<<<
 *         while ctx.node:
 *             # Skip everything except element and text nodes
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {

        /* "resiliparse/extract/html2text.pyx":702
 *     extract_nodes.reserve(150)
 *     with nogil:
 *         while ctx.node:             # <<<<<<<<<<<<<<
 *             # Skip everything except element and text nodes
 *             if ctx.node.type != LXB_DOM_NODE_TYPE_ELEMENT and ctx.node.type != LXB_DOM_NODE_TYPE_TEXT:
 */
        while (1) {
          __pyx_t_2 = (__pyx_v_ctx.node != 0);
          if (!__pyx_t_2) break;

          /* "resiliparse/extract/html2text.pyx":704
 *         while ctx.node:
 *             # Skip everything except element and text nodes
 *             if ctx.node.type != LXB_DOM_NODE_TYPE_ELEMENT and ctx.node.type != LXB_DOM_NODE_TYPE_TEXT:             # <<<<<<<<<<<<<<
 *                 is_end_tag = True
 *                 ctx.node = next_node(ctx.root_node, ctx.node, &ctx.depth, &is_end_tag)
 */
          switch (__pyx_v_ctx.node->type) {
            case LXB_DOM_NODE_TYPE_ELEMENT:
            case LXB_DOM_NODE_TYPE_TEXT:
            __pyx_t_2 = 0;
            break;
            default:
            __pyx_t_2 = 1;
            break;
          }
          if (__pyx_t_2) {

            /* "resiliparse/extract/html2text.pyx":705
 *             # Skip everything except element and text nodes
 *             if ctx.node.type != LXB_DOM_NODE_TYPE_ELEMENT and ctx.node.type != LXB_DOM_NODE_TYPE_TEXT:
 *                 is_end_tag = True             # <<<<<<<<<<<<<<
 *                 ctx.node = next_node(ctx.root_node, ctx.node, &ctx.depth, &is_end_tag)
 *                 continue
 */
            __pyx_v_is_end_tag = 1;

            /* "resiliparse/extract/html2text.pyx":706
 *             if ctx.node.type != LXB_DOM_NODE_TYPE_ELEMENT and ctx.node.type != LXB_DOM_NODE_TYPE_TEXT:
 *                 is_end_tag = True
 *                 ctx.node = next_node(ctx.root_node, ctx.node, &ctx.depth, &is_end_tag)             # <<<<<<<<<<<<<<
 *                 continue
 * 
 */
            __pyx_t_25.__pyx_n = 2;
            __pyx_t_25.depth = (&__pyx_v_ctx.depth);
            __pyx_t_25.end_tag = (&__pyx_v_is_end_tag);
            __pyx_t_10 = __pyx_f_11resiliparse_5parse_4html_next_node(__pyx_v_ctx.root_node, __pyx_v_ctx.node, &__pyx_t_25); 
            __pyx_v_ctx.node = __pyx_t_10;

            /* "resiliparse/extract/html2text.pyx":707
 *                 is_end_tag = True
 *                 ctx.node = next_node(ctx.root_node, ctx.node, &ctx.depth, &is_end_tag)
 *                 continue             # <<<<<<<<<<<<<<
 * 
 *             # Skip blacklisted or non-main-content nodes
 */
            goto __pyx_L30_continue;

            /* "resiliparse/extract/html2text.pyx":704
 *         while ctx.node:
 *             # Skip everything except element and text nodes
 *             if ctx.node.type != LXB_DOM_NODE_TYPE_ELEMENT and ctx.node.type != LXB_DOM_NODE_TYPE_TEXT:             # <<<<<<<<<<<<<<
 *                 is_end_tag = True
 *                 ctx.node = next_node(ctx.root_node, ctx.node, &ctx.depth, &is_end_tag)
 */
          }

          /* "resiliparse/extract/html2text.pyx":710
 * 
 *             # Skip blacklisted or non-main-content nodes
 *             if preselected_nodes.find(ctx.node) != preselected_nodes.end() or \             # <<<<<<<<<<<<<<
 *                     (main_content and not _is_main_content_node(ctx.node, ctx.depth + base_depth, comments)):
 *                 is_end_tag = True
 */
          __pyx_t_24 = ((__pyx_v_preselected_nodes.find(__pyx_v_ctx.node) != __pyx_v_preselected_nodes.end()) != 0);
          if (!__pyx_t_24) {
          } else {
            __pyx_t_2 = __pyx_t_24;
            goto __pyx_L34_bool_binop_done;
          }

          /* "resiliparse/extract/html2text.pyx":711
 *             # Skip blacklisted or non-main-content nodes
 *             if preselected_nodes.find(ctx.node) != preselected_nodes.end() or \
 *                     (main_content and not _is_main_content_node(ctx.node, ctx.depth + base_depth, comments)):             # <<<<<<<<<<<<<<
 *                 is_end_tag = True
 *                 ctx.node = next_node(ctx.root_node, ctx.node, &ctx.depth, &is_end_tag)
 */
          __pyx_t_24 = (__pyx_v_main_content != 0);
          if (__pyx_t_24) {
          } else {
            __pyx_t_2 = __pyx_t_24;
            goto __pyx_L34_bool_binop_done;
          }
          __pyx_t_24 = ((!(__pyx_f_11resiliparse_7extract_9html2text__is_main_content_node(__pyx_v_ctx.node, (__pyx_v_ctx.depth + __pyx_v_base_depth), __pyx_v_comments) != 0)) != 0);
          __pyx_t_2 = __pyx_t_24;
          __pyx_L34_bool_binop_done:;

          /* "resiliparse/extract/html2text.pyx":710
 * 
 *             # Skip blacklisted or non-main-content nodes
 *             if preselected_nodes.find(ctx.node) != preselected_nodes.end() or \             # <<<<<<<<<<<<<<
 *                     (main_content and not _is_main_content_node(ctx.node, ctx.depth + base_depth, comments)):
 *                 is_end_tag = True
 */
          if (__pyx_t_2) {

            /* "resiliparse/extract/html2text.pyx":712
 *             if preselected_nodes.find(ctx.node) != preselected_nodes.end() or \
 *                     (main_content and not _is_main_content_node(ctx.node, ctx.depth + base_depth, comments)):
 *                 is_end_tag = True             # <<<<<<<<<<<<<<
 *                 ctx.node = next_node(ctx.root_node, ctx.node, &ctx.depth, &is_end_tag)
 *                 continue
 */
            __pyx_v_is_end_tag = 1;

            /* "resiliparse/extract/html2text.pyx":713
 *                     (main_content and not _is_main_content_node(ctx.node, ctx.depth + base_depth, comments)):
 *                 is_end_tag = True
 *                 ctx.node = next_node(ctx.root_node, ctx.node, &ctx.depth, &is_end_tag)             # <<<<<<<<<<<<<<
 *                 continue
 * 
 */
            __pyx_t_25.__pyx_n = 2;
            __pyx_t_25.depth = (&__pyx_v_ctx.depth);
            __pyx_t_25.end_tag = (&__pyx_v_is_end_tag);
            __pyx_t_10 = __pyx_f_11resiliparse_5parse_4html_next_node(__pyx_v_ctx.root_node, __pyx_v_ctx.node, &__pyx_t_25); 
            __pyx_v_ctx.node = __pyx_t_10;

            /* "resiliparse/extract/html2text.pyx":714
 *                 is_end_tag = True
 *                 ctx.node = next_node(ctx.root_node, ctx.node, &ctx.depth, &is_end_tag)
 *                 continue             # <<<<<<<<<<<<<<
 * 
 *             _extract_cb(extract_nodes, ctx, is_end_tag)
 */
            goto __pyx_L30_continue;

            /* "resiliparse/extract/html2text.pyx":710
 * 
 *             # Skip blacklisted or non-main-content nodes
 *             if preselected_nodes.find(ctx.node) != preselected_nodes.end() or \             # <<<<<<<<<<<<<<
 *                     (main_content and not _is_main_content_node(ctx.node, ctx.depth + base_depth, comments)):
 *                 is_end_tag = True
 */
          }

          /* "resiliparse/extract/html2text.pyx":716
 *                 continue
 * 
 *             _extract_cb(extract_nodes, ctx, is_end_tag)             # <<<<<<<<<<<<<<
 * 
 *             ctx.node = next_node(ctx.root_node, ctx.node, &ctx.depth, &is_end_tag)
 */
          __pyx_f_11resiliparse_7extract_9html2text__extract_cb(__pyx_v_extract_nodes, __pyx_v_ctx, __pyx_v_is_end_tag);

          /* "resiliparse/extract/html2text.pyx":718
 *             _extract_cb(extract_nodes, ctx, is_end_tag)
 * 
 *             ctx.node = next_node(ctx.root_node, ctx.node, &ctx.depth, &is_end_tag)             # <<<<<<<<<<<<<<
 * 
 *     return bytes_to_str(_serialize_extract_nodes(extract_nodes, ctx.opts)).rstrip()
 */
          __pyx_t_25.__pyx_n = 2;
          __pyx_t_25.depth = (&__pyx_v_ctx.depth);
          __pyx_t_25.end_tag = (&__pyx_v_is_end_tag);
          __pyx_t_10 = __pyx_f_11resiliparse_5parse_4html_next_node(__pyx_v_ctx.root_node, __pyx_v_ctx.node, &__pyx_t_25); 
          __pyx_v_ctx.node = __pyx_t_10;
          __pyx_L30_continue:;
        }
      }

      /* "resiliparse/extract/html2text.pyx":701
 *     cdef vector[shared_ptr[ExtractNode]] extract_nodes
 *     extract_nodes.reserve(150)
 *     with nogil:             # <<<<<<<<<<<<<<
 *         while ctx.node:
 *             # Skip everything except element and text nodes
 */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L29;
        }
        __pyx_L29:;
      }
  }

  /* "resiliparse/extract/html2text.pyx":720
 *             ctx.node = next_node(ctx.root_node, ctx.node, &ctx.depth, &is_end_tag)
 * 
 *     return bytes_to_str(_serialize_extract_nodes(extract_nodes, ctx.opts)).rstrip()             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_bytes_to_str); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 720, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = __pyx_convert_PyBytes_string_to_py_std__in_string(__pyx_f_11resiliparse_7extract_9html2text__serialize_extract_nodes(__pyx_v_extract_nodes, __pyx_v_ctx.opts)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 720, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_8, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 720, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_rstrip); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 720, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 720, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "resiliparse/extract/html2text.pyx":583
 * 
 * 
 * def extract_plain_text(HTMLTree tree, bint preserve_formatting=True, bint main_content=False,             # <<<<<<<<<<<<<<
 *                        bint list_bullets=True,  bint alt_texts=True, bint links=False, bint form_fields=False,
 *                        bint noscript=False, bint comments=True, skip_elements=None):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("resiliparse.extract.html2text.extract_plain_text", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_skip_selectors);
  __Pyx_XDECREF(__pyx_v_combined_skip_sel);
  __Pyx_XDECREF(__pyx_7genexpr__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "resiliparse_common/string_util.pxd":22
 * 
 * 
 * cdef inline size_t lstrip_c_str(const char** s_ptr, size_t l) nogil:             # <<<<<<<<<<<<<<
 *     """Strip leading white space from a C string."""
 *     cdef const char* end = deref(s_ptr) + l
 */

static CYTHON_INLINE size_t __pyx_f_18resiliparse_common_11string_util_lstrip_c_str(char const **__pyx_v_s_ptr, size_t __pyx_v_l) {
  char const *__pyx_v_end;
  size_t __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;

  /* "resiliparse_common/string_util.pxd":24
 * cdef inline size_t lstrip_c_str(const char** s_ptr, size_t l) nogil:
 *     """Strip leading white space from a C string."""
 *     cdef const char* end = deref(s_ptr) + l             # <<<<<<<<<<<<<<
 *     while deref(s_ptr) < end and isspace(deref(s_ptr)[0]):
 *         inc(deref(s_ptr))
 */
  __pyx_v_end = ((*__pyx_v_s_ptr) + __pyx_v_l);

  /* "resiliparse_common/string_util.pxd":25
 *     """Strip leading white space from a C string."""
 *     cdef const char* end = deref(s_ptr) + l
 *     while deref(s_ptr) < end and isspace(deref(s_ptr)[0]):             # <<<<<<<<<<<<<<
 *         inc(deref(s_ptr))
 *     return end - deref(s_ptr)
 */
  while (1) {
    __pyx_t_2 = (((*__pyx_v_s_ptr) < __pyx_v_end) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_2 = (std::isspace(((*__pyx_v_s_ptr)[0])) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_1) break;

    /* "resiliparse_common/string_util.pxd":26
 *     cdef const char* end = deref(s_ptr) + l
 *     while deref(s_ptr) < end and isspace(deref(s_ptr)[0]):
 *         inc(deref(s_ptr))             # <<<<<<<<<<<<<<
 *     return end - deref(s_ptr)
 * 
 */
    (void)((++(*__pyx_v_s_ptr)));
  }

  /* "resiliparse_common/string_util.pxd":27
 *     while deref(s_ptr) < end and isspace(deref(s_ptr)[0]):
 *         inc(deref(s_ptr))
 *     return end - deref(s_ptr)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = (__pyx_v_end - (*__pyx_v_s_ptr));
  goto __pyx_L0;

  /* "resiliparse_common/string_util.pxd":22
 * 
 * 
 * cdef inline size_t lstrip_c_str(const char** s_ptr, size_t l) nogil:             # <<<<<<<<<<<<<<
 *     """Strip leading white space from a C string."""
 *     cdef const char* end = deref(s_ptr) + l
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "resiliparse_common/string_util.pxd":30
 * 
 * 
 * cdef inline size_t rstrip_c_str(const char** s_ptr, size_t l) nogil:             # <<<<<<<<<<<<<<
 *     """Strip trailing white space from a C string."""
 *     cdef const char* end = deref(s_ptr) + l
 */

static CYTHON_INLINE size_t __pyx_f_18resiliparse_common_11string_util_rstrip_c_str(char const **__pyx_v_s_ptr, size_t __pyx_v_l) {
  char const *__pyx_v_end;
  size_t __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;

  /* "resiliparse_common/string_util.pxd":32
 * cdef inline size_t rstrip_c_str(const char** s_ptr, size_t l) nogil:
 *     """Strip trailing white space from a C string."""
 *     cdef const char* end = deref(s_ptr) + l             # <<<<<<<<<<<<<<
 *     while end > deref(s_ptr) and isspace((end - 1)[0]):
 *         dec(end)
 */
  __pyx_v_end = ((*__pyx_v_s_ptr) + __pyx_v_l);

  /* "resiliparse_common/string_util.pxd":33
 *     """Strip trailing white space from a C string."""
 *     cdef const char* end = deref(s_ptr) + l
 *     while end > deref(s_ptr) and isspace((end - 1)[0]):             # <<<<<<<<<<<<<<
 *         dec(end)
 *     return end - deref(s_ptr)
 */
  while (1) {
    __pyx_t_2 = ((__pyx_v_end > (*__pyx_v_s_ptr)) != 0);
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_2 = (std::isspace(((__pyx_v_end - 1)[0])) != 0);
    __pyx_t_1 = __pyx_t_2;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_1) break;

    /* "resiliparse_common/string_util.pxd":34
 *     cdef const char* end = deref(s_ptr) + l
 *     while end > deref(s_ptr) and isspace((end - 1)[0]):
 *         dec(end)             # <<<<<<<<<<<<<<
 *     return end - deref(s_ptr)
 * 
 */
    (void)((--__pyx_v_end));
  }

  /* "resiliparse_common/string_util.pxd":35
 *     while end > deref(s_ptr) and isspace((end - 1)[0]):
 *         dec(end)
 *     return end - deref(s_ptr)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = (__pyx_v_end - (*__pyx_v_s_ptr));
  goto __pyx_L0;

  /* "resiliparse_common/string_util.pxd":30
 * 
 * 
 * cdef inline size_t rstrip_c_str(const char** s_ptr, size_t l) nogil:             # <<<<<<<<<<<<<<
 *     """Strip trailing white space from a C string."""
 *     cdef const char* end = deref(s_ptr) + l
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "resiliparse_common/string_util.pxd":38
 * 
 * 
 * cdef inline size_t strip_c_str(const char** s_ptr, size_t l) nogil:             # <<<<<<<<<<<<<<
 *     """Strip leading and trailing white space from a C string."""
 *     return rstrip_c_str(s_ptr, lstrip_c_str(s_ptr, l))
 */

static CYTHON_INLINE size_t __pyx_f_18resiliparse_common_11string_util_strip_c_str(char const **__pyx_v_s_ptr, size_t __pyx_v_l) {
  size_t __pyx_r;

  /* "resiliparse_common/string_util.pxd":40
 * cdef inline size_t strip_c_str(const char** s_ptr, size_t l) nogil:
 *     """Strip leading and trailing white space from a C string."""
 *     return rstrip_c_str(s_ptr, lstrip_c_str(s_ptr, l))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_f_18resiliparse_common_11string_util_rstrip_c_str(__pyx_v_s_ptr, __pyx_f_18resiliparse_common_11string_util_lstrip_c_str(__pyx_v_s_ptr, __pyx_v_l));
  goto __pyx_L0;

  /* "resiliparse_common/string_util.pxd":38
 * 
 * 
 * cdef inline size_t strip_c_str(const char** s_ptr, size_t l) nogil:             # <<<<<<<<<<<<<<
 *     """Strip leading and trailing white space from a C string."""
 *     return rstrip_c_str(s_ptr, lstrip_c_str(s_ptr, l))
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "resiliparse_common/string_util.pxd":52
 * 
 * 
 * cdef inline string rstrip_str(const string& s) nogil:             # <<<<<<<<<<<<<<
 *     """Strip leading white space from a C++ string."""
 *     cdef const char* start = s.data()
 */

static CYTHON_INLINE std::string __pyx_f_18resiliparse_common_11string_util_rstrip_str(std::string const &__pyx_v_s) {
  char const *__pyx_v_start;
  size_t __pyx_v_l;
  std::string __pyx_r;
  int __pyx_t_1;
  std::string __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "resiliparse_common/string_util.pxd":54
 * cdef inline string rstrip_str(const string& s) nogil:
 *     """Strip leading white space from a C++ string."""
 *     cdef const char* start = s.data()             # <<<<<<<<<<<<<<
 *     cdef size_t l = rstrip_c_str(&start, s.size())
 *     if l == s.size():
 */
  __pyx_v_start = __pyx_v_s.data();

  /* "resiliparse_common/string_util.pxd":55
 *     """Strip leading white space from a C++ string."""
 *     cdef const char* start = s.data()
 *     cdef size_t l = rstrip_c_str(&start, s.size())             # <<<<<<<<<<<<<<
 *     if l == s.size():
 *         return s
 */
  __pyx_v_l = __pyx_f_18resiliparse_common_11string_util_rstrip_c_str((&__pyx_v_start), __pyx_v_s.size());

  /* "resiliparse_common/string_util.pxd":56
 *     cdef const char* start = s.data()
 *     cdef size_t l = rstrip_c_str(&start, s.size())
 *     if l == s.size():             # <<<<<<<<<<<<<<
 *         return s
 *     return string(start, l)
 */
  __pyx_t_1 = ((__pyx_v_l == __pyx_v_s.size()) != 0);
  if (__pyx_t_1) {

    /* "resiliparse_common/string_util.pxd":57
 *     cdef size_t l = rstrip_c_str(&start, s.size())
 *     if l == s.size():
 *         return s             # <<<<<<<<<<<<<<
 *     return string(start, l)
 * 
 */
    __pyx_r = __pyx_v_s;
    goto __pyx_L0;

    /* "resiliparse_common/string_util.pxd":56
 *     cdef const char* start = s.data()
 *     cdef size_t l = rstrip_c_str(&start, s.size())
 *     if l == s.size():             # <<<<<<<<<<<<<<
 *         return s
 *     return string(start, l)
 */
  }

  /* "resiliparse_common/string_util.pxd":58
 *     if l == s.size():
 *         return s
 *     return string(start, l)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  try {
    __pyx_t_2 = std::string(__pyx_v_start, __pyx_v_l);
  } catch(...) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
    #endif
    __Pyx_CppExn2PyErr();
    #ifdef WITH_THREAD
    __Pyx_PyGILState_Release(__pyx_gilstate_save);
    #endif
    __PYX_ERR(1, 58, __pyx_L1_error)
  }
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  /* "resiliparse_common/string_util.pxd":52
 * 
 * 
 * cdef inline string rstrip_str(const string& s) nogil:             # <<<<<<<<<<<<<<
 *     """Strip leading white space from a C++ string."""
 *     cdef const char* start = s.data()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("resiliparse_common.string_util.rstrip_str", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 1);
  __Pyx_pretend_to_initialize(&__pyx_r);
  __pyx_L0:;
  return __pyx_r;
}

/* "resiliparse_common/string_util.pxd":61
 * 
 * 
 * cdef inline string strip_str(const string& s) nogil:             # <<<<<<<<<<<<<<
 *     """Strip leading and trailing white space from a C++ string."""
 *     cdef const char* start = s.data()
 */

static CYTHON_INLINE std::string __pyx_f_18resiliparse_common_11string_util_strip_str(std::string const &__pyx_v_s) {
  char const *__pyx_v_start;
  size_t __pyx_v_l;
  std::string __pyx_r;
  std::string __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* "resiliparse_common/string_util.pxd":63
 * cdef inline string strip_str(const string& s) nogil:
 *     """Strip leading and trailing white space from a C++ string."""
 *     cdef const char* start = s.data()             # <<<<<<<<<<<<<<
 *     cdef size_t l = strip_c_str(&start, s.size())
 *     return string(start, l)
 */
  __pyx_v_start = __pyx_v_s.data();

  /* "resiliparse_common/string_util.pxd":64
 *     """Strip leading and trailing white space from a C++ string."""
 *     cdef const char* start = s.data()
 *     cdef size_t l = strip_c_str(&start, s.size())             # <<<<<<<<<<<<<<
 *     return string(start, l)
 * 
 */
  __pyx_v_l = __pyx_f_18resiliparse_common_11string_util_strip_c_str((&__pyx_v_start), __pyx_v_s.size());

  /* "resiliparse_common/string_util.pxd":65
 *     cdef const char* start = s.data()
 *     cdef size_t l = strip_c_str(&start, s.size())
 *     return string(start, l)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  try {
    __pyx_t_1 = std::string(__pyx_v_start, __pyx_v_l);
  } catch(...) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
    #endif
    __Pyx_CppExn2PyErr();
    #ifdef WITH_THREAD
    __Pyx_PyGILState_Release(__pyx_gilstate_save);
    #endif
    __PYX_ERR(1, 65, __pyx_L1_error)
  }
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* "resiliparse_common/string_util.pxd":61
 * 
 * 
 * cdef inline string strip_str(const string& s) nogil:             # <<<<<<<<<<<<<<
 *     """Strip leading and trailing white space from a C++ string."""
 *     cdef const char* start = s.data()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("resiliparse_common.string_util.strip_str", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 1);
  __Pyx_pretend_to_initialize(&__pyx_r);
  __pyx_L0:;
  return __pyx_r;
}

/* "resiliparse_common/string_util.pxd":68
 * 
 * 
 * cdef inline string str_to_lower(string s) nogil:             # <<<<<<<<<<<<<<
 *     """Convert a C++ string to lower-case characters."""
 *     cdef size_t i
 */

static CYTHON_INLINE std::string __pyx_f_18resiliparse_common_11string_util_str_to_lower(std::string __pyx_v_s) {
  size_t __pyx_v_i;
  std::string __pyx_r;
  size_t __pyx_t_1;
  size_t __pyx_t_2;
  size_t __pyx_t_3;

  /* "resiliparse_common/string_util.pxd":71
 *     """Convert a C++ string to lower-case characters."""
 *     cdef size_t i
 *     for i in range(s.size()):             # <<<<<<<<<<<<<<
 *         s[i] = tolower(s[i])
 *     return s
 */
  __pyx_t_1 = __pyx_v_s.size();
  __pyx_t_2 = __pyx_t_1;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "resiliparse_common/string_util.pxd":72
 *     cdef size_t i
 *     for i in range(s.size()):
 *         s[i] = tolower(s[i])             # <<<<<<<<<<<<<<
 *     return s
 */
    (__pyx_v_s[__pyx_v_i]) = std::tolower((__pyx_v_s[__pyx_v_i]));
  }

  /* "resiliparse_common/string_util.pxd":73
 *     for i in range(s.size()):
 *         s[i] = tolower(s[i])
 *     return s             # <<<<<<<<<<<<<<
 */
  __pyx_r = __pyx_v_s;
  goto __pyx_L0;

  /* "resiliparse_common/string_util.pxd":68
 * 
 * 
 * cdef inline string str_to_lower(string s) nogil:             # <<<<<<<<<<<<<<
 *     """Convert a C++ string to lower-case characters."""
 *     cdef size_t i
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "resiliparse/parse/html.pxd":21
 * 
 * 
 * cdef inline bint check_node(DOMNode node):             # <<<<<<<<<<<<<<
 *     """Check whether node is initialized and valid."""
 *     return node is not None and node.tree is not None and node.node != NULL
 */

static CYTHON_INLINE int __pyx_f_11resiliparse_5parse_4html_check_node(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode *__pyx_v_node) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("check_node", 0);

  /* "resiliparse/parse/html.pxd":23
 * cdef inline bint check_node(DOMNode node):
 *     """Check whether node is initialized and valid."""
 *     return node is not None and node.tree is not None and node.node != NULL             # <<<<<<<<<<<<<<
 * 
 * cdef bint init_css_parser(lxb_css_parser_t** parser) except 0
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_node) != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_3 = (((PyObject *)__pyx_v_node->tree) != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L3_bool_binop_done;
  }
  __pyx_t_2 = ((__pyx_v_node->node != NULL) != 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L3_bool_binop_done:;
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  /* "resiliparse/parse/html.pxd":21
 * 
 * 
 * cdef inline bint check_node(DOMNode node):             # <<<<<<<<<<<<<<
 *     """Check whether node is initialized and valid."""
 *     return node is not None and node.tree is not None and node.node != NULL
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "resiliparse/parse/html.pxd":36
 *                                size_t* depth=*, bint* end_tag=*) nogil
 * 
 * cdef inline lxb_dom_node_t* next_element_node(const lxb_dom_node_t* root_node, lxb_dom_node_t* node,             # <<<<<<<<<<<<<<
 *                                               size_t* depth=NULL, bint* end_tag=NULL) nogil:
 *     node = next_node(root_node, node, depth, end_tag)
 */

static CYTHON_INLINE lxb_dom_node_t *__pyx_f_11resiliparse_5parse_4html_next_element_node(lxb_dom_node_t const *__pyx_v_root_node, lxb_dom_node_t *__pyx_v_node, struct __pyx_opt_args_11resiliparse_5parse_4html_next_element_node *__pyx_optional_args) {

  /* "resiliparse/parse/html.pxd":37
 * 
 * cdef inline lxb_dom_node_t* next_element_node(const lxb_dom_node_t* root_node, lxb_dom_node_t* node,
 *                                               size_t* depth=NULL, bint* end_tag=NULL) nogil:             # <<<<<<<<<<<<<<
 *     node = next_node(root_node, node, depth, end_tag)
 *     while node and node.type != LXB_DOM_NODE_TYPE_ELEMENT:
 */
  size_t *__pyx_v_depth = ((size_t *)NULL);
  int *__pyx_v_end_tag = ((int *)NULL);
  lxb_dom_node_t *__pyx_r;
  lxb_dom_node_t *__pyx_t_1;
  struct __pyx_opt_args_11resiliparse_5parse_4html_next_node __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_depth = __pyx_optional_args->depth;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_end_tag = __pyx_optional_args->end_tag;
      }
    }
  }

  /* "resiliparse/parse/html.pxd":38
 * cdef inline lxb_dom_node_t* next_element_node(const lxb_dom_node_t* root_node, lxb_dom_node_t* node,
 *                                               size_t* depth=NULL, bint* end_tag=NULL) nogil:
 *     node = next_node(root_node, node, depth, end_tag)             # <<<<<<<<<<<<<<
 *     while node and node.type != LXB_DOM_NODE_TYPE_ELEMENT:
 *         node = next_node(root_node, node, depth, end_tag)
 */
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.depth = __pyx_v_depth;
  __pyx_t_2.end_tag = __pyx_v_end_tag;
  __pyx_t_1 = __pyx_f_11resiliparse_5parse_4html_next_node(__pyx_v_root_node, __pyx_v_node, &__pyx_t_2); 
  __pyx_v_node = __pyx_t_1;

  /* "resiliparse/parse/html.pxd":39
 *                                               size_t* depth=NULL, bint* end_tag=NULL) nogil:
 *     node = next_node(root_node, node, depth, end_tag)
 *     while node and node.type != LXB_DOM_NODE_TYPE_ELEMENT:             # <<<<<<<<<<<<<<
 *         node = next_node(root_node, node, depth, end_tag)
 *     return node
 */
  while (1) {
    __pyx_t_4 = (__pyx_v_node != 0);
    if (__pyx_t_4) {
    } else {
      __pyx_t_3 = __pyx_t_4;
      goto __pyx_L5_bool_binop_done;
    }
    __pyx_t_4 = ((__pyx_v_node->type != LXB_DOM_NODE_TYPE_ELEMENT) != 0);
    __pyx_t_3 = __pyx_t_4;
    __pyx_L5_bool_binop_done:;
    if (!__pyx_t_3) break;

    /* "resiliparse/parse/html.pxd":40
 *     node = next_node(root_node, node, depth, end_tag)
 *     while node and node.type != LXB_DOM_NODE_TYPE_ELEMENT:
 *         node = next_node(root_node, node, depth, end_tag)             # <<<<<<<<<<<<<<
 *     return node
 * 
 */
    __pyx_t_2.__pyx_n = 2;
    __pyx_t_2.depth = __pyx_v_depth;
    __pyx_t_2.end_tag = __pyx_v_end_tag;
    __pyx_t_1 = __pyx_f_11resiliparse_5parse_4html_next_node(__pyx_v_root_node, __pyx_v_node, &__pyx_t_2); 
    __pyx_v_node = __pyx_t_1;
  }

  /* "resiliparse/parse/html.pxd":41
 *     while node and node.type != LXB_DOM_NODE_TYPE_ELEMENT:
 *         node = next_node(root_node, node, depth, end_tag)
 *     return node             # <<<<<<<<<<<<<<
 * 
 * cdef inline string_view get_node_attr_sv(lxb_dom_node_t* node, const string& attr) nogil:
 */
  __pyx_r = __pyx_v_node;
  goto __pyx_L0;

  /* "resiliparse/parse/html.pxd":36
 *                                size_t* depth=*, bint* end_tag=*) nogil
 * 
 * cdef inline lxb_dom_node_t* next_element_node(const lxb_dom_node_t* root_node, lxb_dom_node_t* node,             # <<<<<<<<<<<<<<
 *                                               size_t* depth=NULL, bint* end_tag=NULL) nogil:
 *     node = next_node(root_node, node, depth, end_tag)
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "resiliparse/parse/html.pxd":43
 *     return node
 * 
 * cdef inline string_view get_node_attr_sv(lxb_dom_node_t* node, const string& attr) nogil:             # <<<<<<<<<<<<<<
 *     """Get node attribute value as string_view."""
 *     cdef size_t node_attr_len
 */

static CYTHON_INLINE std::string_view __pyx_f_11resiliparse_5parse_4html_get_node_attr_sv(lxb_dom_node_t *__pyx_v_node, std::string const &__pyx_v_attr) {
  size_t __pyx_v_node_attr_len;
  lxb_char_t const *__pyx_v_node_attr_data;
  std::string_view __pyx_r;

  /* "resiliparse/parse/html.pxd":46
 *     """Get node attribute value as string_view."""
 *     cdef size_t node_attr_len
 *     cdef const lxb_char_t* node_attr_data = lxb_dom_element_get_attribute(             # <<<<<<<<<<<<<<
 *         <lxb_dom_element_t*>node, <lxb_char_t*>attr.data(), attr.size(), &node_attr_len)
 *     return string_view(<const char*>node_attr_data, node_attr_len)
 */
  __pyx_v_node_attr_data = lxb_dom_element_get_attribute(((lxb_dom_element_t *)__pyx_v_node), ((lxb_char_t *)__pyx_v_attr.data()), __pyx_v_attr.size(), (&__pyx_v_node_attr_len));

  /* "resiliparse/parse/html.pxd":48
 *     cdef const lxb_char_t* node_attr_data = lxb_dom_element_get_attribute(
 *         <lxb_dom_element_t*>node, <lxb_char_t*>attr.data(), attr.size(), &node_attr_len)
 *     return string_view(<const char*>node_attr_data, node_attr_len)             # <<<<<<<<<<<<<<
 * 
 * cdef inline StringPiece get_node_attr_sp(lxb_dom_node_t* node, const string& attr) nogil:
 */
  __pyx_r = std::string_view(((char const *)__pyx_v_node_attr_data), __pyx_v_node_attr_len);
  goto __pyx_L0;

  /* "resiliparse/parse/html.pxd":43
 *     return node
 * 
 * cdef inline string_view get_node_attr_sv(lxb_dom_node_t* node, const string& attr) nogil:             # <<<<<<<<<<<<<<
 *     """Get node attribute value as string_view."""
 *     cdef size_t node_attr_len
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "resiliparse/parse/html.pxd":50
 *     return string_view(<const char*>node_attr_data, node_attr_len)
 * 
 * cdef inline StringPiece get_node_attr_sp(lxb_dom_node_t* node, const string& attr) nogil:             # <<<<<<<<<<<<<<
 *     """Get node attribute value as RE2 StringPiece."""
 *     cdef size_t node_attr_len
 */

static CYTHON_INLINE re2::StringPiece __pyx_f_11resiliparse_5parse_4html_get_node_attr_sp(lxb_dom_node_t *__pyx_v_node, std::string const &__pyx_v_attr) {
  size_t __pyx_v_node_attr_len;
  lxb_char_t const *__pyx_v_node_attr_data;
  re2::StringPiece __pyx_r;

  /* "resiliparse/parse/html.pxd":53
 *     """Get node attribute value as RE2 StringPiece."""
 *     cdef size_t node_attr_len
 *     cdef const lxb_char_t* node_attr_data = lxb_dom_element_get_attribute(             # <<<<<<<<<<<<<<
 *         <lxb_dom_element_t*>node, <lxb_char_t*>attr.data(), attr.size(), &node_attr_len)
 *     return StringPiece(<const char*>node_attr_data, node_attr_len)
 */
  __pyx_v_node_attr_data = lxb_dom_element_get_attribute(((lxb_dom_element_t *)__pyx_v_node), ((lxb_char_t *)__pyx_v_attr.data()), __pyx_v_attr.size(), (&__pyx_v_node_attr_len));

  /* "resiliparse/parse/html.pxd":55
 *     cdef const lxb_char_t* node_attr_data = lxb_dom_element_get_attribute(
 *         <lxb_dom_element_t*>node, <lxb_char_t*>attr.data(), attr.size(), &node_attr_len)
 *     return StringPiece(<const char*>node_attr_data, node_attr_len)             # <<<<<<<<<<<<<<
 * 
 * cdef string get_node_text(lxb_dom_node_t* node) nogil
 */
  __pyx_r = re2::StringPiece(((char const *)__pyx_v_node_attr_data), __pyx_v_node_attr_len);
  goto __pyx_L0;

  /* "resiliparse/parse/html.pxd":50
 *     return string_view(<const char*>node_attr_data, node_attr_len)
 * 
 * cdef inline StringPiece get_node_attr_sp(lxb_dom_node_t* node, const string& attr) nogil:             # <<<<<<<<<<<<<<
 *     """Get node attribute value as RE2 StringPiece."""
 *     cdef size_t node_attr_len
 */

  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}

/* "string.from_py":13
 * 
 * @cname("__pyx_convert_string_from_py_std__in_string")
 * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *:             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t length = 0
 *     cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length)
 */

static std::string __pyx_convert_string_from_py_std__in_string(PyObject *__pyx_v_o) {
  Py_ssize_t __pyx_v_length;
  char const *__pyx_v_data;
  std::string __pyx_r;
  __Pyx_RefNannyDeclarations
  char const *__pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_convert_string_from_py_std__in_string", 0);

  /* "string.from_py":14
 * @cname("__pyx_convert_string_from_py_std__in_string")
 * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *:
 *     cdef Py_ssize_t length = 0             # <<<<<<<<<<<<<<
 *     cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length)
 *     return string(data, length)
 */
  __pyx_v_length = 0;

  /* "string.from_py":15
 * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *:
 *     cdef Py_ssize_t length = 0
 *     cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length)             # <<<<<<<<<<<<<<
 *     return string(data, length)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_AsStringAndSize(__pyx_v_o, (&__pyx_v_length)); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(2, 15, __pyx_L1_error)
  __pyx_v_data = __pyx_t_1;

  /* "string.from_py":16
 *     cdef Py_ssize_t length = 0
 *     cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length)
 *     return string(data, length)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = std::string(__pyx_v_data, __pyx_v_length);
  goto __pyx_L0;

  /* "string.from_py":13
 * 
 * @cname("__pyx_convert_string_from_py_std__in_string")
 * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *:             # <<<<<<<<<<<<<<
 *     cdef Py_ssize_t length = 0
 *     cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("string.from_py.__pyx_convert_string_from_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_pretend_to_initialize(&__pyx_r);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "set.from_py":108
 * 
 * @cname("__pyx_convert_set_from_py_std_3a__3a_string")
 * cdef set[X] __pyx_convert_set_from_py_std_3a__3a_string(object o) except *:             # <<<<<<<<<<<<<<
 *     cdef set[X] s
 *     for item in o:
 */

static std::set<std::string>  __pyx_convert_set_from_py_std_3a__3a_string(PyObject *__pyx_v_o) {
  std::set<std::string>  __pyx_v_s;
  PyObject *__pyx_v_item = NULL;
  std::set<std::string>  __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  std::string __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_convert_set_from_py_std_3a__3a_string", 0);

  /* "set.from_py":110
 * cdef set[X] __pyx_convert_set_from_py_std_3a__3a_string(object o) except *:
 *     cdef set[X] s
 *     for item in o:             # <<<<<<<<<<<<<<
 *         s.insert(<X>item)
 *     return s
 */
  if (likely(PyList_CheckExact(__pyx_v_o)) || PyTuple_CheckExact(__pyx_v_o)) {
    __pyx_t_1 = __pyx_v_o; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_o); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 110, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 110, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(2, 110, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 110, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(2, 110, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 110, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(2, 110, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "set.from_py":111
 *     cdef set[X] s
 *     for item in o:
 *         s.insert(<X>item)             # <<<<<<<<<<<<<<
 *     return s
 * 
 */
    __pyx_t_5 = __pyx_convert_string_from_py_std__in_string(__pyx_v_item); if (unlikely(PyErr_Occurred())) __PYX_ERR(2, 111, __pyx_L1_error)
    __pyx_v_s.insert(((std::string)__pyx_t_5));

    /* "set.from_py":110
 * cdef set[X] __pyx_convert_set_from_py_std_3a__3a_string(object o) except *:
 *     cdef set[X] s
 *     for item in o:             # <<<<<<<<<<<<<<
 *         s.insert(<X>item)
 *     return s
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "set.from_py":112
 *     for item in o:
 *         s.insert(<X>item)
 *     return s             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_s;
  goto __pyx_L0;

  /* "set.from_py":108
 * 
 * @cname("__pyx_convert_set_from_py_std_3a__3a_string")
 * cdef set[X] __pyx_convert_set_from_py_std_3a__3a_string(object o) except *:             # <<<<<<<<<<<<<<
 *     cdef set[X] s
 *     for item in o:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("set.from_py.__pyx_convert_set_from_py_std_3a__3a_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_pretend_to_initialize(&__pyx_r);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "string.to_py":31
 * 
 * @cname("__pyx_convert_PyObject_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s):             # <<<<<<<<<<<<<<
 *     return __Pyx_PyObject_FromStringAndSize(s.data(), s.size())
 * cdef extern from *:
 */

static CYTHON_INLINE PyObject *__pyx_convert_PyObject_string_to_py_std__in_string(std::string const &__pyx_v_s) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_convert_PyObject_string_to_py_std__in_string", 0);

  /* "string.to_py":32
 * @cname("__pyx_convert_PyObject_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s):
 *     return __Pyx_PyObject_FromStringAndSize(s.data(), s.size())             # <<<<<<<<<<<<<<
 * cdef extern from *:
 *     cdef object __Pyx_PyUnicode_FromStringAndSize(const char*, size_t)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 32, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "string.to_py":31
 * 
 * @cname("__pyx_convert_PyObject_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s):             # <<<<<<<<<<<<<<
 *     return __Pyx_PyObject_FromStringAndSize(s.data(), s.size())
 * cdef extern from *:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("string.to_py.__pyx_convert_PyObject_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "string.to_py":37
 * 
 * @cname("__pyx_convert_PyUnicode_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s):             # <<<<<<<<<<<<<<
 *     return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size())
 * cdef extern from *:
 */

static CYTHON_INLINE PyObject *__pyx_convert_PyUnicode_string_to_py_std__in_string(std::string const &__pyx_v_s) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_convert_PyUnicode_string_to_py_std__in_string", 0);

  /* "string.to_py":38
 * @cname("__pyx_convert_PyUnicode_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s):
 *     return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size())             # <<<<<<<<<<<<<<
 * cdef extern from *:
 *     cdef object __Pyx_PyStr_FromStringAndSize(const char*, size_t)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyUnicode_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 38, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "string.to_py":37
 * 
 * @cname("__pyx_convert_PyUnicode_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s):             # <<<<<<<<<<<<<<
 *     return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size())
 * cdef extern from *:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("string.to_py.__pyx_convert_PyUnicode_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "string.to_py":43
 * 
 * @cname("__pyx_convert_PyStr_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s):             # <<<<<<<<<<<<<<
 *     return __Pyx_PyStr_FromStringAndSize(s.data(), s.size())
 * cdef extern from *:
 */

static CYTHON_INLINE PyObject *__pyx_convert_PyStr_string_to_py_std__in_string(std::string const &__pyx_v_s) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_convert_PyStr_string_to_py_std__in_string", 0);

  /* "string.to_py":44
 * @cname("__pyx_convert_PyStr_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s):
 *     return __Pyx_PyStr_FromStringAndSize(s.data(), s.size())             # <<<<<<<<<<<<<<
 * cdef extern from *:
 *     cdef object __Pyx_PyBytes_FromStringAndSize(const char*, size_t)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyStr_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 44, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "string.to_py":43
 * 
 * @cname("__pyx_convert_PyStr_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s):             # <<<<<<<<<<<<<<
 *     return __Pyx_PyStr_FromStringAndSize(s.data(), s.size())
 * cdef extern from *:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("string.to_py.__pyx_convert_PyStr_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "string.to_py":49
 * 
 * @cname("__pyx_convert_PyBytes_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s):             # <<<<<<<<<<<<<<
 *     return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size())
 * cdef extern from *:
 */

static CYTHON_INLINE PyObject *__pyx_convert_PyBytes_string_to_py_std__in_string(std::string const &__pyx_v_s) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_convert_PyBytes_string_to_py_std__in_string", 0);

  /* "string.to_py":50
 * @cname("__pyx_convert_PyBytes_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s):
 *     return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size())             # <<<<<<<<<<<<<<
 * cdef extern from *:
 *     cdef object __Pyx_PyByteArray_FromStringAndSize(const char*, size_t)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "string.to_py":49
 * 
 * @cname("__pyx_convert_PyBytes_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s):             # <<<<<<<<<<<<<<
 *     return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size())
 * cdef extern from *:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("string.to_py.__pyx_convert_PyBytes_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "string.to_py":55
 * 
 * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s):             # <<<<<<<<<<<<<<
 *     return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size())
 * 
 */

static CYTHON_INLINE PyObject *__pyx_convert_PyByteArray_string_to_py_std__in_string(std::string const &__pyx_v_s) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_convert_PyByteArray_string_to_py_std__in_string", 0);

  /* "string.to_py":56
 * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s):
 *     return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size())             # <<<<<<<<<<<<<<
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyByteArray_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 56, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "string.to_py":55
 * 
 * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s):             # <<<<<<<<<<<<<<
 *     return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size())
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("string.to_py.__pyx_convert_PyByteArray_string_to_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
#if CYTHON_PEP489_MULTI_PHASE_INIT
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
static int __pyx_pymod_exec_html2text(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  {Py_mod_create, (void*)__pyx_pymod_create},
  {Py_mod_exec, (void*)__pyx_pymod_exec_html2text},
  {0, NULL}
};
#endif

static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "html2text",
    0, /* m_doc */
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    0, /* m_size */
  #else
    -1, /* m_size */
  #endif
    __pyx_methods /* m_methods */,
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    __pyx_moduledef_slots, /* m_slots */
  #else
    NULL, /* m_reload */
  #endif
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
    #define CYTHON_SMALL_CODE
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
    #define CYTHON_SMALL_CODE __attribute__((cold))
#else
    #define CYTHON_SMALL_CODE
#endif
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_u_, __pyx_k_, sizeof(__pyx_k_), 0, 1, 0, 0},
  {&__pyx_kp_b__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 0, 0},
  {&__pyx_n_b_alert, __pyx_k_alert, sizeof(__pyx_k_alert), 0, 0, 0, 1},
  {&__pyx_n_s_alt_texts, __pyx_k_alt_texts, sizeof(__pyx_k_alt_texts), 0, 0, 1, 1},
  {&__pyx_n_b_area, __pyx_k_area, sizeof(__pyx_k_area), 0, 0, 0, 1},
  {&__pyx_kp_b_article_body_articleBody_conten, __pyx_k_article_body_articleBody_conten, sizeof(__pyx_k_article_body_articleBody_conten), 0, 0, 0, 0},
  {&__pyx_n_b_audio, __pyx_k_audio, sizeof(__pyx_k_audio), 0, 0, 0, 1},
  {&__pyx_n_b_banner, __pyx_k_banner, sizeof(__pyx_k_banner), 0, 0, 0, 1},
  {&__pyx_n_s_base_depth, __pyx_k_base_depth, sizeof(__pyx_k_base_depth), 0, 0, 1, 1},
  {&__pyx_n_s_body, __pyx_k_body, sizeof(__pyx_k_body), 0, 0, 1, 1},
  {&__pyx_n_b_button, __pyx_k_button, sizeof(__pyx_k_button), 0, 0, 0, 1},
  {&__pyx_n_s_bytes_to_str, __pyx_k_bytes_to_str, sizeof(__pyx_k_bytes_to_str), 0, 0, 1, 1},
  {&__pyx_n_b_checkbox, __pyx_k_checkbox, sizeof(__pyx_k_checkbox), 0, 0, 0, 1},
  {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  {&__pyx_n_s_combined_skip_sel, __pyx_k_combined_skip_sel, sizeof(__pyx_k_combined_skip_sel), 0, 0, 1, 1},
  {&__pyx_n_b_comment, __pyx_k_comment, sizeof(__pyx_k_comment), 0, 0, 0, 1},
  {&__pyx_n_s_comments, __pyx_k_comments, sizeof(__pyx_k_comments), 0, 0, 1, 1},
  {&__pyx_n_b_complementary, __pyx_k_complementary, sizeof(__pyx_k_complementary), 0, 0, 0, 1},
  {&__pyx_n_b_contentinfo, __pyx_k_contentinfo, sizeof(__pyx_k_contentinfo), 0, 0, 0, 1},
  {&__pyx_n_s_css_parser, __pyx_k_css_parser, sizeof(__pyx_k_css_parser), 0, 0, 1, 1},
  {&__pyx_n_s_css_selectors, __pyx_k_css_selectors, sizeof(__pyx_k_css_selectors), 0, 0, 1, 1},
  {&__pyx_n_s_ctx, __pyx_k_ctx, sizeof(__pyx_k_ctx), 0, 0, 1, 1},
  {&__pyx_n_b_dialog, __pyx_k_dialog, sizeof(__pyx_k_dialog), 0, 0, 0, 1},
  {&__pyx_n_s_e, __pyx_k_e, sizeof(__pyx_k_e), 0, 0, 1, 1},
  {&__pyx_n_b_embedimg, __pyx_k_embedimg, sizeof(__pyx_k_embedimg), 0, 0, 0, 1},
  {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
  {&__pyx_n_s_extract_nodes, __pyx_k_extract_nodes, sizeof(__pyx_k_extract_nodes), 0, 0, 1, 1},
  {&__pyx_n_s_extract_plain_text, __pyx_k_extract_plain_text, sizeof(__pyx_k_extract_plain_text), 0, 0, 1, 1},
  {&__pyx_n_b_figcaption, __pyx_k_figcaption, sizeof(__pyx_k_figcaption), 0, 0, 0, 1},
  {&__pyx_n_b_figure, __pyx_k_figure, sizeof(__pyx_k_figure), 0, 0, 0, 1},
  {&__pyx_n_s_form_fields, __pyx_k_form_fields, sizeof(__pyx_k_form_fields), 0, 0, 1, 1},
  {&__pyx_n_b_frame, __pyx_k_frame, sizeof(__pyx_k_frame), 0, 0, 0, 1},
  {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
  {&__pyx_n_b_iframe, __pyx_k_iframe, sizeof(__pyx_k_iframe), 0, 0, 0, 1},
  {&__pyx_n_b_img, __pyx_k_img, sizeof(__pyx_k_img), 0, 0, 0, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_b_input, __pyx_k_input, sizeof(__pyx_k_input), 0, 0, 0, 1},
  {&__pyx_n_s_is_end_tag, __pyx_k_is_end_tag, sizeof(__pyx_k_is_end_tag), 0, 0, 1, 1},
  {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
  {&__pyx_n_b_label, __pyx_k_label, sizeof(__pyx_k_label), 0, 0, 0, 1},
  {&__pyx_n_s_links, __pyx_k_links, sizeof(__pyx_k_links), 0, 0, 1, 1},
  {&__pyx_n_s_list_bullets, __pyx_k_list_bullets, sizeof(__pyx_k_list_bullets), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_main_content, __pyx_k_main_content, sizeof(__pyx_k_main_content), 0, 0, 1, 1},
  {&__pyx_n_s_main_content_selector, __pyx_k_main_content_selector, sizeof(__pyx_k_main_content_selector), 0, 0, 1, 1},
  {&__pyx_n_b_menu, __pyx_k_menu, sizeof(__pyx_k_menu), 0, 0, 0, 1},
  {&__pyx_n_b_menubar, __pyx_k_menubar, sizeof(__pyx_k_menubar), 0, 0, 0, 1},
  {&__pyx_n_b_menuitem, __pyx_k_menuitem, sizeof(__pyx_k_menuitem), 0, 0, 0, 1},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_n_b_navigation, __pyx_k_navigation, sizeof(__pyx_k_navigation), 0, 0, 0, 1},
  {&__pyx_n_b_noscript, __pyx_k_noscript, sizeof(__pyx_k_noscript), 0, 0, 0, 1},
  {&__pyx_n_s_noscript, __pyx_k_noscript, sizeof(__pyx_k_noscript), 0, 0, 1, 1},
  {&__pyx_n_b_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 0, 1},
  {&__pyx_n_b_option, __pyx_k_option, sizeof(__pyx_k_option), 0, 0, 0, 1},
  {&__pyx_n_s_pnode, __pyx_k_pnode, sizeof(__pyx_k_pnode), 0, 0, 1, 1},
  {&__pyx_n_s_preselected_nodes, __pyx_k_preselected_nodes, sizeof(__pyx_k_preselected_nodes), 0, 0, 1, 1},
  {&__pyx_n_b_presentation, __pyx_k_presentation, sizeof(__pyx_k_presentation), 0, 0, 0, 1},
  {&__pyx_n_s_preserve_formatting, __pyx_k_preserve_formatting, sizeof(__pyx_k_preserve_formatting), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_n_b_radio, __pyx_k_radio, sizeof(__pyx_k_radio), 0, 0, 0, 1},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_resiliparse_extract_html2text, __pyx_k_resiliparse_extract_html2text, sizeof(__pyx_k_resiliparse_extract_html2text), 0, 0, 1, 1},
  {&__pyx_kp_s_resiliparse_extract_html2text_py, __pyx_k_resiliparse_extract_html2text_py, sizeof(__pyx_k_resiliparse_extract_html2text_py), 0, 0, 1, 0},
  {&__pyx_n_s_resiliparse_parse_encoding, __pyx_k_resiliparse_parse_encoding, sizeof(__pyx_k_resiliparse_parse_encoding), 0, 0, 1, 1},
  {&__pyx_n_s_rstrip, __pyx_k_rstrip, sizeof(__pyx_k_rstrip), 0, 0, 1, 1},
  {&__pyx_n_b_script, __pyx_k_script, sizeof(__pyx_k_script), 0, 0, 0, 1},
  {&__pyx_n_b_search, __pyx_k_search, sizeof(__pyx_k_search), 0, 0, 0, 1},
  {&__pyx_n_b_searchbox, __pyx_k_searchbox, sizeof(__pyx_k_searchbox), 0, 0, 0, 1},
  {&__pyx_n_b_select, __pyx_k_select, sizeof(__pyx_k_select), 0, 0, 0, 1},
  {&__pyx_n_s_selector_list, __pyx_k_selector_list, sizeof(__pyx_k_selector_list), 0, 0, 1, 1},
  {&__pyx_n_s_selectors, __pyx_k_selectors, sizeof(__pyx_k_selectors), 0, 0, 1, 1},
  {&__pyx_n_b_separator, __pyx_k_separator, sizeof(__pyx_k_separator), 0, 0, 0, 1},
  {&__pyx_n_s_skip, __pyx_k_skip, sizeof(__pyx_k_skip), 0, 0, 1, 1},
  {&__pyx_n_s_skip_elements, __pyx_k_skip_elements, sizeof(__pyx_k_skip_elements), 0, 0, 1, 1},
  {&__pyx_n_s_skip_selectors, __pyx_k_skip_selectors, sizeof(__pyx_k_skip_selectors), 0, 0, 1, 1},
  {&__pyx_n_b_style, __pyx_k_style, sizeof(__pyx_k_style), 0, 0, 0, 1},
  {&__pyx_n_b_svg, __pyx_k_svg, sizeof(__pyx_k_svg), 0, 0, 0, 1},
  {&__pyx_n_b_tab, __pyx_k_tab, sizeof(__pyx_k_tab), 0, 0, 0, 1},
  {&__pyx_n_s_tag_name, __pyx_k_tag_name, sizeof(__pyx_k_tag_name), 0, 0, 1, 1},
  {&__pyx_n_s_tag_name_len, __pyx_k_tag_name_len, sizeof(__pyx_k_tag_name_len), 0, 0, 1, 1},
  {&__pyx_n_s_tag_name_str, __pyx_k_tag_name_str, sizeof(__pyx_k_tag_name_str), 0, 0, 1, 1},
  {&__pyx_n_b_template, __pyx_k_template, sizeof(__pyx_k_template), 0, 0, 0, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_b_textarea, __pyx_k_textarea, sizeof(__pyx_k_textarea), 0, 0, 0, 1},
  {&__pyx_n_b_toolbar, __pyx_k_toolbar, sizeof(__pyx_k_toolbar), 0, 0, 0, 1},
  {&__pyx_n_b_tooltip, __pyx_k_tooltip, sizeof(__pyx_k_tooltip), 0, 0, 0, 1},
  {&__pyx_n_s_tree, __pyx_k_tree, sizeof(__pyx_k_tree), 0, 0, 1, 1},
  {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
  {&__pyx_n_b_video, __pyx_k_video, sizeof(__pyx_k_video), 0, 0, 0, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 99, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "resiliparse/extract/html2text.pyx":583
 * 
 * 
 * def extract_plain_text(HTMLTree tree, bint preserve_formatting=True, bint main_content=False,             # <<<<<<<<<<<<<<
 *                        bint list_bullets=True,  bint alt_texts=True, bint links=False, bint form_fields=False,
 *                        bint noscript=False, bint comments=True, skip_elements=None):
 */
  __pyx_tuple__3 = PyTuple_Pack(29, __pyx_n_s_tree, __pyx_n_s_preserve_formatting, __pyx_n_s_main_content, __pyx_n_s_list_bullets, __pyx_n_s_alt_texts, __pyx_n_s_links, __pyx_n_s_form_fields, __pyx_n_s_noscript, __pyx_n_s_comments, __pyx_n_s_skip_elements, __pyx_n_s_skip_selectors, __pyx_n_s_ctx, __pyx_n_s_tag_name, __pyx_n_s_tag_name_len, __pyx_n_s_tag_name_str, __pyx_n_s_i, __pyx_n_s_skip, __pyx_n_s_is_end_tag, __pyx_n_s_css_parser, __pyx_n_s_css_selectors, __pyx_n_s_selectors, __pyx_n_s_selector_list, __pyx_n_s_preselected_nodes, __pyx_n_s_main_content_selector, __pyx_n_s_combined_skip_sel, __pyx_n_s_base_depth, __pyx_n_s_pnode, __pyx_n_s_extract_nodes, __pyx_n_s_e); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 583, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);
  __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(10, 0, 29, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_resiliparse_extract_html2text_py, __pyx_n_s_extract_plain_text, 583, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 583, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
  __pyx_umethod_PySet_Type_update.type = (PyObject*)&PySet_Type;
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/

static int __Pyx_modinit_global_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  /*--- Global init code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_variable_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  /*--- Variable export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  /*--- Function export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_type_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  /*--- Type init code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_type_import_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  /*--- Type import code ---*/
  __pyx_t_1 = PyImport_ImportModule("resiliparse.parse.html"); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_11resiliparse_5parse_4html_DOMElementClassList = __Pyx_ImportType(__pyx_t_1, "resiliparse.parse.html", "DOMElementClassList", sizeof(struct __pyx_obj_11resiliparse_5parse_4html_DOMElementClassList), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_11resiliparse_5parse_4html_DOMElementClassList) __PYX_ERR(3, 75, __pyx_L1_error)
  __pyx_vtabptr_11resiliparse_5parse_4html_DOMElementClassList = (struct __pyx_vtabstruct_11resiliparse_5parse_4html_DOMElementClassList*)__Pyx_GetVtable(__pyx_ptype_11resiliparse_5parse_4html_DOMElementClassList->tp_dict); if (unlikely(!__pyx_vtabptr_11resiliparse_5parse_4html_DOMElementClassList)) __PYX_ERR(3, 75, __pyx_L1_error)
  __pyx_ptype_11resiliparse_5parse_4html_DOMNode = __Pyx_ImportType(__pyx_t_1, "resiliparse.parse.html", "DOMNode", sizeof(struct __pyx_obj_11resiliparse_5parse_4html_DOMNode), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_11resiliparse_5parse_4html_DOMNode) __PYX_ERR(3, 84, __pyx_L1_error)
  __pyx_vtabptr_11resiliparse_5parse_4html_DOMNode = (struct __pyx_vtabstruct_11resiliparse_5parse_4html_DOMNode*)__Pyx_GetVtable(__pyx_ptype_11resiliparse_5parse_4html_DOMNode->tp_dict); if (unlikely(!__pyx_vtabptr_11resiliparse_5parse_4html_DOMNode)) __PYX_ERR(3, 84, __pyx_L1_error)
  __pyx_ptype_11resiliparse_5parse_4html_DOMCollection = __Pyx_ImportType(__pyx_t_1, "resiliparse.parse.html", "DOMCollection", sizeof(struct __pyx_obj_11resiliparse_5parse_4html_DOMCollection), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_11resiliparse_5parse_4html_DOMCollection) __PYX_ERR(3, 113, __pyx_L1_error)
  __pyx_vtabptr_11resiliparse_5parse_4html_DOMCollection = (struct __pyx_vtabstruct_11resiliparse_5parse_4html_DOMCollection*)__Pyx_GetVtable(__pyx_ptype_11resiliparse_5parse_4html_DOMCollection->tp_dict); if (unlikely(!__pyx_vtabptr_11resiliparse_5parse_4html_DOMCollection)) __PYX_ERR(3, 113, __pyx_L1_error)
  __pyx_ptype_11resiliparse_5parse_4html_HTMLTree = __Pyx_ImportType(__pyx_t_1, "resiliparse.parse.html", "HTMLTree", sizeof(struct __pyx_obj_11resiliparse_5parse_4html_HTMLTree), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_11resiliparse_5parse_4html_HTMLTree) __PYX_ERR(3, 149, __pyx_L1_error)
  __pyx_vtabptr_11resiliparse_5parse_4html_HTMLTree = (struct __pyx_vtabstruct_11resiliparse_5parse_4html_HTMLTree*)__Pyx_GetVtable(__pyx_ptype_11resiliparse_5parse_4html_HTMLTree->tp_dict); if (unlikely(!__pyx_vtabptr_11resiliparse_5parse_4html_HTMLTree)) __PYX_ERR(3, 149, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_variable_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  /*--- Variable import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_import_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  /*--- Function import code ---*/
  __pyx_t_1 = PyImport_ImportModule("resiliparse.parse.html"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_ImportFunction(__pyx_t_1, "init_css_parser", (void (**)(void))&__pyx_f_11resiliparse_5parse_4html_init_css_parser, "int (lxb_css_parser_t **)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "destroy_css_parser", (void (**)(void))&__pyx_f_11resiliparse_5parse_4html_destroy_css_parser, "void (lxb_css_parser_t *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "init_css_selectors", (void (**)(void))&__pyx_f_11resiliparse_5parse_4html_init_css_selectors, "int (lxb_css_parser_t *, lxb_css_selectors_t **, lxb_selectors_t **)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "destroy_css_selectors", (void (**)(void))&__pyx_f_11resiliparse_5parse_4html_destroy_css_selectors, "void (lxb_css_selectors_t *, lxb_selectors_t *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "parse_css_selectors", (void (**)(void))&__pyx_f_11resiliparse_5parse_4html_parse_css_selectors, "lxb_css_selector_list_t *(lxb_css_parser_t *, lxb_char_t const *, size_t)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "next_node", (void (**)(void))&__pyx_f_11resiliparse_5parse_4html_next_node, "lxb_dom_node_t *(lxb_dom_node_t const *, lxb_dom_node_t *, struct __pyx_opt_args_11resiliparse_5parse_4html_next_node *__pyx_optional_args)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "get_node_text", (void (**)(void))&__pyx_f_11resiliparse_5parse_4html_get_node_text, "std::string (lxb_dom_node_t *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_ImportFunction(__pyx_t_1, "is_block_element", (void (**)(void))&__pyx_f_11resiliparse_5parse_4html_is_block_element, "int (lxb_tag_id_t)") < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_RefNannyFinishContext();
  return -1;
}


#ifndef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#elif PY_MAJOR_VERSION < 3
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" void
#else
#define __Pyx_PyMODINIT_FUNC void
#endif
#else
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
#else
#define __Pyx_PyMODINIT_FUNC PyObject *
#endif
#endif


#if PY_MAJOR_VERSION < 3
__Pyx_PyMODINIT_FUNC inithtml2text(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC inithtml2text(void)
#else
__Pyx_PyMODINIT_FUNC PyInit_html2text(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit_html2text(void)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
  return PyModuleDef_Init(&__pyx_moduledef);
}
static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
    #if PY_VERSION_HEX >= 0x030700A1
    static PY_INT64_T main_interpreter_id = -1;
    PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
    if (main_interpreter_id == -1) {
        main_interpreter_id = current_id;
        return (unlikely(current_id == -1)) ? -1 : 0;
    } else if (unlikely(main_interpreter_id != current_id))
    #else
    static PyInterpreterState *main_interpreter = NULL;
    PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
    if (!main_interpreter) {
        main_interpreter = current_interpreter;
    } else if (unlikely(main_interpreter != current_interpreter))
    #endif
    {
        PyErr_SetString(
            PyExc_ImportError,
            "Interpreter change detected - this module can only be loaded into one interpreter per process.");
        return -1;
    }
    return 0;
}
static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
    PyObject *value = PyObject_GetAttrString(spec, from_name);
    int result = 0;
    if (likely(value)) {
        if (allow_none || value != Py_None) {
            result = PyDict_SetItemString(moddict, to_name, value);
        }
        Py_DECREF(value);
    } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Clear();
    } else {
        result = -1;
    }
    return result;
}
static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
    PyObject *module = NULL, *moddict, *modname;
    if (__Pyx_check_single_interpreter())
        return NULL;
    if (__pyx_m)
        return __Pyx_NewRef(__pyx_m);
    modname = PyObject_GetAttrString(spec, "name");
    if (unlikely(!modname)) goto bad;
    module = PyModule_NewObject(modname);
    Py_DECREF(modname);
    if (unlikely(!module)) goto bad;
    moddict = PyModule_GetDict(module);
    if (unlikely(!moddict)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
    return module;
bad:
    Py_XDECREF(module);
    return NULL;
}


static CYTHON_SMALL_CODE int __pyx_pymod_exec_html2text(PyObject *__pyx_pyinit_module)
#endif
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  std::set<std::string>  __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  if (__pyx_m) {
    if (__pyx_m == __pyx_pyinit_module) return 0;
    PyErr_SetString(PyExc_RuntimeError, "Module 'html2text' has already been imported. Re-initialisation is not supported.");
    return -1;
  }
  #elif PY_MAJOR_VERSION >= 3
  if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  #endif
  #if CYTHON_REFNANNY
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
if (!__Pyx_RefNanny) {
  PyErr_Clear();
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  if (!__Pyx_RefNanny)
      Py_FatalError("failed to import 'refnanny' module");
}
#endif
  __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_html2text(void)", 0);
  if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pxy_PyFrame_Initialize_Offsets
  __Pxy_PyFrame_Initialize_Offsets();
  #endif
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_AsyncGen_USED
  if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  PyEval_InitThreads();
  #endif
  /*--- Module creation code ---*/
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  __pyx_m = __pyx_pyinit_module;
  Py_INCREF(__pyx_m);
  #else
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("html2text", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_b);
  __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_cython_runtime);
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  if (__pyx_module_is_main_resiliparse__extract__html2text) {
    if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
    if (!PyDict_GetItemString(modules, "resiliparse.extract.html2text")) {
      if (unlikely(PyDict_SetItemString(modules, "resiliparse.extract.html2text", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Global type/function init code ---*/
  (void)__Pyx_modinit_global_init_code();
  (void)__Pyx_modinit_variable_export_code();
  (void)__Pyx_modinit_function_export_code();
  (void)__Pyx_modinit_type_init_code();
  if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  (void)__Pyx_modinit_variable_import_code();
  if (unlikely(__Pyx_modinit_function_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif

  /* "resiliparse/extract/html2text.pyx":25
 * from libcpp.vector cimport vector
 * 
 * from resiliparse.parse.encoding import bytes_to_str             # <<<<<<<<<<<<<<
 * from resiliparse_common.string_util cimport rstrip_str, strip_str
 * from resiliparse_inc.cctype cimport isspace
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_bytes_to_str);
  __Pyx_GIVEREF(__pyx_n_s_bytes_to_str);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_bytes_to_str);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_resiliparse_parse_encoding, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_bytes_to_str); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_bytes_to_str, __pyx_t_1) < 0) __PYX_ERR(0, 25, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "resiliparse/extract/html2text.pyx":109
 * 
 * 
 * cdef string LIST_BULLET = <const char*>b'\xe2\x80\xa2'             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_11resiliparse_7extract_9html2text_LIST_BULLET = ((char const *)((char const *)"\342\200\242"));

  /* "resiliparse/extract/html2text.pyx":316
 * 
 * cdef RE2Options re_opts
 * re_opts.set_case_sensitive(False)             # <<<<<<<<<<<<<<
 * 
 * cdef RE2 article_cls_regex = RE2(rb'(?:^|[\s_-])(?:article|entry|post|story|single[_-]?post|main[_-]content)(?:content|body|text|page)?(?:$|[\s_-])', re_opts)
 */
  __pyx_v_11resiliparse_7extract_9html2text_re_opts.set_case_sensitive(0);

  /* "resiliparse/extract/html2text.pyx":318
 * re_opts.set_case_sensitive(False)
 * 
 * cdef RE2 article_cls_regex = RE2(rb'(?:^|[\s_-])(?:article|entry|post|story|single[_-]?post|main[_-]content)(?:content|body|text|page)?(?:$|[\s_-])', re_opts)             # <<<<<<<<<<<<<<
 * cdef RE2 nav_cls_regex = RE2(rb'(?:^|\s)(?:(?:l|m|wp|main|site|page|sub|article|global|sticky|main)[_-]*)?(?:nav(?:igation)?|menu(?:[_-]item)?|drop[_-]?down|bread[_-]?crumbs?)|(?:links?[_-]?(?:bar|box|list|container|section|wrapp(?:er))?)(?:$|[\s_-])', re_opts)
 * cdef RE2 recommended_cls_regex = RE2(rb'(?:^|[\s_-])(?:trends|trending|recommended|featured|popular|editors?[_-]picks|related|read-next|(?:related|more|other)[_-]?(?:links|articles|posts|guides|stories))(?:$|[\s_-])', re_opts)
 */
  __pyx_v_11resiliparse_7extract_9html2text_article_cls_regex = RE2Stack(((char const *)"(?:^|[\\s_-])(?:article|entry|post|story|single[_-]?post|main[_-]content)(?:content|body|text|page)?(?:$|[\\s_-])"), __pyx_v_11resiliparse_7extract_9html2text_re_opts);

  /* "resiliparse/extract/html2text.pyx":319
 * 
 * cdef RE2 article_cls_regex = RE2(rb'(?:^|[\s_-])(?:article|entry|post|story|single[_-]?post|main[_-]content)(?:content|body|text|page)?(?:$|[\s_-])', re_opts)
 * cdef RE2 nav_cls_regex = RE2(rb'(?:^|\s)(?:(?:l|m|wp|main|site|page|sub|article|global|sticky|main)[_-]*)?(?:nav(?:igation)?|menu(?:[_-]item)?|drop[_-]?down|bread[_-]?crumbs?)|(?:links?[_-]?(?:bar|box|list|container|section|wrapp(?:er))?)(?:$|[\s_-])', re_opts)             # <<<<<<<<<<<<<<
 * cdef RE2 recommended_cls_regex = RE2(rb'(?:^|[\s_-])(?:trends|trending|recommended|featured|popular|editors?[_-]picks|related|read-next|(?:related|more|other)[_-]?(?:links|articles|posts|guides|stories))(?:$|[\s_-])', re_opts)
 * cdef RE2 landmark_id_regex = RE2(rb'^(?:(?:l|wp|global|page|site|full|sticky)[_-]*)?(?:(?:head|foot)(?:er)?|right)$', re_opts)
 */
  __pyx_v_11resiliparse_7extract_9html2text_nav_cls_regex = RE2Stack(((char const *)"(?:^|\\s)(?:(?:l|m|wp|main|site|page|sub|article|global|sticky|main)[_-]*)?(?:nav(?:igation)?|menu(?:[_-]item)?|drop[_-]?down|bread[_-]?crumbs?)|(?:links?[_-]?(?:bar|box|list|container|section|wrapp(?:er))?)(?:$|[\\s_-])"), __pyx_v_11resiliparse_7extract_9html2text_re_opts);

  /* "resiliparse/extract/html2text.pyx":320
 * cdef RE2 article_cls_regex = RE2(rb'(?:^|[\s_-])(?:article|entry|post|story|single[_-]?post|main[_-]content)(?:content|body|text|page)?(?:$|[\s_-])', re_opts)
 * cdef RE2 nav_cls_regex = RE2(rb'(?:^|\s)(?:(?:l|m|wp|main|site|page|sub|article|global|sticky|main)[_-]*)?(?:nav(?:igation)?|menu(?:[_-]item)?|drop[_-]?down|bread[_-]?crumbs?)|(?:links?[_-]?(?:bar|box|list|container|section|wrapp(?:er))?)(?:$|[\s_-])', re_opts)
 * cdef RE2 recommended_cls_regex = RE2(rb'(?:^|[\s_-])(?:trends|trending|recommended|featured|popular|editors?[_-]picks|related|read-next|(?:related|more|other)[_-]?(?:links|articles|posts|guides|stories))(?:$|[\s_-])', re_opts)             # <<<<<<<<<<<<<<
 * cdef RE2 landmark_id_regex = RE2(rb'^(?:(?:l|wp|global|page|site|full|sticky)[_-]*)?(?:(?:head|foot)(?:er)?|right)$', re_opts)
 * cdef RE2 header_cls_regex = RE2(rb'(?:^|\s)(?:l|m|wp|global|page|site|full|sticky)[_-]*header(?:[_-]?wrap(?:per)?|bar)?(?:$|\s)', re_opts)
 */
  __pyx_v_11resiliparse_7extract_9html2text_recommended_cls_regex = RE2Stack(((char const *)"(?:^|[\\s_-])(?:trends|trending|recommended|featured|popular|editors?[_-]picks|related|read-next|(?:related|more|other)[_-]?(?:links|articles|posts|guides|stories))(?:$|[\\s_-])"), __pyx_v_11resiliparse_7extract_9html2text_re_opts);

  /* "resiliparse/extract/html2text.pyx":321
 * cdef RE2 nav_cls_regex = RE2(rb'(?:^|\s)(?:(?:l|m|wp|main|site|page|sub|article|global|sticky|main)[_-]*)?(?:nav(?:igation)?|menu(?:[_-]item)?|drop[_-]?down|bread[_-]?crumbs?)|(?:links?[_-]?(?:bar|box|list|container|section|wrapp(?:er))?)(?:$|[\s_-])', re_opts)
 * cdef RE2 recommended_cls_regex = RE2(rb'(?:^|[\s_-])(?:trends|trending|recommended|featured|popular|editors?[_-]picks|related|read-next|(?:related|more|other)[_-]?(?:links|articles|posts|guides|stories))(?:$|[\s_-])', re_opts)
 * cdef RE2 landmark_id_regex = RE2(rb'^(?:(?:l|wp|global|page|site|full|sticky)[_-]*)?(?:(?:head|foot)(?:er)?|right)$', re_opts)             # <<<<<<<<<<<<<<
 * cdef RE2 header_cls_regex = RE2(rb'(?:^|\s)(?:l|m|wp|global|page|site|full|sticky)[_-]*header(?:[_-]?wrap(?:per)?|bar)?(?:$|\s)', re_opts)
 * cdef RE2 footer_cls_regex = RE2(rb'(?:^|[\s_-])(?:global|page|site|copyright)?(?:footer|copyright|cookie|consent|legal|fcontainer)(?:$|[\s_-])', re_opts)
 */
  __pyx_v_11resiliparse_7extract_9html2text_landmark_id_regex = RE2Stack(((char const *)"^(?:(?:l|wp|global|page|site|full|sticky)[_-]*)?(?:(?:head|foot)(?:er)?|right)$"), __pyx_v_11resiliparse_7extract_9html2text_re_opts);

  /* "resiliparse/extract/html2text.pyx":322
 * cdef RE2 recommended_cls_regex = RE2(rb'(?:^|[\s_-])(?:trends|trending|recommended|featured|popular|editors?[_-]picks|related|read-next|(?:related|more|other)[_-]?(?:links|articles|posts|guides|stories))(?:$|[\s_-])', re_opts)
 * cdef RE2 landmark_id_regex = RE2(rb'^(?:(?:l|wp|global|page|site|full|sticky)[_-]*)?(?:(?:head|foot)(?:er)?|right)$', re_opts)
 * cdef RE2 header_cls_regex = RE2(rb'(?:^|\s)(?:l|m|wp|global|page|site|full|sticky)[_-]*header(?:[_-]?wrap(?:per)?|bar)?(?:$|\s)', re_opts)             # <<<<<<<<<<<<<<
 * cdef RE2 footer_cls_regex = RE2(rb'(?:^|[\s_-])(?:global|page|site|copyright)?(?:footer|copyright|cookie|consent|legal|fcontainer)(?:$|[\s_-])', re_opts)
 * cdef RE2 post_meta_cls_regex = RE2(rb'(?:^|[\s_-])(?:(?:post|entry|article(?:page)?|content|story|section)[_-]*(?:text[_-]*)?(?:footer|teaser|meta(?:[_-]?data)?|subline|sidebar|author(?:name)?|published|timestamp|date|posted[_-]?on|info|labels?|tags?|keywords|category)|by[_-]?line|date[_-]?line|author-date|submitted(?:-by)?)|meta[_-]?data(?:$|[\s_-])', re_opts)
 */
  __pyx_v_11resiliparse_7extract_9html2text_header_cls_regex = RE2Stack(((char const *)"(?:^|\\s)(?:l|m|wp|global|page|site|full|sticky)[_-]*header(?:[_-]?wrap(?:per)?|bar)?(?:$|\\s)"), __pyx_v_11resiliparse_7extract_9html2text_re_opts);

  /* "resiliparse/extract/html2text.pyx":323
 * cdef RE2 landmark_id_regex = RE2(rb'^(?:(?:l|wp|global|page|site|full|sticky)[_-]*)?(?:(?:head|foot)(?:er)?|right)$', re_opts)
 * cdef RE2 header_cls_regex = RE2(rb'(?:^|\s)(?:l|m|wp|global|page|site|full|sticky)[_-]*header(?:[_-]?wrap(?:per)?|bar)?(?:$|\s)', re_opts)
 * cdef RE2 footer_cls_regex = RE2(rb'(?:^|[\s_-])(?:global|page|site|copyright)?(?:footer|copyright|cookie|consent|legal|fcontainer)(?:$|[\s_-])', re_opts)             # <<<<<<<<<<<<<<
 * cdef RE2 post_meta_cls_regex = RE2(rb'(?:^|[\s_-])(?:(?:post|entry|article(?:page)?|content|story|section)[_-]*(?:text[_-]*)?(?:footer|teaser|meta(?:[_-]?data)?|subline|sidebar|author(?:name)?|published|timestamp|date|posted[_-]?on|info|labels?|tags?|keywords|category)|by[_-]?line|date[_-]?line|author-date|submitted(?:-by)?)|meta[_-]?data(?:$|[\s_-])', re_opts)
 * cdef RE2 sidebar_cls_regex = RE2(rb'(?:^|\s)(?:(?:l|wp|right|left|global|sticky)[_-]*)?(?:(?:side|sticky)[_-]?(?:bars?|box)|one-third)(?:$|[\s_-])', re_opts)
 */
  __pyx_v_11resiliparse_7extract_9html2text_footer_cls_regex = RE2Stack(((char const *)"(?:^|[\\s_-])(?:global|page|site|copyright)?(?:footer|copyright|cookie|consent|legal|fcontainer)(?:$|[\\s_-])"), __pyx_v_11resiliparse_7extract_9html2text_re_opts);

  /* "resiliparse/extract/html2text.pyx":324
 * cdef RE2 header_cls_regex = RE2(rb'(?:^|\s)(?:l|m|wp|global|page|site|full|sticky)[_-]*header(?:[_-]?wrap(?:per)?|bar)?(?:$|\s)', re_opts)
 * cdef RE2 footer_cls_regex = RE2(rb'(?:^|[\s_-])(?:global|page|site|copyright)?(?:footer|copyright|cookie|consent|legal|fcontainer)(?:$|[\s_-])', re_opts)
 * cdef RE2 post_meta_cls_regex = RE2(rb'(?:^|[\s_-])(?:(?:post|entry|article(?:page)?|content|story|section)[_-]*(?:text[_-]*)?(?:footer|teaser|meta(?:[_-]?data)?|subline|sidebar|author(?:name)?|published|timestamp|date|posted[_-]?on|info|labels?|tags?|keywords|category)|by[_-]?line|date[_-]?line|author-date|submitted(?:-by)?)|meta[_-]?data(?:$|[\s_-])', re_opts)             # <<<<<<<<<<<<<<
 * cdef RE2 sidebar_cls_regex = RE2(rb'(?:^|\s)(?:(?:l|wp|right|left|global|sticky)[_-]*)?(?:(?:side|sticky)[_-]?(?:bars?|box)|one-third)(?:$|[\s_-])', re_opts)
 * cdef RE2 search_cls_regex = RE2(rb'(?:^|[\s_-])search(?:[_-]?(?:bar|facility|box))?(?:$|\s)', re_opts)
 */
  __pyx_v_11resiliparse_7extract_9html2text_post_meta_cls_regex = RE2Stack(((char const *)"(?:^|[\\s_-])(?:(?:post|entry|article(?:page)?|content|story|section)[_-]*(?:text[_-]*)?(?:footer|teaser|meta(?:[_-]?data)?|subline|sidebar|author(?:name)?|published|timestamp|date|posted[_-]?on|info|labels?|tags?|keywords|category)|by[_-]?line|date[_-]?line|author-date|submitted(?:-by)?)|meta[_-]?data(?:$|[\\s_-])"), __pyx_v_11resiliparse_7extract_9html2text_re_opts);

  /* "resiliparse/extract/html2text.pyx":325
 * cdef RE2 footer_cls_regex = RE2(rb'(?:^|[\s_-])(?:global|page|site|copyright)?(?:footer|copyright|cookie|consent|legal|fcontainer)(?:$|[\s_-])', re_opts)
 * cdef RE2 post_meta_cls_regex = RE2(rb'(?:^|[\s_-])(?:(?:post|entry|article(?:page)?|content|story|section)[_-]*(?:text[_-]*)?(?:footer|teaser|meta(?:[_-]?data)?|subline|sidebar|author(?:name)?|published|timestamp|date|posted[_-]?on|info|labels?|tags?|keywords|category)|by[_-]?line|date[_-]?line|author-date|submitted(?:-by)?)|meta[_-]?data(?:$|[\s_-])', re_opts)
 * cdef RE2 sidebar_cls_regex = RE2(rb'(?:^|\s)(?:(?:l|wp|right|left|global|sticky)[_-]*)?(?:(?:side|sticky)[_-]?(?:bars?|box)|one-third)(?:$|[\s_-])', re_opts)             # <<<<<<<<<<<<<<
 * cdef RE2 search_cls_regex = RE2(rb'(?:^|[\s_-])search(?:[_-]?(?:bar|facility|box))?(?:$|\s)', re_opts)
 * cdef RE2 skip_link_cls_regex = RE2(rb'(?:^|\s)(?:link[_-]?)?(?:skip(?:[_-]?(?:to|link))?|scroll[_-]?(?:up|down)|next|prev(?:ious)?|permalink|pagination)(?:$|\s|[_-]?(?:post|article))', re_opts)
 */
  __pyx_v_11resiliparse_7extract_9html2text_sidebar_cls_regex = RE2Stack(((char const *)"(?:^|\\s)(?:(?:l|wp|right|left|global|sticky)[_-]*)?(?:(?:side|sticky)[_-]?(?:bars?|box)|one-third)(?:$|[\\s_-])"), __pyx_v_11resiliparse_7extract_9html2text_re_opts);

  /* "resiliparse/extract/html2text.pyx":326
 * cdef RE2 post_meta_cls_regex = RE2(rb'(?:^|[\s_-])(?:(?:post|entry|article(?:page)?|content|story|section)[_-]*(?:text[_-]*)?(?:footer|teaser|meta(?:[_-]?data)?|subline|sidebar|author(?:name)?|published|timestamp|date|posted[_-]?on|info|labels?|tags?|keywords|category)|by[_-]?line|date[_-]?line|author-date|submitted(?:-by)?)|meta[_-]?data(?:$|[\s_-])', re_opts)
 * cdef RE2 sidebar_cls_regex = RE2(rb'(?:^|\s)(?:(?:l|wp|right|left|global|sticky)[_-]*)?(?:(?:side|sticky)[_-]?(?:bars?|box)|one-third)(?:$|[\s_-])', re_opts)
 * cdef RE2 search_cls_regex = RE2(rb'(?:^|[\s_-])search(?:[_-]?(?:bar|facility|box))?(?:$|\s)', re_opts)             # <<<<<<<<<<<<<<
 * cdef RE2 skip_link_cls_regex = RE2(rb'(?:^|\s)(?:link[_-]?)?(?:skip(?:[_-]?(?:to|link))?|scroll[_-]?(?:up|down)|next|prev(?:ious)?|permalink|pagination)(?:$|\s|[_-]?(?:post|article))', re_opts)
 * cdef RE2 display_cls_regex = RE2(rb'(?:^|\s)(?:is[_-])?(?:display-none|hidden|invisible|collapsed|h-0|nocontent|expandable)(?:-xs|-sm|-lg|-2?xl)?(?:$|\s)', re_opts)
 */
  __pyx_v_11resiliparse_7extract_9html2text_search_cls_regex = RE2Stack(((char const *)"(?:^|[\\s_-])search(?:[_-]?(?:bar|facility|box))?(?:$|\\s)"), __pyx_v_11resiliparse_7extract_9html2text_re_opts);

  /* "resiliparse/extract/html2text.pyx":327
 * cdef RE2 sidebar_cls_regex = RE2(rb'(?:^|\s)(?:(?:l|wp|right|left|global|sticky)[_-]*)?(?:(?:side|sticky)[_-]?(?:bars?|box)|one-third)(?:$|[\s_-])', re_opts)
 * cdef RE2 search_cls_regex = RE2(rb'(?:^|[\s_-])search(?:[_-]?(?:bar|facility|box))?(?:$|\s)', re_opts)
 * cdef RE2 skip_link_cls_regex = RE2(rb'(?:^|\s)(?:link[_-]?)?(?:skip(?:[_-]?(?:to|link))?|scroll[_-]?(?:up|down)|next|prev(?:ious)?|permalink|pagination)(?:$|\s|[_-]?(?:post|article))', re_opts)             # <<<<<<<<<<<<<<
 * cdef RE2 display_cls_regex = RE2(rb'(?:^|\s)(?:is[_-])?(?:display-none|hidden|invisible|collapsed|h-0|nocontent|expandable)(?:-xs|-sm|-lg|-2?xl)?(?:$|\s)', re_opts)
 * cdef RE2 display_css_regex = RE2(rb'(?:^|;\s*)(?:display\s?:\s?none|visibility\s?:\s?hidden)(?:$|\s?;)', re_opts)
 */
  __pyx_v_11resiliparse_7extract_9html2text_skip_link_cls_regex = RE2Stack(((char const *)"(?:^|\\s)(?:link[_-]?)?(?:skip(?:[_-]?(?:to|link))?|scroll[_-]?(?:up|down)|next|prev(?:ious)?|permalink|pagination)(?:$|\\s|[_-]?(?:post|article))"), __pyx_v_11resiliparse_7extract_9html2text_re_opts);

  /* "resiliparse/extract/html2text.pyx":328
 * cdef RE2 search_cls_regex = RE2(rb'(?:^|[\s_-])search(?:[_-]?(?:bar|facility|box))?(?:$|\s)', re_opts)
 * cdef RE2 skip_link_cls_regex = RE2(rb'(?:^|\s)(?:link[_-]?)?(?:skip(?:[_-]?(?:to|link))?|scroll[_-]?(?:up|down)|next|prev(?:ious)?|permalink|pagination)(?:$|\s|[_-]?(?:post|article))', re_opts)
 * cdef RE2 display_cls_regex = RE2(rb'(?:^|\s)(?:is[_-])?(?:display-none|hidden|invisible|collapsed|h-0|nocontent|expandable)(?:-xs|-sm|-lg|-2?xl)?(?:$|\s)', re_opts)             # <<<<<<<<<<<<<<
 * cdef RE2 display_css_regex = RE2(rb'(?:^|;\s*)(?:display\s?:\s?none|visibility\s?:\s?hidden)(?:$|\s?;)', re_opts)
 * cdef RE2 modal_cls_regex = RE2(rb'(?:^|\s)(?:wp-|p-|-l)?(?:modal|popup|lightbox)(?:[_-]*(?:window|pane|box))?(?:$|[\s_-])', re_opts)
 */
  __pyx_v_11resiliparse_7extract_9html2text_display_cls_regex = RE2Stack(((char const *)"(?:^|\\s)(?:is[_-])?(?:display-none|hidden|invisible|collapsed|h-0|nocontent|expandable)(?:-xs|-sm|-lg|-2?xl)?(?:$|\\s)"), __pyx_v_11resiliparse_7extract_9html2text_re_opts);

  /* "resiliparse/extract/html2text.pyx":329
 * cdef RE2 skip_link_cls_regex = RE2(rb'(?:^|\s)(?:link[_-]?)?(?:skip(?:[_-]?(?:to|link))?|scroll[_-]?(?:up|down)|next|prev(?:ious)?|permalink|pagination)(?:$|\s|[_-]?(?:post|article))', re_opts)
 * cdef RE2 display_cls_regex = RE2(rb'(?:^|\s)(?:is[_-])?(?:display-none|hidden|invisible|collapsed|h-0|nocontent|expandable)(?:-xs|-sm|-lg|-2?xl)?(?:$|\s)', re_opts)
 * cdef RE2 display_css_regex = RE2(rb'(?:^|;\s*)(?:display\s?:\s?none|visibility\s?:\s?hidden)(?:$|\s?;)', re_opts)             # <<<<<<<<<<<<<<
 * cdef RE2 modal_cls_regex = RE2(rb'(?:^|\s)(?:wp-|p-|-l)?(?:modal|popup|lightbox)(?:[_-]*(?:window|pane|box))?(?:$|[\s_-])', re_opts)
 * cdef RE2 gallery_cls_regex = RE2(rb'(?:^|[\s_-])(?:gallery|carousel)(?:$|[\s_-])', re_opts)
 */
  __pyx_v_11resiliparse_7extract_9html2text_display_css_regex = RE2Stack(((char const *)"(?:^|;\\s*)(?:display\\s?:\\s?none|visibility\\s?:\\s?hidden)(?:$|\\s?;)"), __pyx_v_11resiliparse_7extract_9html2text_re_opts);

  /* "resiliparse/extract/html2text.pyx":330
 * cdef RE2 display_cls_regex = RE2(rb'(?:^|\s)(?:is[_-])?(?:display-none|hidden|invisible|collapsed|h-0|nocontent|expandable)(?:-xs|-sm|-lg|-2?xl)?(?:$|\s)', re_opts)
 * cdef RE2 display_css_regex = RE2(rb'(?:^|;\s*)(?:display\s?:\s?none|visibility\s?:\s?hidden)(?:$|\s?;)', re_opts)
 * cdef RE2 modal_cls_regex = RE2(rb'(?:^|\s)(?:wp-|p-|-l)?(?:modal|popup|lightbox)(?:[_-]*(?:window|pane|box))?(?:$|[\s_-])', re_opts)             # <<<<<<<<<<<<<<
 * cdef RE2 gallery_cls_regex = RE2(rb'(?:^|[\s_-])(?:gallery|carousel)(?:$|[\s_-])', re_opts)
 * cdef RE2 signin_cls_regex = RE2(rb'(?:^|[\s_-])(?:(?:log[_-]?in|sign[_-]?(?:in|up)|account)|user[_-](?:info|profile|settings|actions))(?:$|[\s_-])', re_opts)
 */
  __pyx_v_11resiliparse_7extract_9html2text_modal_cls_regex = RE2Stack(((char const *)"(?:^|\\s)(?:wp-|p-|-l)?(?:modal|popup|lightbox)(?:[_-]*(?:window|pane|box))?(?:$|[\\s_-])"), __pyx_v_11resiliparse_7extract_9html2text_re_opts);

  /* "resiliparse/extract/html2text.pyx":331
 * cdef RE2 display_css_regex = RE2(rb'(?:^|;\s*)(?:display\s?:\s?none|visibility\s?:\s?hidden)(?:$|\s?;)', re_opts)
 * cdef RE2 modal_cls_regex = RE2(rb'(?:^|\s)(?:wp-|p-|-l)?(?:modal|popup|lightbox)(?:[_-]*(?:window|pane|box))?(?:$|[\s_-])', re_opts)
 * cdef RE2 gallery_cls_regex = RE2(rb'(?:^|[\s_-])(?:gallery|carousel)(?:$|[\s_-])', re_opts)             # <<<<<<<<<<<<<<
 * cdef RE2 signin_cls_regex = RE2(rb'(?:^|[\s_-])(?:(?:log[_-]?in|sign[_-]?(?:in|up)|account)|user[_-](?:info|profile|settings|actions))(?:$|[\s_-])', re_opts)
 * cdef RE2 ads_cls_regex = RE2(rb'(?:^|\s)(?:(?:google|wide)[_-]?ads?|ad(?:vert|vertise(?:ment|link)?|$|_[a-f0-9]+)|sponsor(?:ed)?|promoted|paid|(?:wide)?banner|donate)(?:$|[\s_-])', re_opts)
 */
  __pyx_v_11resiliparse_7extract_9html2text_gallery_cls_regex = RE2Stack(((char const *)"(?:^|[\\s_-])(?:gallery|carousel)(?:$|[\\s_-])"), __pyx_v_11resiliparse_7extract_9html2text_re_opts);

  /* "resiliparse/extract/html2text.pyx":332
 * cdef RE2 modal_cls_regex = RE2(rb'(?:^|\s)(?:wp-|p-|-l)?(?:modal|popup|lightbox)(?:[_-]*(?:window|pane|box))?(?:$|[\s_-])', re_opts)
 * cdef RE2 gallery_cls_regex = RE2(rb'(?:^|[\s_-])(?:gallery|carousel)(?:$|[\s_-])', re_opts)
 * cdef RE2 signin_cls_regex = RE2(rb'(?:^|[\s_-])(?:(?:log[_-]?in|sign[_-]?(?:in|up)|account)|user[_-](?:info|profile|settings|actions))(?:$|[\s_-])', re_opts)             # <<<<<<<<<<<<<<
 * cdef RE2 ads_cls_regex = RE2(rb'(?:^|\s)(?:(?:google|wide)[_-]?ads?|ad(?:vert|vertise(?:ment|link)?|$|_[a-f0-9]+)|sponsor(?:ed)?|promoted|paid|(?:wide)?banner|donate)(?:$|[\s_-])', re_opts)
 * cdef RE2 social_cls_regex = RE2(rb'(?:^|\s|__|--|mobile-|desktop-|l-|m-|c-)(?:social(?:media|search)?|share(?:daddy)?|syndication|newsletter|sharing|follow|email|likes?|(?:give[_-]?)?feedback|(?:brand[_-])?engagement|facebook|twitter|subscribe|wa|jp|aptf-follow)(?:[_-]?(?:post|links?|section|icons?|btn|buttons?|target))?(?:$|[\s_-])', re_opts)
 */
  __pyx_v_11resiliparse_7extract_9html2text_signin_cls_regex = RE2Stack(((char const *)"(?:^|[\\s_-])(?:(?:log[_-]?in|sign[_-]?(?:in|up)|account)|user[_-](?:info|profile|settings|actions))(?:$|[\\s_-])"), __pyx_v_11resiliparse_7extract_9html2text_re_opts);

  /* "resiliparse/extract/html2text.pyx":333
 * cdef RE2 gallery_cls_regex = RE2(rb'(?:^|[\s_-])(?:gallery|carousel)(?:$|[\s_-])', re_opts)
 * cdef RE2 signin_cls_regex = RE2(rb'(?:^|[\s_-])(?:(?:log[_-]?in|sign[_-]?(?:in|up)|account)|user[_-](?:info|profile|settings|actions))(?:$|[\s_-])', re_opts)
 * cdef RE2 ads_cls_regex = RE2(rb'(?:^|\s)(?:(?:google|wide)[_-]?ads?|ad(?:vert|vertise(?:ment|link)?|$|_[a-f0-9]+)|sponsor(?:ed)?|promoted|paid|(?:wide)?banner|donate)(?:$|[\s_-])', re_opts)             # <<<<<<<<<<<<<<
 * cdef RE2 social_cls_regex = RE2(rb'(?:^|\s|__|--|mobile-|desktop-|l-|m-|c-)(?:social(?:media|search)?|share(?:daddy)?|syndication|newsletter|sharing|follow|email|likes?|(?:give[_-]?)?feedback|(?:brand[_-])?engagement|facebook|twitter|subscribe|wa|jp|aptf-follow)(?:[_-]?(?:post|links?|section|icons?|btn|buttons?|target))?(?:$|[\s_-])', re_opts)
 * cdef RE2 comments_cls_regex = RE2(rb'(?:^|[\s_-])(?:(?:article|user|post)[_-]*)?(?:(?:no[_-]?)?comments?|comment[_-]?list|reply)(?:$|[\s_-])', re_opts)
 */
  __pyx_v_11resiliparse_7extract_9html2text_ads_cls_regex = RE2Stack(((char const *)"(?:^|\\s)(?:(?:google|wide)[_-]?ads?|ad(?:vert|vertise(?:ment|link)?|$|_[a-f0-9]+)|sponsor(?:ed)?|promoted|paid|(?:wide)?banner|donate)(?:$|[\\s_-])"), __pyx_v_11resiliparse_7extract_9html2text_re_opts);

  /* "resiliparse/extract/html2text.pyx":334
 * cdef RE2 signin_cls_regex = RE2(rb'(?:^|[\s_-])(?:(?:log[_-]?in|sign[_-]?(?:in|up)|account)|user[_-](?:info|profile|settings|actions))(?:$|[\s_-])', re_opts)
 * cdef RE2 ads_cls_regex = RE2(rb'(?:^|\s)(?:(?:google|wide)[_-]?ads?|ad(?:vert|vertise(?:ment|link)?|$|_[a-f0-9]+)|sponsor(?:ed)?|promoted|paid|(?:wide)?banner|donate)(?:$|[\s_-])', re_opts)
 * cdef RE2 social_cls_regex = RE2(rb'(?:^|\s|__|--|mobile-|desktop-|l-|m-|c-)(?:social(?:media|search)?|share(?:daddy)?|syndication|newsletter|sharing|follow|email|likes?|(?:give[_-]?)?feedback|(?:brand[_-])?engagement|facebook|twitter|subscribe|wa|jp|aptf-follow)(?:[_-]?(?:post|links?|section|icons?|btn|buttons?|target))?(?:$|[\s_-])', re_opts)             # <<<<<<<<<<<<<<
 * cdef RE2 comments_cls_regex = RE2(rb'(?:^|[\s_-])(?:(?:article|user|post)[_-]*)?(?:(?:no[_-]?)?comments?|comment[_-]?list|reply)(?:$|[\s_-])', re_opts)
 * cdef RE2 logo_cls_regex = RE2(rb'(?:brand(?:ing)?[_-]*)?logo(?:$|\s)', re_opts)
 */
  __pyx_v_11resiliparse_7extract_9html2text_social_cls_regex = RE2Stack(((char const *)"(?:^|\\s|__|--|mobile-|desktop-|l-|m-|c-)(?:social(?:media|search)?|share(?:daddy)?|syndication|newsletter|sharing|follow|email|likes?|(?:give[_-]?)?feedback|(?:brand[_-])?engagement|facebook|twitter|subscribe|wa|jp|aptf-follow)(?:[_-]?(?:post|links?|section|icons?|btn|buttons?|target))?(?:$|[\\s_-])"), __pyx_v_11resiliparse_7extract_9html2text_re_opts);

  /* "resiliparse/extract/html2text.pyx":335
 * cdef RE2 ads_cls_regex = RE2(rb'(?:^|\s)(?:(?:google|wide)[_-]?ads?|ad(?:vert|vertise(?:ment|link)?|$|_[a-f0-9]+)|sponsor(?:ed)?|promoted|paid|(?:wide)?banner|donate)(?:$|[\s_-])', re_opts)
 * cdef RE2 social_cls_regex = RE2(rb'(?:^|\s|__|--|mobile-|desktop-|l-|m-|c-)(?:social(?:media|search)?|share(?:daddy)?|syndication|newsletter|sharing|follow|email|likes?|(?:give[_-]?)?feedback|(?:brand[_-])?engagement|facebook|twitter|subscribe|wa|jp|aptf-follow)(?:[_-]?(?:post|links?|section|icons?|btn|buttons?|target))?(?:$|[\s_-])', re_opts)
 * cdef RE2 comments_cls_regex = RE2(rb'(?:^|[\s_-])(?:(?:article|user|post)[_-]*)?(?:(?:no[_-]?)?comments?|comment[_-]?list|reply)(?:$|[\s_-])', re_opts)             # <<<<<<<<<<<<<<
 * cdef RE2 logo_cls_regex = RE2(rb'(?:brand(?:ing)?[_-]*)?logo(?:$|\s)', re_opts)
 * cdef RE2 print_cls_regex = RE2(rb'(?:^|\s)print[_-]', re_opts)
 */
  __pyx_v_11resiliparse_7extract_9html2text_comments_cls_regex = RE2Stack(((char const *)"(?:^|[\\s_-])(?:(?:article|user|post)[_-]*)?(?:(?:no[_-]?)?comments?|comment[_-]?list|reply)(?:$|[\\s_-])"), __pyx_v_11resiliparse_7extract_9html2text_re_opts);

  /* "resiliparse/extract/html2text.pyx":336
 * cdef RE2 social_cls_regex = RE2(rb'(?:^|\s|__|--|mobile-|desktop-|l-|m-|c-)(?:social(?:media|search)?|share(?:daddy)?|syndication|newsletter|sharing|follow|email|likes?|(?:give[_-]?)?feedback|(?:brand[_-])?engagement|facebook|twitter|subscribe|wa|jp|aptf-follow)(?:[_-]?(?:post|links?|section|icons?|btn|buttons?|target))?(?:$|[\s_-])', re_opts)
 * cdef RE2 comments_cls_regex = RE2(rb'(?:^|[\s_-])(?:(?:article|user|post)[_-]*)?(?:(?:no[_-]?)?comments?|comment[_-]?list|reply)(?:$|[\s_-])', re_opts)
 * cdef RE2 logo_cls_regex = RE2(rb'(?:brand(?:ing)?[_-]*)?logo(?:$|\s)', re_opts)             # <<<<<<<<<<<<<<
 * cdef RE2 print_cls_regex = RE2(rb'(?:^|\s)print[_-]', re_opts)
 * 
 */
  __pyx_v_11resiliparse_7extract_9html2text_logo_cls_regex = RE2Stack(((char const *)"(?:brand(?:ing)?[_-]*)?logo(?:$|\\s)"), __pyx_v_11resiliparse_7extract_9html2text_re_opts);

  /* "resiliparse/extract/html2text.pyx":337
 * cdef RE2 comments_cls_regex = RE2(rb'(?:^|[\s_-])(?:(?:article|user|post)[_-]*)?(?:(?:no[_-]?)?comments?|comment[_-]?list|reply)(?:$|[\s_-])', re_opts)
 * cdef RE2 logo_cls_regex = RE2(rb'(?:brand(?:ing)?[_-]*)?logo(?:$|\s)', re_opts)
 * cdef RE2 print_cls_regex = RE2(rb'(?:^|\s)print[_-]', re_opts)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_11resiliparse_7extract_9html2text_print_cls_regex = RE2Stack(((char const *)"(?:^|\\s)print[_-]"), __pyx_v_11resiliparse_7extract_9html2text_re_opts);

  /* "resiliparse/extract/html2text.pyx":371
 * 
 * 
 * cdef stl_set[string] blacklist_aria_roles = [b'alert', b'banner', b'checkbox', b'comment', b'complementary',             # <<<<<<<<<<<<<<
 *                                              b'contentinfo', b'dialog', b'img', b'menu', b'menubar', b'menuitem',
 *                                              b'navigation', b'presentation', b'radio', b'search', b'searchbox',
 */
  __pyx_t_2 = PyList_New(20); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_b_alert);
  __Pyx_GIVEREF(__pyx_n_b_alert);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_b_alert);
  __Pyx_INCREF(__pyx_n_b_banner);
  __Pyx_GIVEREF(__pyx_n_b_banner);
  PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_b_banner);
  __Pyx_INCREF(__pyx_n_b_checkbox);
  __Pyx_GIVEREF(__pyx_n_b_checkbox);
  PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_b_checkbox);
  __Pyx_INCREF(__pyx_n_b_comment);
  __Pyx_GIVEREF(__pyx_n_b_comment);
  PyList_SET_ITEM(__pyx_t_2, 3, __pyx_n_b_comment);
  __Pyx_INCREF(__pyx_n_b_complementary);
  __Pyx_GIVEREF(__pyx_n_b_complementary);
  PyList_SET_ITEM(__pyx_t_2, 4, __pyx_n_b_complementary);
  __Pyx_INCREF(__pyx_n_b_contentinfo);
  __Pyx_GIVEREF(__pyx_n_b_contentinfo);
  PyList_SET_ITEM(__pyx_t_2, 5, __pyx_n_b_contentinfo);
  __Pyx_INCREF(__pyx_n_b_dialog);
  __Pyx_GIVEREF(__pyx_n_b_dialog);
  PyList_SET_ITEM(__pyx_t_2, 6, __pyx_n_b_dialog);
  __Pyx_INCREF(__pyx_n_b_img);
  __Pyx_GIVEREF(__pyx_n_b_img);
  PyList_SET_ITEM(__pyx_t_2, 7, __pyx_n_b_img);
  __Pyx_INCREF(__pyx_n_b_menu);
  __Pyx_GIVEREF(__pyx_n_b_menu);
  PyList_SET_ITEM(__pyx_t_2, 8, __pyx_n_b_menu);
  __Pyx_INCREF(__pyx_n_b_menubar);
  __Pyx_GIVEREF(__pyx_n_b_menubar);
  PyList_SET_ITEM(__pyx_t_2, 9, __pyx_n_b_menubar);
  __Pyx_INCREF(__pyx_n_b_menuitem);
  __Pyx_GIVEREF(__pyx_n_b_menuitem);
  PyList_SET_ITEM(__pyx_t_2, 10, __pyx_n_b_menuitem);
  __Pyx_INCREF(__pyx_n_b_navigation);
  __Pyx_GIVEREF(__pyx_n_b_navigation);
  PyList_SET_ITEM(__pyx_t_2, 11, __pyx_n_b_navigation);
  __Pyx_INCREF(__pyx_n_b_presentation);
  __Pyx_GIVEREF(__pyx_n_b_presentation);
  PyList_SET_ITEM(__pyx_t_2, 12, __pyx_n_b_presentation);
  __Pyx_INCREF(__pyx_n_b_radio);
  __Pyx_GIVEREF(__pyx_n_b_radio);
  PyList_SET_ITEM(__pyx_t_2, 13, __pyx_n_b_radio);
  __Pyx_INCREF(__pyx_n_b_search);
  __Pyx_GIVEREF(__pyx_n_b_search);
  PyList_SET_ITEM(__pyx_t_2, 14, __pyx_n_b_search);
  __Pyx_INCREF(__pyx_n_b_searchbox);
  __Pyx_GIVEREF(__pyx_n_b_searchbox);
  PyList_SET_ITEM(__pyx_t_2, 15, __pyx_n_b_searchbox);
  __Pyx_INCREF(__pyx_n_b_separator);
  __Pyx_GIVEREF(__pyx_n_b_separator);
  PyList_SET_ITEM(__pyx_t_2, 16, __pyx_n_b_separator);
  __Pyx_INCREF(__pyx_n_b_tab);
  __Pyx_GIVEREF(__pyx_n_b_tab);
  PyList_SET_ITEM(__pyx_t_2, 17, __pyx_n_b_tab);
  __Pyx_INCREF(__pyx_n_b_toolbar);
  __Pyx_GIVEREF(__pyx_n_b_toolbar);
  PyList_SET_ITEM(__pyx_t_2, 18, __pyx_n_b_toolbar);
  __Pyx_INCREF(__pyx_n_b_tooltip);
  __Pyx_GIVEREF(__pyx_n_b_tooltip);
  PyList_SET_ITEM(__pyx_t_2, 19, __pyx_n_b_tooltip);
  __pyx_t_3 = __pyx_convert_set_from_py_std_3a__3a_string(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 371, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_11resiliparse_7extract_9html2text_blacklist_aria_roles = __pyx_t_3;

  /* "resiliparse/extract/html2text.pyx":583
 * 
 * 
 * def extract_plain_text(HTMLTree tree, bint preserve_formatting=True, bint main_content=False,             # <<<<<<<<<<<<<<
 *                        bint list_bullets=True,  bint alt_texts=True, bint links=False, bint form_fields=False,
 *                        bint noscript=False, bint comments=True, skip_elements=None):
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_11resiliparse_7extract_9html2text_1extract_plain_text, NULL, __pyx_n_s_resiliparse_extract_html2text); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 583, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_extract_plain_text, __pyx_t_2) < 0) __PYX_ERR(0, 583, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "resiliparse/extract/html2text.pyx":1
 * # Copyright 2021 Janek Bevendorff             # <<<<<<<<<<<<<<
 * #
 * # Licensed under the Apache License, Version 2.0 (the "License");
 */
  __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "string.to_py":55
 * 
 * @cname("__pyx_convert_PyByteArray_string_to_py_std__in_string")
 * cdef inline object __pyx_convert_PyByteArray_string_to_py_std__in_string(const string& s):             # <<<<<<<<<<<<<<
 *     return __Pyx_PyByteArray_FromStringAndSize(s.data(), s.size())
 * 
 */

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init resiliparse.extract.html2text", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_CLEAR(__pyx_m);
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init resiliparse.extract.html2text");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  return (__pyx_m != NULL) ? 0 : -1;
  #elif PY_MAJOR_VERSION >= 3
  return __pyx_m;
  #else
  return;
  #endif
}

/* --- Runtime support code --- */
/* Refnanny */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule(modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, "RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

/* PyObjectGetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#endif

/* GetBuiltinName */
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

/* PyErrFetchRestore */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}
#endif

/* WriteUnraisableException */
static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
                                  int full_traceback, CYTHON_UNUSED int nogil) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_PyThreadState_declare
#ifdef WITH_THREAD
    PyGILState_STATE state;
    if (nogil)
        state = PyGILState_Ensure();
#ifdef _MSC_VER
    else state = (PyGILState_STATE)-1;
#endif
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    if (full_traceback) {
        Py_XINCREF(old_exc);
        Py_XINCREF(old_val);
        Py_XINCREF(old_tb);
        __Pyx_ErrRestore(old_exc, old_val, old_tb);
        PyErr_PrintEx(1);
    }
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
#ifdef WITH_THREAD
    if (nogil)
        PyGILState_Release(state);
#endif
}

/* RaiseDoubleKeywords */
static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

/* ParseKeywords */
static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

/* RaiseArgTupleInvalid */
static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

/* ArgTypeTest */
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
{
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    else if (exact) {
        #if PY_MAJOR_VERSION == 2
        if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
        #endif
    }
    else {
        if (likely(__Pyx_TypeCheck(obj, type))) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

/* ExtTypeTest */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(__Pyx_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

/* PyFunctionFastCall */
#if CYTHON_FAST_PYCALL
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
                                               PyObject *globals) {
    PyFrameObject *f;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject **fastlocals;
    Py_ssize_t i;
    PyObject *result;
    assert(globals != NULL);
    /* XXX Perhaps we should create a specialized
       PyFrame_New() that doesn't take locals, but does
       take builtins without sanity checking them.
       */
    assert(tstate != NULL);
    f = PyFrame_New(tstate, co, globals, NULL);
    if (f == NULL) {
        return NULL;
    }
    fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
    for (i = 0; i < na; i++) {
        Py_INCREF(*args);
        fastlocals[i] = *args++;
    }
    result = PyEval_EvalFrameEx(f,0);
    ++tstate->recursion_depth;
    Py_DECREF(f);
    --tstate->recursion_depth;
    return result;
}
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
    PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
    PyObject *globals = PyFunction_GET_GLOBALS(func);
    PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
    PyObject *closure;
#if PY_MAJOR_VERSION >= 3
    PyObject *kwdefs;
#endif
    PyObject *kwtuple, **k;
    PyObject **d;
    Py_ssize_t nd;
    Py_ssize_t nk;
    PyObject *result;
    assert(kwargs == NULL || PyDict_Check(kwargs));
    nk = kwargs ? PyDict_Size(kwargs) : 0;
    if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
        return NULL;
    }
    if (
#if PY_MAJOR_VERSION >= 3
            co->co_kwonlyargcount == 0 &&
#endif
            likely(kwargs == NULL || nk == 0) &&
            co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
        if (argdefs == NULL && co->co_argcount == nargs) {
            result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
            goto done;
        }
        else if (nargs == 0 && argdefs != NULL
                 && co->co_argcount == Py_SIZE(argdefs)) {
            /* function called with no arguments, but all parameters have
               a default value: use default values as arguments .*/
            args = &PyTuple_GET_ITEM(argdefs, 0);
            result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
            goto done;
        }
    }
    if (kwargs != NULL) {
        Py_ssize_t pos, i;
        kwtuple = PyTuple_New(2 * nk);
        if (kwtuple == NULL) {
            result = NULL;
            goto done;
        }
        k = &PyTuple_GET_ITEM(kwtuple, 0);
        pos = i = 0;
        while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
            Py_INCREF(k[i]);
            Py_INCREF(k[i+1]);
            i += 2;
        }
        nk = i / 2;
    }
    else {
        kwtuple = NULL;
        k = NULL;
    }
    closure = PyFunction_GET_CLOSURE(func);
#if PY_MAJOR_VERSION >= 3
    kwdefs = PyFunction_GET_KW_DEFAULTS(func);
#endif
    if (argdefs != NULL) {
        d = &PyTuple_GET_ITEM(argdefs, 0);
        nd = Py_SIZE(argdefs);
    }
    else {
        d = NULL;
        nd = 0;
    }
#if PY_MAJOR_VERSION >= 3
    result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, kwdefs, closure);
#else
    result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, closure);
#endif
    Py_XDECREF(kwtuple);
done:
    Py_LeaveRecursiveCall();
    return result;
}
#endif
#endif

/* PyObjectCall */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = Py_TYPE(func)->tp_call;
    if (unlikely(!call))
        return PyObject_Call(func, arg, kw);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = (*call)(func, arg, kw);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCallMethO */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
    PyObject *self, *result;
    PyCFunction cfunc;
    cfunc = PyCFunction_GET_FUNCTION(func);
    self = PyCFunction_GET_SELF(func);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = cfunc(self, arg);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCallNoArg */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, NULL, 0);
    }
#endif
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
#else
    if (likely(PyCFunction_Check(func)))
#endif
    {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

/* PyCFunctionFastCall */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
    PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    int flags = PyCFunction_GET_FLAGS(func);
    assert(PyCFunction_Check(func));
    assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
    assert(nargs >= 0);
    assert(nargs == 0 || args != NULL);
    /* _PyCFunction_FastCallDict() must not be called with an exception set,
       because it may clear it (directly or indirectly) and so the
       caller loses its exception */
    assert(!PyErr_Occurred());
    if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
        return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
    } else {
        return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
    }
}
#endif

/* PyObjectCallOneArg */
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_New(1);
    if (unlikely(!args)) return NULL;
    Py_INCREF(arg);
    PyTuple_SET_ITEM(args, 0, arg);
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, &arg, 1);
    }
#endif
    if (likely(PyCFunction_Check(func))) {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
#if CYTHON_FAST_PYCCALL
        } else if (__Pyx_PyFastCFunction_Check(func)) {
            return __Pyx_PyCFunction_FastCall(func, &arg, 1);
#endif
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_Pack(1, arg);
    if (unlikely(!args)) return NULL;
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
#endif

/* UnpackUnboundCMethod */
static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
    PyObject *method;
    method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
    if (unlikely(!method))
        return -1;
    target->method = method;
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION >= 3
    if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
    #endif
    {
        PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
        target->func = descr->d_method->ml_meth;
        target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS);
    }
#endif
    return 0;
}

/* CallUnboundCMethod1 */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg) {
    if (likely(cfunc->func)) {
        int flag = cfunc->flag;
        if (flag == METH_O) {
            return (*(cfunc->func))(self, arg);
        } else if (PY_VERSION_HEX >= 0x030600B1 && flag == METH_FASTCALL) {
            if (PY_VERSION_HEX >= 0x030700A0) {
                return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, &arg, 1);
            } else {
                return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL);
            }
        } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
            return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL);
        }
    }
    return __Pyx__CallUnboundCMethod1(cfunc, self, arg);
}
#endif
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg){
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
        args = PyTuple_New(1);
        if (unlikely(!args)) goto bad;
        Py_INCREF(arg);
        PyTuple_SET_ITEM(args, 0, arg);
        if (cfunc->flag & METH_KEYWORDS)
            result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL);
        else
            result = (*cfunc->func)(self, args);
    } else {
        args = PyTuple_New(2);
        if (unlikely(!args)) goto bad;
        Py_INCREF(self);
        PyTuple_SET_ITEM(args, 0, self);
        Py_INCREF(arg);
        PyTuple_SET_ITEM(args, 1, arg);
        result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    }
#else
    args = PyTuple_Pack(2, self, arg);
    if (unlikely(!args)) goto bad;
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
#endif
bad:
    Py_XDECREF(args);
    return result;
}

/* StringJoin */
#if !CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) {
    return PyObject_CallMethodObjArgs(sep, __pyx_n_s_join, values, NULL);
}
#endif

/* GetException */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
#endif
{
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_FAST_THREAD_STATE
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_FAST_THREAD_STATE
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (local_tb) {
        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
            goto bad;
    }
    #endif
    Py_XINCREF(local_tb);
    Py_XINCREF(local_type);
    Py_XINCREF(local_value);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_FAST_THREAD_STATE
    #if CYTHON_USE_EXC_INFO_STACK
    {
        _PyErr_StackItem *exc_info = tstate->exc_info;
        tmp_type = exc_info->exc_type;
        tmp_value = exc_info->exc_value;
        tmp_tb = exc_info->exc_traceback;
        exc_info->exc_type = local_type;
        exc_info->exc_value = local_value;
        exc_info->exc_traceback = local_tb;
    }
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

/* SwapException */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = *type;
    exc_info->exc_value = *value;
    exc_info->exc_traceback = *tb;
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = *type;
    tstate->exc_value = *value;
    tstate->exc_traceback = *tb;
    #endif
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
    PyErr_SetExcInfo(*type, *value, *tb);
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#endif

/* GetTopmostException */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
{
    _PyErr_StackItem *exc_info = tstate->exc_info;
    while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
           exc_info->previous_item != NULL)
    {
        exc_info = exc_info->previous_item;
    }
    return exc_info;
}
#endif

/* SaveResetException */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
    *type = exc_info->exc_type;
    *value = exc_info->exc_value;
    *tb = exc_info->exc_traceback;
    #else
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    #endif
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = type;
    exc_info->exc_value = value;
    exc_info->exc_traceback = tb;
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
#endif

/* PyDictVersioning */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
    PyObject **dictptr = NULL;
    Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
    if (offset) {
#if CYTHON_COMPILING_IN_CPYTHON
        dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
#else
        dictptr = _PyObject_GetDictPtr(obj);
#endif
    }
    return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
}
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
        return 0;
    return obj_dict_version == __Pyx_get_object_dict_version(obj);
}
#endif

/* GetModuleGlobalName */
#if CYTHON_USE_DICT_VERSIONS
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
#else
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
#endif
{
    PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
    result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    } else if (unlikely(PyErr_Occurred())) {
        return NULL;
    }
#else
    result = PyDict_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
#endif
#else
    result = PyObject_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
    PyErr_Clear();
#endif
    return __Pyx_GetBuiltinName(name);
}

/* PyObjectCall2Args */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
    PyObject *args, *result = NULL;
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyFunction_FastCall(function, args, 2);
    }
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyCFunction_FastCall(function, args, 2);
    }
    #endif
    args = PyTuple_New(2);
    if (unlikely(!args)) goto done;
    Py_INCREF(arg1);
    PyTuple_SET_ITEM(args, 0, arg1);
    Py_INCREF(arg2);
    PyTuple_SET_ITEM(args, 1, arg2);
    Py_INCREF(function);
    result = __Pyx_PyObject_Call(function, args, NULL);
    Py_DECREF(args);
    Py_DECREF(function);
done:
    return result;
}

/* TypeImport */
#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
    size_t size, enum __Pyx_ImportType_CheckSize check_size)
{
    PyObject *result = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    result = PyObject_GetAttrString(module, class_name);
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%.200s.%.200s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifndef Py_LIMITED_API
    basicsize = ((PyTypeObject *)result)->tp_basicsize;
#else
    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
    if (!py_basicsize)
        goto bad;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = 0;
    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
        goto bad;
#endif
    if ((size_t)basicsize < size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(result);
    return NULL;
}
#endif

/* GetVTable */
static void* __Pyx_GetVtable(PyObject *dict) {
    void* ptr;
    PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
    if (!ob)
        goto bad;
#if PY_VERSION_HEX >= 0x02070000
    ptr = PyCapsule_GetPointer(ob, 0);
#else
    ptr = PyCObject_AsVoidPtr(ob);
#endif
    if (!ptr && !PyErr_Occurred())
        PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
    Py_DECREF(ob);
    return ptr;
bad:
    Py_XDECREF(ob);
    return NULL;
}

/* Import */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_MAJOR_VERSION < 3
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
    if (!py_import)
        goto bad;
    #endif
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_MAJOR_VERSION < 3
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

/* ImportFrom */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

/* CLineInTraceback */
#ifndef CYTHON_CLINE_IN_TRACEBACK
static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
    PyObject *use_cline;
    PyObject *ptype, *pvalue, *ptraceback;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject **cython_runtime_dict;
#endif
    if (unlikely(!__pyx_cython_runtime)) {
        return c_line;
    }
    __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON
    cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
    if (likely(cython_runtime_dict)) {
        __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
            use_cline, *cython_runtime_dict,
            __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
    } else
#endif
    {
      PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
      if (use_cline_obj) {
        use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
        Py_DECREF(use_cline_obj);
      } else {
        PyErr_Clear();
        use_cline = NULL;
      }
    }
    if (!use_cline) {
        c_line = 0;
        (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
    }
    else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
        c_line = 0;
    }
    __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
    return c_line;
}
#endif

/* CodeObjectCache */
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = start + (end - start) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

/* AddTraceback */
#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = NULL;
    PyObject *py_funcname = NULL;
    #if PY_MAJOR_VERSION < 3
    PyObject *py_srcfile = NULL;
    py_srcfile = PyString_FromString(filename);
    if (!py_srcfile) goto bad;
    #endif
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        if (!py_funcname) goto bad;
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        if (!py_funcname) goto bad;
        funcname = PyUnicode_AsUTF8(py_funcname);
        if (!funcname) goto bad;
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        if (!py_funcname) goto bad;
        #endif
    }
    #if PY_MAJOR_VERSION < 3
    py_code = __Pyx_PyCode_New(
        0,
        0,
        0,
        0,
        0,
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    #else
    py_code = PyCode_NewEmpty(filename, funcname, py_line);
    #endif
    Py_XDECREF(py_funcname);  // XDECREF since it's only set on Py3 if cline
    return py_code;
bad:
    Py_XDECREF(py_funcname);
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(py_srcfile);
    #endif
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    if (c_line) {
        c_line = __Pyx_CLineForTraceback(tstate, c_line);
    }
    py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
    }
    py_frame = PyFrame_New(
        tstate,            /*PyThreadState *tstate,*/
        py_code,           /*PyCodeObject *code,*/
        __pyx_d,    /*PyObject *globals,*/
        0                  /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

/* CIntFromPyVerify */
#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
    {\
        func_type value = func_value;\
        if (sizeof(target_type) < sizeof(func_type)) {\
            if (unlikely(value != (func_type) (target_type) value)) {\
                func_type zero = 0;\
                if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                    return (target_type) -1;\
                if (is_unsigned && unlikely(value < zero))\
                    goto raise_neg_overflow;\
                else\
                    goto raise_overflow;\
            }\
        }\
        return (target_type) value;\
    }

/* CIntFromPy */
static CYTHON_INLINE size_t __Pyx_PyInt_As_size_t(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const size_t neg_one = (size_t) -1, const_zero = (size_t) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(size_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(size_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (size_t) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (size_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(size_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) >= 2 * PyLong_SHIFT) {
                            return (size_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) >= 3 * PyLong_SHIFT) {
                            return (size_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) >= 4 * PyLong_SHIFT) {
                            return (size_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (size_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(size_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(size_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (size_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(size_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(size_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(size_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                            return (size_t) (((size_t)-1)*(((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(size_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                            return (size_t) ((((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(size_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                            return (size_t) (((size_t)-1)*(((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(size_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                            return (size_t) ((((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(size_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
                            return (size_t) (((size_t)-1)*(((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(size_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(size_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(size_t) - 1 > 4 * PyLong_SHIFT) {
                            return (size_t) ((((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(size_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(size_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(size_t, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            size_t val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (size_t) -1;
        }
    } else {
        size_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (size_t) -1;
        val = __Pyx_PyInt_As_size_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to size_t");
    return (size_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to size_t");
    return (size_t) -1;
}

/* CIntFromPy */
static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const char neg_one = (char) -1, const_zero = (char) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(char) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(char, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (char) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (char) 0;
                case  1: __PYX_VERIFY_RETURN_INT(char, digit, digits[0])
                case 2:
                    if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) >= 2 * PyLong_SHIFT) {
                            return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) >= 3 * PyLong_SHIFT) {
                            return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) >= 4 * PyLong_SHIFT) {
                            return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (char) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(char) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (char) 0;
                case -1: __PYX_VERIFY_RETURN_INT(char, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(char,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(char) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
                            return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
                            return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
                            return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
                            return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
                            return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
                            return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(char) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            char val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (char) -1;
        }
    } else {
        char val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (char) -1;
        val = __Pyx_PyInt_As_char(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to char");
    return (char) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to char");
    return (char) -1;
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int neg_one = (int) -1, const_zero = (int) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const long neg_one = (long) -1, const_zero = (long) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const long neg_one = (long) -1, const_zero = (long) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (long) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (long) -1;
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to long");
    return (long) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to long");
    return (long) -1;
}

/* CIntFromPy */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int neg_one = (int) -1, const_zero = (int) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int) -1;
        }
    } else {
        int val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int");
    return (int) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int");
    return (int) -1;
}

/* FastTypeChecks */
#if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
    while (a) {
        a = a->tp_base;
        if (a == b)
            return 1;
    }
    return b == &PyBaseObject_Type;
}
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
    PyObject *mro;
    if (a == b) return 1;
    mro = a->tp_mro;
    if (likely(mro)) {
        Py_ssize_t i, n;
        n = PyTuple_GET_SIZE(mro);
        for (i = 0; i < n; i++) {
            if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
                return 1;
        }
        return 0;
    }
    return __Pyx_InBases(a, b);
}
#if PY_MAJOR_VERSION == 2
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
    PyObject *exception, *value, *tb;
    int res;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&exception, &value, &tb);
    res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
    if (unlikely(res == -1)) {
        PyErr_WriteUnraisable(err);
        res = 0;
    }
    if (!res) {
        res = PyObject_IsSubclass(err, exc_type2);
        if (unlikely(res == -1)) {
            PyErr_WriteUnraisable(err);
            res = 0;
        }
    }
    __Pyx_ErrRestore(exception, value, tb);
    return res;
}
#else
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
    int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
    if (!res) {
        res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
    }
    return res;
}
#endif
static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    assert(PyExceptionClass_Check(exc_type));
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        PyObject *t = PyTuple_GET_ITEM(tuple, i);
        #if PY_MAJOR_VERSION < 3
        if (likely(exc_type == t)) return 1;
        #endif
        if (likely(PyExceptionClass_Check(t))) {
            if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
        } else {
        }
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
    if (likely(err == exc_type)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        if (likely(PyExceptionClass_Check(exc_type))) {
            return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
        } else if (likely(PyTuple_Check(exc_type))) {
            return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
        } else {
        }
    }
    return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
    assert(PyExceptionClass_Check(exc_type1));
    assert(PyExceptionClass_Check(exc_type2));
    if (likely(err == exc_type1 || err == exc_type2)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
    }
    return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif

/* CheckBinaryVersion */
static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        return PyErr_WarnEx(NULL, message, 1);
    }
    return 0;
}

/* FunctionImport */
#ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, funcname);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%.200s does not export expected C function %.200s",
                PyModule_GetName(module), funcname);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    tmp.p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
             PyModule_GetName(module), funcname, sig, desc);
        goto bad;
    }
    tmp.p = PyCObject_AsVoidPtr(cobj);}
#endif
    *f = tmp.fp;
    if (!(*f))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

/* InitStrings */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        if (PyObject_Hash(*t->p) == -1)
            return -1;
        ++t;
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    char* defenc_c;
    PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
    if (!defenc) return NULL;
    defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    {
        char* end = defenc_c + PyBytes_GET_SIZE(defenc);
        char* c;
        for (c = defenc_c; c < end; c++) {
            if ((unsigned char) (*c) >= 128) {
                PyUnicode_AsASCIIString(o);
                return NULL;
            }
        }
    }
#endif
    *length = PyBytes_GET_SIZE(defenc);
    return defenc_c;
}
#else
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    if (likely(PyUnicode_IS_ASCII(o))) {
        *length = PyUnicode_GET_LENGTH(o);
        return PyUnicode_AsUTF8(o);
    } else {
        PyUnicode_AsASCIIString(o);
        return NULL;
    }
#else
    return PyUnicode_AsUTF8AndSize(o, length);
#endif
}
#endif
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
        return __Pyx_PyUnicode_AsStringAndSize(o, length);
    } else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
    int retval;
    if (unlikely(!x)) return -1;
    retval = __Pyx_PyObject_IsTrue(x);
    Py_DECREF(x);
    return retval;
}
static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
#if PY_MAJOR_VERSION >= 3
    if (PyLong_Check(result)) {
        if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
                "__int__ returned non-int (type %.200s).  "
                "The ability to return an instance of a strict subclass of int "
                "is deprecated, and may be removed in a future version of Python.",
                Py_TYPE(result)->tp_name)) {
            Py_DECREF(result);
            return NULL;
        }
        return result;
    }
#endif
    PyErr_Format(PyExc_TypeError,
                 "__%.4s__ returned non-%.4s (type %.200s)",
                 type_name, type_name, Py_TYPE(result)->tp_name);
    Py_DECREF(result);
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
#if CYTHON_USE_TYPE_SLOTS
  PyNumberMethods *m;
#endif
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_Check(x) || PyLong_Check(x)))
#else
  if (likely(PyLong_Check(x)))
#endif
    return __Pyx_NewRef(x);
#if CYTHON_USE_TYPE_SLOTS
  m = Py_TYPE(x)->tp_as_number;
  #if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = m->nb_int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = m->nb_long(x);
  }
  #else
  if (likely(m && m->nb_int)) {
    name = "int";
    res = m->nb_int(x);
  }
  #endif
#else
  if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
    res = PyNumber_Int(x);
  }
#endif
  if (likely(res)) {
#if PY_MAJOR_VERSION < 3
    if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
#else
    if (unlikely(!PyLong_CheckExact(res))) {
#endif
        return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b))) {
    if (sizeof(Py_ssize_t) >= sizeof(long))
        return PyInt_AS_LONG(b);
    else
        return PyInt_AsSsize_t(b);
  }
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_USE_PYLONG_INTERNALS
    const digit* digits = ((PyLongObject*)b)->ob_digit;
    const Py_ssize_t size = Py_SIZE(b);
    if (likely(__Pyx_sst_abs(size) <= 1)) {
        ival = likely(size) ? digits[0] : 0;
        if (size == -1) ival = -ival;
        return ival;
    } else {
      switch (size) {
         case 2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
      }
    }
    #endif
    return PyLong_AsSsize_t(b);
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) {
  if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) {
    return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o);
#if PY_MAJOR_VERSION < 3
  } else if (likely(PyInt_CheckExact(o))) {
    return PyInt_AS_LONG(o);
#endif
  } else {
    Py_ssize_t ival;
    PyObject *x;
    x = PyNumber_Index(o);
    if (!x) return -1;
    ival = PyInt_AsLong(x);
    Py_DECREF(x);
    return ival;
  }
}
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
