Implement methods to go backwards and look backwards inside Scanner
まだ誰も着手していません。
評価
調査の方向性
Scanner のエントリーポイントから始め、issue に記載されている既存の next と find の動作を比較します。要求どおりに scanner の位置を更新する後方相当の機能を、範囲を限定した検索動作を含めて定義し、image-link のパースのユースケースで期待される範囲を取得できることを検証します。
索引モデルが issue の本文から書いたものです。
説明
Is your feature request related to a problem? Please describe.
I'm trying to implement an InlineContentParser for images from a custom markdown spec from a certain website. Given I already parsed the opener, the spec requires me to look for the first whitespace character or end of text, then going backwards from there, look for the first ). Everything between the opener and ) is considered the image link.
This is a bit annoying to implement with the current limited set of methods Scanner has, and I also imagine the performance would be worse when instead of going backwards from the closer, you go forward from the opener via scanner.find(')') and perform an additional find to see if you just found the last ).
Describe the solution you'd like
I would like for there to be similar methods to next and find that would instead look back from the current Scanner position, i.e prev, and findPrev. Then I could just do the following (sorry that the code is in Kotlin as I don't regularly write Java, I hope the intent is clear):
val start = scanner.position() // position after the opener has been parsed
scanner.find { char -> char.isWhitespace() } // scanner gets moved to first whitespace or very end if there is none
scanner.findPrev(')') // scanner gets moved backwards until the position is at ')'. Ideally there would also be an overload that takes a position until which it should move, so i could pass the `start` to it and it would early exit if it doesn't find one by then
val end = scanner.position()
val imageLink = scanner.getSource(start, end).getContent()
Describe alternatives you've considered
As stated above I have considered iterating forward from the current position to find the next ) and check if there's another one to see if I'd found the last one.
- 主要言語
- Java
- スター
- 2.7k
- フォーク
- 337
- 平均マージ
- 15日 9時間
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
commonmark/commonmark-java のほかの issue
-
Unclosed link reference definition title keeps the partial title and the following paragraph's source spans (0.30.0)対応中かも @sean0407 が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
commonmark/commonmark-java#460 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 74/100
commonmark/commonmark-java#457 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
commonmark/commonmark-java#443 · コメント 4 件 ·
-
Option to define custom flanking/canOpen/canClose rules for delimiters再び着手できるかも @abhiramaab が 61 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンenhancement
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
commonmark/commonmark-java#428 · コメント 4 件 ·
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
commonmark/commonmark-java#414 · コメント 1 件 · リアクション 1 件 ·
commonmark/commonmark-java の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
quelea-projection/Quelea#711 ·
-
bug pdd
難易度 2/5 1時間未満 初心者へのやさしさ 67/100
objectionary/eo#9450 ·
メンテナーはふだん 1 日以内に返信
-
[EC2] DescribeAvailabilityZones should return real AWS error for unknown zone name対応中かも @omatheusmesmo が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
area: core good first issue type: enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ShaftHQ/SHAFT_ENGINE#6909 ·
メンテナーはふだん 1 日以内に返信