Just published the preliminary tool on

codeberg.org/barefootstache/pd

It mainly describes how to do it and is a semi-automation tool to get PDFs into .

In the current version one will still need to modify the pattern constant in the clean-html.js file to align with the PDF in use.

After spending 7 hours to publish the code while going through a 71 page PDF.

The 71 pages were reduced to 43 pages in the `clean-html.js` step. And in the next step of `create-question.js` it was expanded to 63 pages.

Most of the time I was in the cleaning phase, since this is where one can remove pages and add questions quickly without the need of either copy-pasting the wording directly to or manually typing it out.

One thing that has been holding me back is not having a in to generate snippets quickly.

As neat as or is, I miss the abilities of in the browser.

I don't remember how many times I tried to grab certain properties, which would have been available in the browser, but don't exist in cheerio.

And it is a bit annoying to constantly put various html elements into the cheerio wrapper class to get access to the various functionalities it offers. Thus instead grabbed the minimal viable data and just worked further with arrays.

Follow

The most fun I had was dealing with a a pre-existing reference as in

```
const page = { foo: 0, bar: 0};
const pageList = [];
if (someNumber > 4) {
for (let ii = 0; ii < someNumber; ii++ ) {
page.foo = ii * ii;
page.bar = ii + ii;
pageList.push(page);
}
return;
}
pageList.push(page);
```

When console logging within the for-loop everything worked as expected, but if one saved the `JSON.stringify(pageList)` then each item that was created in the for-loop equated to the last item created.

The solution is to create a `structureClone(page)` within the for-loop and reference it over `page`.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.