You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
varwtf=require("wtf_wikipedia");consttext=`==English=====Etymology==={{suffix|abbreviate|ory|lang=en}}===Pronunciation===* {{a|GenAm}} {{IPA|/əˈbɹi.vi.əˌtɔɹ.i/|lang=en}}===Adjective==={{en-adj}}# Serving or tending to [[abbreviate]]; [[shortening]]; [[abridging]]. {{defdate|Mid 19<sup>th</sup> century.}}<ref name=SOED>{{R:SOED5|page=3}}</ref>====Translations===={{trans-top|serving or tending to abbreviate; shortening; abridging}}* Dutch: {{t+|nl|afkortend}}, {{t+|nl|verkortend}}{{trans-mid}}* Portuguese: {{t|pt|abreviatório}}, {{t|pt|abreviativo}}{{trans-bottom}}===References===<references/>`;constdocument=wtf(text,{title: 'abbreviatory'});console.log(JSON.stringify(document.json(),null,2));
This document (which is taken from Wiktionary) has a single top-level section with the title "English". Nested within that top-level section are four second-level sections.
All sections and subsections are returned as a flat array. I would have expected the top-level array to contain only a single section. How do I get only the top-level sections for a document?
The title property for the first section is empty. Shouldn't that be "English"? In turn, its sentences property contains "text": "==English==".
The text was updated successfully, but these errors were encountered:
hey Daniel, yeah you're correct about the mis-parsing of the section title. I'll check that out.
you can use the depth property to find sections of a specific level. There are also .children().parent() and so on methods, please check out the api
I played around with the idea of nested-sections, but it got really messy.
will look at the ==english== issue asap
cheers
Consider the following script:
This document (which is taken from Wiktionary) has a single top-level section with the title "English". Nested within that top-level section are four second-level sections.
Here's the output:
Here's what strikes me as odd:
title
property for the first section is empty. Shouldn't that be "English"? In turn, itssentences
property contains"text": "==English=="
.The text was updated successfully, but these errors were encountered: