How to use the wtf_wikipedia function in wtf_wikipedia

To help you get started, we’ve selected a few wtf_wikipedia examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xyfir / illuminsight / __tests__ / components / reader / Insights.spec.tsx View on Github external
test('', () => {
  expect(true).toBe(true);

  const store = createStore(reducer, {
    insights: {
      definitions: testDefinitions,
      searches: [
        {
          name: 'Google',
          url: 'https://www.google.com/search?q=Blood%20Meridian',
        },
      ],
      wikis: [
        {
          recipe: defaultRecipe.wikis[0],
          doc: wtf(testWikitext),
        },
      ],
      text: 'Blood Meridian',
    },
    recipe: defaultRecipe,
    pub: testPub,
    ast: [],
  });
  const { getAllByText, getByTitle, getByText } = render(
    
      
    ,
  );

  // Expect insight to have opened definitions
  getAllByText('noun');
github xyfir / illuminsight / __tests__ / components / reader / WikiInsight.spec.tsx View on Github external
test('', async () => {
  const { getByLabelText, getAllByText, getByText } = render(
    ,
  );

  // Validate only main section was rendered
  getByText("McCarthy's fifth book", { exact: false });
  // in second section:
  expect(() =>
    getByText('The novel follows an adolescent runaway', { exact: false }),
  ).toThrow();
  // in infobox:
  expect(() => getByText('historical novel')).toThrow();

  // Validate attribution
  let el = getByText('Source: Wikipedia:');
  el = el.querySelector('a')!;
  expect(el.textContent).toBe(
github xyfir / illuminsight / __tests__ / components / reader / WikiInsight.spec.tsx View on Github external
expect(els[1].tagName).toBe('H1');

  // Trigger section change from breadcrumbs to main "Blood Meridian or The Evening Redness in the West"
  fireEvent.click(
    getByText('Blood Meridian or The Evening Redness in the West'),
  );

  // Validate we're back to main section
  getByText('Source: Wikipedia:');
  getByText("McCarthy's fifth book", { exact: false });
  getByText('Continue Reading');
  getByText('Show Statistics');

  // Mock wtf_wikipedia.fetch()
  const mockFetch = ((wtf as any).fetch = jest.fn());
  mockFetch.mockResolvedValueOnce(wtf(alternateTestWikitext));

  // Click "Cormac McCarthy" link
  fireEvent.click(getByText('Cormac McCarthy'));

  // Validate new article was loaded
  expect(mockFetch).toHaveBeenCalledTimes(1);
  expect(mockFetch.mock.calls[0][0]).toBe('Cormac_McCarthy');
  await waitForDomChange();
  getByText('American novelist, playwright, and', { exact: false });

  // Click back button to main "Blood Meridian" article
  fireEvent.click(getByLabelText('Go back to previous article'));

  // Validate we're back to main article
  getByText("McCarthy's fifth book", { exact: false });
});
github knreise / KNReiseAPI / src / apis / LokalhistoriewikiAPI.js View on Github external
function parseLokalhistorieItem(item, extra) {
        var extraData = {};
        if (extra && _.has(extra, 'revisions')) {
            var wikitext = extra.revisions[0]['*'];
            var doc = wtf(wikitext);
            extraData.media = _getThumbnails(wikitext).concat(_getImages(doc.images()));
            extraData.thumbnail = extraData.media.length > 0
                ? extraData.media[0].image
                : null;


            var text = _.chain(doc.sections())
                .filter(s => {
                    return BLACKLIST.indexOf(s.title().toLowerCase()) === -1;
                }).map(s => `${s.title()}\n${s.plaintext()}`)
                .value()
                .join('\n\n');

            extraData.text = text;
        }
        var link = `${urlBase}?curid=${item.pageid}`;

wtf_wikipedia

parse wikiscript into json

MIT
Latest version published 3 months ago

Package Health Score

69 / 100
Full package analysis