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

[[:Category:Foo]] syntax #308

Open
Istador opened this issue Sep 25, 2019 · 7 comments
Open

[[:Category:Foo]] syntax #308

Istador opened this issue Sep 25, 2019 · 7 comments

Comments

@Istador
Copy link
Contributor

Istador commented Sep 25, 2019

When using the normal link syntax for category pages inside an article [[Category:Foo]], it doesn't add a link to the text, but adds the page to the category. Therefore it's okay to not parse them as part of the text.

But there is a special special syntax with a colon in front that allows linking to category pages: [[:Category:Foo]]
It can also be piped to change the visual text on the page: [[:Category:Foo|Bar]].

https://en.wikipedia.org/wiki/Help:Category#Linking_to_category_pages

wtf_wikipedia doesn't support this syntax.


Code:

wtf('pre [[Category:Foo]] post').sentences(0).toHtml()
wtf('pre [[:Category:Foo]] post').sentences(0).toHtml()
wtf('pre [[:Category:Foo|Bar]] post').sentences(0).toHtml()

Actual result:

<span class="sentence">pre post</span>
<span class="sentence">pre post</span>
<span class="sentence">pre post</span>

Expected result:

<span class="sentence">pre post</span>
<span class="sentence">pre <a class="link" href="./Category:Foo">Category:Foo</a> post</span>
<span class="sentence">pre <a class="link" href="./Category:Foo">Bar</a> post</span>
@spencermountain
Copy link
Owner

ah interesting. Thanks for the heads-up @Istador . I think we should support this.

@spencermountain spencermountain changed the title Linking to category pages [[:Category:Foo]] syntax Sep 25, 2019
Istador added a commit to Istador/pine-interactive-map that referenced this issue Sep 25, 2019
@Istador
Copy link
Contributor Author

Istador commented Dec 25, 2022

Updated code for wtf_wikipedia version 10.0.3 with wtf-plugin-html version 1.0.0:

wtf('pre [[Category:Foo]] post').sentences()[0].html()
wtf('pre [[:Category:Foo]] post').sentences()[0].html()
wtf('pre [[Category:Foo|Bar]] post').sentences()[0].html()
wtf('pre [[:Category:Foo|Bar]] post').sentences()[0].html()

Actual result:

<span class="sentence">pre post</span>
<span class="sentence">pre post</span>
<span class="sentence">pre post</span>
<span class="sentence">pre post</span>

Expected result:

<span class="sentence">pre post</span>
<span class="sentence">pre <a class="link" href="./Category:Foo">Category:Foo</a> post</span>
<span class="sentence">pre post</span>
<span class="sentence">pre <a class="link" href="./Category:Foo">Bar</a> post</span>

File syntax is affected too.

wtf('pre [[File:Foo.png]] post').sentences()[0].html()
wtf('pre [[:File:Foo.png]] post').sentences()[0].html()
wtf('pre [[File:Foo.png|Bar]] post').sentences()[0].html()
wtf('pre [[:File:Foo.png|Bar]] post').sentences()[0].html()

Actual result:

<span class="sentence">pre post</span>
<span class="sentence">pre post</span>
<span class="sentence">pre post</span>
<span class="sentence">pre post</span>

Expected result:

<span class="sentence">pre <a class="link" href="./File:Foo.png">File:Foo.png</a> post</span>
<span class="sentence">pre <a class="link" href="./File:Foo.png">File:Foo.png</a> post</span>
<span class="sentence">pre <a class="link" href="./File:Foo.png">Bar</a> post</span>
<span class="sentence">pre <a class="link" href="./File:Foo.png">Bar</a> post</span>

File syntax within tables also seems broken:

wtf('{|\n|-\n|pre [[File:Foo.png]] post\n|}').tables()[0].data[0].col1.data.text
wtf('{|\n|-\n|pre [[:File:Foo.png]] post\n|}').tables()[0].data[0].col1.data.text
wtf('{|\n|-\n|pre [[File:Foo.png|Bar]] post\n|}').tables()[0].data[0].col1.data.text
wtf('{|\n|-\n|pre [[:File:Foo.png|Bar]] post\n|}').tables()[0].data[0].col1.data.text

Actual result:

"pre [[File:Foo.png]] post"
"pre [[:File:Foo.png]] post"
"pre Foo.png post"
"Bar]] post"

Expected result:

"pre File:Foo.png post"
"pre File:Foo.png post"
"pre Bar post"
"pre Bar post"

