GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — HTMLTokenizer.stream.chunkOffset not updating on string with no html elements · Issue #571 · html5lib/html5lib-python

HTMLTokenizer.stream.chunkOffset not updating on string with no html elements #571

New issue
Copy link
New issue
Copy link
Open
Open
HTMLTokenizer.stream.chunkOffset not updating on string with no html elements#571
Copy link

Description

@ehsmeng
ehsmeng
opened on Jul 29, 2023
Issue body actions
from html5lib._tokenizer import HTMLTokenizer
from io import StringIO

class T():
    def __init__(self, data):
        print("Object from string: " + data)
        self.src = StringIO()
        self.tokenizer = HTMLTokenizer(self.src)

        pos = self.src.tell()
        self.src.write(data)
        self.src.seek(pos)
        self.handle_tokens()
        self.src.close()

    def handle_tokens(self):
        for token in self.tokenizer:
            print(str(self.tokenizer.stream.chunkOffset))

T("klas katt")
T("klas katt<br>")

->

Object from string: klas katt
0
Object from string: klas katt

9
13

I expected first number outputted to be 9.

Apologies if this is an internal variable I should not use.
I'm trying to deduce tag offsets (start,stop) in the html document.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.