Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

=header= support as <h1> #429

Open
ztomm opened this issue May 10, 2021 · 5 comments
Open

=header= support as <h1> #429

ztomm opened this issue May 10, 2021 · 5 comments

Comments

@ztomm
Copy link

ztomm commented May 10, 2021

I updated wtf_wikipedia@8.5.1 to wtf_wikipedia@9.0.0. Now I got following error when parsing to HTML with the additional modul wtf-plugin-html@0.2.1:

if (options.title === true && data.title) {

TypeError: Cannot read property 'title' of undefined
at Document.toHtml [as html] (Y:_dev\wikiparser\node_modules\wtf-plugin-html\builds\wtf-plugin-html.js:34:40)
at Object. (Y:_dev\wikiparser\app.js:46:20)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47

reproduce with this steps:

create test folder

npm init
npm i wtf_wikipedia
npm i wtf-plugin-html

create app.js

const wtf = require('wtf_wikipedia')
wtf.extend(require('wtf-plugin-html'))

var input = "'''some bold text'''"

console.log(wtf(input).html())

run
node app

@spencermountain
Copy link
Owner

hey, thanks Murat - I'm not sure what happened there.
I reproduced this, and fixed it in 0.2.2
thanks for the heads-up.
cheers

@ztomm
Copy link
Author

ztomm commented May 12, 2021

Hey. Thanks a lot. This part works again.

But I found another bug in this plugin. I think it is related to this issue. So I won't open a new one.

try above with h tags e.g. var input = "= some heading ="

The message is:

...\node_modules\wtf-plugin-html\builds\wtf-plugin-html.js:79
let num = 1 + this.depth();

TypeError: this.depth is not a function
...

I removed these parentheses in this line which fixed it.

This:
let num = 1 + this.depth();

To:
let num = 1 + this.depth;

@spencermountain
Copy link
Owner

yikes. Yeah, i should apologize for neglecting this plugin - this issue for example is pretty egregious.
PR's welcome! I have a busy few weeks, but can help improve this thing this summer, if it's continuing to get used a lot.
thanks

@spencermountain
Copy link
Owner

also - creating attractive-looking html infoboxes is a huge and really fun project that would be great to finally do.
Each infobox variant has its own secretive display logic, and hidden metadata, and layout that would really payoff, if we did it well.
you're welcome to jump in, as much as you're comfortable.
cheers

@spencermountain spencermountain changed the title Parsing to HTML: TypeError: Cannot read property 'title' of undefined =header= support as <h1> Dec 8, 2022
@spencermountain
Copy link
Owner

I didn't realize single-equal sign headers were possible. Looks like they are.
I tried tweaking the regex to support these but started seeing failures on headings like this:
== Publikasies<ref>Esaach: http://www.esaach.org.za/index.php?title=Behr,_Mark</ref> ==
gonna punt one this for now.
Can rework the section parser to be smarter, if this shows up for more cases.
cheers

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

No branches or pull requests

2 participants