From 72d39bea558236df07d53b5d50bd006f8c6d6d76 Mon Sep 17 00:00:00 2001 From: h7x4abk3g Date: Mon, 22 Jun 2020 14:00:24 +0200 Subject: [PATCH] Update todos --- lib/src/unofficial_jisho_api_base.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/src/unofficial_jisho_api_base.dart b/lib/src/unofficial_jisho_api_base.dart index 14ee018..a41e6cd 100644 --- a/lib/src/unofficial_jisho_api_base.dart +++ b/lib/src/unofficial_jisho_api_base.dart @@ -7,8 +7,6 @@ import 'package:html/dom.dart'; final htmlUnescape = html_entities.HtmlUnescape(); -// TODO: Put public facing types in this file. - const String JISHO_API = 'https://jisho.org/api/v1/search/words'; const String SCRAPE_BASE_URI = 'https://jisho.org/search/'; const String STROKE_ORDER_DIAGRAM_BASE_URI = 'https://classic.jisho.org/static/images/stroke_diagrams/'; @@ -46,7 +44,7 @@ String getStringBetweenIndicies(String data, int startIndex, int endIndex) { String getStringBetweenStrings(String data, String startString, String endString) { final regex = RegExp('${RegExp.escape(startString)}(.*?)${RegExp.escape(endString)}', dotAll: true); - final match = regex.allMatches(data).toList(); //TODO: Something wrong here + final match = regex.allMatches(data).toList(); return match.isNotEmpty ? match[0].group(1).toString() : null; } @@ -237,6 +235,11 @@ String uriForExampleSearch(String phrase) { return '${SCRAPE_BASE_URI}${Uri.encodeComponent(phrase)}%23sentences'; } +/* TODO: This is the wrong approach. + * Symbols such as 、「」。 are missing in mid sentence + * Maybe also JP fullwidth numbers? + */ + String getEndSymbolsOfExampleSentence(Element ul) { final endSymbols = RegExp(r'<\/li>([^<>]+)$'); return endSymbols.firstMatch(ul.innerHtml).group(1); @@ -274,7 +277,7 @@ ExampleResultData getKanjiAndKana(Element div) { kanji += unlifted; kana += unlifted; } - } else { // TODO: This doesn't catch the "。" when it's not in a tag + } else { final text = content.text.trim(); if (text != null) { kanji += text;