# Wikipedia oneboxing with url encoded section hash

**URL:** https://meta.discourse.org/t/wikipedia-oneboxing-with-url-encoded-section-hash/199143
**Category:** Feature
**Created:** [August 4, 2021, 2:44pm UTC](https://meta.discourse.org/t/wikipedia-oneboxing-with-url-encoded-section-hash/199143 "2021-08-04T14:44:56Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Benjamin\_D](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/benjamin_d/32/277831_2.png) [@Benjamin\_D](https://meta.discourse.org/u/Benjamin_D)
#### Post date: [August 4, 2021, 2:44pm UTC](https://meta.discourse.org/t/wikipedia-oneboxing-with-url-encoded-section-hash/199143/1 "2021-08-04T14:44:56Z")

</div>

I haven’t categorized the topic as bug because it might be by design, not sure…  
so this works  
`https://fr.wikipedia.org/wiki/Th%C3%A9ologie#Platon`

> **[Théologie | Platon](https://fr.wikipedia.org/wiki/Th%C3%A9ologie#Platon)**
>
> Le premier à avoir employé le terme est le Grec Platon qui, dans La République (II, 379 a - 383 c), met dans la bouche d'Adimante, l'interlocuteur de Socrate, le mot θεολογία à propos de la mythologie, pour désigner la « science de la divinité » ou un discours vrai sur les dieux :

this doesn’t  
`https://fr.wikipedia.org/wiki/Th%C3%A9ologie#La_th%C3%A9ologie_selon_Aristote`

> **[Théologie](https://fr.wikipedia.org/wiki/Th%C3%A9ologie#La_th%C3%A9ologie_selon_Aristote)**
>
> La mise en forme de cet article est à améliorer (janvier 2024).
> La mise en forme du texte ne suit pas les recommandations de Wikipédia : il faut le « wikifier ».
> Les points d'amélioration suivants sont les cas les plus fréquents. Le détail des points à revoir est peut-être précisé sur la page de discussion.
> Pour une aide détaillée, merci de consulter Aide:Wikification.

Weirdly the span ids are `La_th.C3.A9ologie_selon_Aristote` and `La_théologie_selon_Aristote` 🤔 so I think there is something here: [discourse/lib/onebox/engine/wikipedia\_onebox.rb at 2f28ba318c3f650b1a0a76530021bc21bc8ab6f6 · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/2f28ba318c3f650b1a0a76530021bc21bc8ab6f6/lib/onebox/engine/wikipedia_onebox.rb#L27)

> [@Rebaking for automatic header anchors?](https://meta.discourse.org/t/rebaking-for-automatic-header-anchors/186106/1):
>
> Also, the link at the top, where I linked to `#automatic-header-anchor-links` shows me that oneboxing doesn’t ( **yet?** ) know about the section for discourse-internal anchor links, though it does for wikipedia anchor oneboxing (which is awesome). So I’m hoping that oneboxing can grow that soon.

I sure hope so! 😁

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [August 4, 2021, 2:49pm UTC](https://meta.discourse.org/t/wikipedia-oneboxing-with-url-encoded-section-hash/199143/2 "2021-08-04T14:49:06Z")

</div>

Both of your oneboxes work just fine for me in Android 🤔

---

<div class="post-metadata">

### Author: ![Benjamin\_D](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/benjamin_d/32/277831_2.png) [@Benjamin\_D](https://meta.discourse.org/u/Benjamin_D)
#### Post date: [August 4, 2021, 2:56pm UTC](https://meta.discourse.org/t/wikipedia-oneboxing-with-url-encoded-section-hash/199143/3 "2021-08-04T14:56:10Z")

</div>

The links work yes, but for the second one the excerpt should be:

> La poésie et les origines de la pensée… etc

ps. you had me 🤪 for a second here!

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [August 4, 2021, 3:52pm UTC](https://meta.discourse.org/t/wikipedia-oneboxing-with-url-encoded-section-hash/199143/4 "2021-08-04T15:52:31Z")

</div>

Oh you want the onebox summary to reflect the sub-section? That is controlled by

> <https://github.com/discourse/discourse/blob/main/lib/onebox/engine/wikipedia_onebox.rb#L22>

That is not matching

```xml
<h3>
  <span id="La_th.C3.A9ologie_selon_Aristote"></span>
  <span id="La_théologie_selon_Aristote">La théologie selon Aristote</span>
</h3>

```

The code is over 7 years old, so it’s very possible that the Wikipedia markup changed in the meanwhile. It’s a #pr-welcome if someone wants to work on this.

---

<div class="post-metadata">

### Author: ![jbalsas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jbalsas/32/230551_2.png) [@jbalsas](https://meta.discourse.org/u/jbalsas)
#### Post date: [August 11, 2021, 9:20pm UTC](https://meta.discourse.org/t/wikipedia-oneboxing-with-url-encoded-section-hash/199143/5 "2021-08-11T21:20:56Z")

</div>

I’ve sent a possible fix at [Fix/wikipedia oneboxing with url encoded hash by jbalsas · Pull Request #14015 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/14015).

I think unescaping the `m_url_hash_name` should be enough to cover all cases.

Hope this is the right process to contribute! 🤞

---

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erlend_sh/32/119475_2.png) [@erlend\_sh](https://meta.discourse.org/u/erlend_sh)
#### Post date: [August 30, 2021, 9:15am UTC](https://meta.discourse.org/t/wikipedia-oneboxing-with-url-encoded-section-hash/199143/6 "2021-08-30T09:15:18Z")

</div>


