Skip to content
/ tiny-cfi Public

Generate EPUB CFI steps for a node in 40 lines of code!

License

Notifications You must be signed in to change notification settings

jccr/tiny-cfi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tiny CFI

Generate a minimal CFI for a target node, with only the DOM as a dependency.

Caveats

A bunch. This is very rudimentary. Only the element steps are generated. No ranges, no text offsets, no ID assertions.

Usage

generateCfiSteps(target, root)

Example

Given the HTML:

<!DOCTYPE html>
<html>
  <head></head>
  <body>
    <div id="div-2">
      <p id="p-2">
        Hello world
      </p>
      <div></div>
      <div id="div-6"></div>
      <div></div>
    </div>
  </body>
</html>

Running npm i && npm test should print out /4/2/6

Refer to main.js as a code example.

About

Generate EPUB CFI steps for a node in 40 lines of code!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published