parseKanjiPageData function

KanjiResult parseKanjiPageData(
  1. String pageHtml,
  2. String kanji
)

Parses a jisho kanji search page to an object

Implementation

KanjiResult parseKanjiPageData(String pageHtml, String kanji) {
  final result = KanjiResult(
    query: kanji,
    found: _containsKanjiGlyph(pageHtml, kanji),
  );

  if (result.found == false) {
    return result;
  }

  result.data = KanjiResultData(
    strokeCount: _getStrokeCount(pageHtml),
    meaning: _getMeaning(pageHtml),
    strokeOrderDiagramUri: _getUriForStrokeOrderDiagram(kanji),
    strokeOrderSvgUri: _getSvgUri(pageHtml),
    strokeOrderGifUri: _getGifUri(kanji),
    uri: uriForKanjiSearch(kanji).toString(),
    parts: _getParts(pageHtml),
    taughtIn: _getTaughtIn(pageHtml),
    jlptLevel: _getJlptLevel(pageHtml),
    newspaperFrequencyRank: _getNewspaperFrequencyRank(pageHtml),
    kunyomi: _getKunyomi(pageHtml),
    onyomi: _getOnyomi(pageHtml),
    kunyomiExamples: _getKunyomiExamples(pageHtml),
    onyomiExamples: _getOnyomiExamples(pageHtml),
    radical: _getRadical(pageHtml),
  );

  return result;
}