Not all puzzles are standard sudoku, so you never know what is the full set of digits to pencilmark. Maybe the puzzle allows to have zeros. Maybe it's a "mean mini" puzzle that allows entering digits 1-9 despite of having a 6x6 grid. Maybe the puzzle contains letters instead of digits. My current solution is to scan the puzzle for which digits and letters were already entered into the grid and assume that it's the set of things to pencilmark into the cell. Sometimes it works fine, sometimes it's being ridiculous (e.g. when people are using the letter tool to mark some cell relations). Maybe you can come out with something smarter.
Consider adding the functionality from this awesome script: https://github.com/yusitnikov/sudokupad-sven-magic Namely:
Yes, it's "cheating", but it honestly takes a lot of the boring parts out of puzzles so that we can focus on the fun stuff.