mitodl / ocw-to-hugo

A command line utility for taking master.json output from ocw-data-parser and producing markdown for use with hugo-course-publisher
3 stars 0 forks source link

Cannot read property length of null #138

Closed noisecapella closed 2 years ago

noisecapella commented 3 years ago

Steps to Reproduce

Convert res-9-003-brains-minds-and-machines-summer-course-summer-2015

Stacktrace

TypeError: Cannot read property 'length' of null
    at Object.replacement (/home/george/Projects/ocw-to-hugo/src/turndown.js:70:55)
    at TurndownService.replacementForNode (/home/george/Projects/ocw-to-hugo/node_modules/turndown/lib/turndown.cjs.js:877:10)
    at /home/george/Projects/ocw-to-hugo/node_modules/turndown/lib/turndown.cjs.js:836:40
    at NodeList.reduce (<anonymous>)
    at TurndownService.process (/home/george/Projects/ocw-to-hugo/node_modules/turndown/lib/turndown.cjs.js:829:17)
    at TurndownService.replacementForNode (/home/george/Projects/ocw-to-hugo/node_modules/turndown/lib/turndown.cjs.js:872:25)
    at /home/george/Projects/ocw-to-hugo/node_modules/turndown/lib/turndown.cjs.js:836:40
    at NodeList.reduce (<anonymous>)
    at TurndownService.process (/home/george/Projects/ocw-to-hugo/node_modules/turndown/lib/turndown.cjs.js:829:17)
    at TurndownService.turndown (/home/george/Projects/ocw-to-hugo/node_modules/turndown/lib/turndown.cjs.js:741:26) {
  level: 'error',
  service: 'user-service',
  [Symbol(level)]: 'error',
  [Symbol(message)]: '{"level":"error","service":"user-service"}'
}
noisecapella commented 3 years ago

Set of courses I noticed this bug on:

"1-012-introduction-to-civil-engineering-design-spring-2002",
"2-062j-wave-propagation-spring-2017",
"2-067-advanced-structural-dynamics-and-acoustics-13-811-spring-2004",
"21l-455-classical-literature-the-golden-age-of-augustan-rome-fall-2004",
"21w-035-science-writing-and-new-media-communicating-science-to-the-public-fall-2016",
"21w-031-science-writing-and-new-media-explorations-in-communicating-about-science-technology-spring-2017",
"4-647-technopolitics-culture-intervention-fall-2014",
"mas-965-nextlab-i-designing-mobile-technologies-for-the-next-billion-users-fall-2008",
"res-9-003-brains-minds-and-machines-summer-course-summer-2015"
noisecapella commented 3 years ago

Looks like some tables are not generating the --- which our code is expecting as a header. In res-9-003 maybe because there's no thead or th tag. Not sure but maybe this is something we should fix in the source HTML?

The original page for reference: https://ocw.mit.edu/resources/res-9-003-brains-minds-and-machines-summer-course-summer-2015/syllabus/course-instructors-guest-speakers-and-icub-team/ There is an empty page on production: https://ocwnext.odl.mit.edu/courses/res-9-003-brains-minds-and-machines-summer-course-summer-2015/sections/syllabus/course-instructors-guest-speakers-and-icub-team/

noisecapella commented 2 years ago

I don't see the exception in the issue anymore but I do see the table parsing/formatting issue. I'll close this and we can address that in #276