-
Notifications
You must be signed in to change notification settings - Fork 0
/
wikt.h
53 lines (42 loc) · 1.38 KB
/
wikt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* \file
* Functions to process and navigate Wiktionary pages.
* https://www.wiktionary.org
*/
#include <stdbool.h>
#include "common.h"
#include <tidy.h>
#include <tidybuffio.h>
/** Base URL for the service. */
#define WIKTIONARY_BASE "https://en.wiktionary.org/wiki"
/** Relevant elements of a page. */
typedef struct {
/** Table-of-contents element. */
TidyNode toc;
/** Main content element of the page. */
TidyNode contents;
} wikt_page;
/**
* Finds the page elements.
* \param doc The root document.
* \param p Output parameter.
*/
bool wikt_parse_page(TidyDoc doc, wikt_page *p);
/** Finds the header of a translation element. */
TidyNode wikt_translation_head(TidyNode node);
/** Finds the body of a translation element. */
TidyNode wikt_translation_body(TidyNode node);
/** Moves forward to the next translation item. */
TidyNode wikt_next_translation_block(TidyNode node, TidyNode *list);
/** Checks whether an item is a translation to a given language. */
bool wikt_translation_is_language(TidyBuffer buf, const char *lang);
/**
* Advances `node` until the next section.
* \return Whether a section was found.
*/
bool wikt_next_section(const char *cls, const char *prefix, TidyNode *node);
/**
* Advances `node` until the next subsection.
* \return Whether a subsection was found.
*/
bool wikt_next_subsection(const char *cls, const char *prefix, TidyNode *node);