@spencermountain
Copy link
Owner

Thanks, I’ll check this out over the next few days
Cheers

@spencermountain
Copy link
Owner

spencermountain commented Dec 30, 2022

hey Robin, thanks for the heads-up. bit of a rats-nest these interwiki links are. You're right - the parser changed slightly in 10.0.3

you can check the wikipedia sandbox to see how it behaves:
2022-12-30-H6supyvn
i think the category syntax works as we'd like it to

yeah, the file syntax must have some special check in the wp parser. I'll check it out.
thanks

@spencermountain
Copy link
Owner

oh wait, i'm wrong. You're correct.
maybe we need to rollback the interwiki change.
rats!

@spencermountain
Copy link
Owner

think I got this fixed in 10.1.0 - let me know?
thanks for your patience.
cheers

@Istador
Copy link
Contributor Author

Istador commented Jan 2, 2023

wtf_wikipedia version 10.1.0 with wtf-plugin-html version 1.0.0:

wtf('pre [[Category:Foo]] post').sentences()[0].html()
wtf('pre [[:Category:Foo]] post').sentences()[0].html()
wtf('pre [[Category:Foo|Bar]] post').sentences()[0].html()
wtf('pre [[:Category:Foo|Bar]] post').sentences()[0].html()
wtf('pre [[File:Foo.png]] post').sentences()[0].html()
wtf('pre [[:File:Foo.png]] post').sentences()[0].html()
wtf('pre [[File:Foo.png|Bar]] post').sentences()[0].html()
wtf('pre [[:File:Foo.png|Bar]] post').sentences()[0].html()
wtf('{|\n|-\n|pre [[File:Foo.png]] post\n|}').tables()[0].data[0].col1.data.text
wtf('{|\n|-\n|pre [[:File:Foo.png]] post\n|}').tables()[0].data[0].col1.data.text
wtf('{|\n|-\n|pre [[File:Foo.png|Bar]] post\n|}').tables()[0].data[0].col1.data.text
wtf('{|\n|-\n|pre [[:File:Foo.png|Bar]] post\n|}').tables()[0].data[0].col1.data.text

Actual result:

<span class="sentence">pre post</span>
<span class="sentence">pre <a class="link" href="./:Category:Foo">Category:Foo</a> post</span>
<span class="sentence">pre post</span>
<span class="sentence">pre <a class="link" href="./:Category:Foo">Bar</a> post</span>
<span class="sentence">pre post</span>
<span class="sentence">pre <a class="link" href="./:File:Foo.png">File:Foo.png</a> post</span>
<span class="sentence">pre post</span>
<span class="sentence">pre <a class="link" href="./:File:Foo.png">Bar</a> post</span>
pre [[File:Foo.png]] post
pre File:Foo.png post
pre Foo.png post
pre Bar post

Expected result:

<span class="sentence">pre post</span>
<span class="sentence">pre <a class="link" href="./Category:Foo">Category:Foo</a> post</span>
<span class="sentence">pre post</span>
<span class="sentence">pre <a class="link" href="./Category:Foo">Bar</a> post</span>
<span class="sentence">pre <a class="link" href="./File:Foo.png">File:Foo.png</a> post</span>
<span class="sentence">pre <a class="link" href="./File:Foo.png">File:Foo.png</a> post</span>
<span class="sentence">pre <a class="link" href="./File:Foo.png">Bar</a> post</span>
<span class="sentence">pre <a class="link" href="./File:Foo.png">Bar</a> post</span>
pre File:Foo.png post
pre File:Foo.png post
pre Bar post
pre Bar post

For reference the wiki preview:

wiki

Based on this wikitext:

pre [[Category:Foo]] post

pre [[:Category:Foo]] post

pre [[Category:Foo|Bar]] post

pre [[:Category:Foo|Bar]] post

pre [[File:Foo.png]] post

pre [[:File:Foo.png]] post

pre [[File:Foo.png|Bar]] post

pre [[:File:Foo.png|Bar]] post

The ./:Category and ./:File hrefs instead of ./Category and ./File are neglectible because wikis seem to redirect these URLs correctly to the variant without a colon. Though it would be better without to avoid a redirect.


I think it's subjectible what wtf_wikipedia should do with files without the colon syntax, because if these files would exist, the wiki would render them as links with an image inside and not as links with text. Though the textual representation in tables should be identical / consistent with that?

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