Implement methods to go backwards and look backwards inside Scanner
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 38/100
Direzione di ricerca
Inizia dal punto di ingresso di Scanner e confronta il comportamento esistente di next e find descritto nell’issue. Definisci equivalenti all’indietro che aggiornino la posizione dello scanner come richiesto, incluso il comportamento di ricerca limitata, e verifica che il caso d’uso di parsing di image-link possa ottenere l’intervallo previsto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Java
- Stelle
- 2.7k
- Fork
- 336
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di commonmark/commonmark-java
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
commonmark/commonmark-java#460 ·
-
Second code span not recognised after an unclosed backtick string and another code spanForse già presa @TanbirRamim l’ha presa 13 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
commonmark/commonmark-java#458 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 74/100
commonmark/commonmark-java#457 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
commonmark/commonmark-java#443 · 4 commenti ·
-
Option to define custom flanking/canOpen/canClose rules for delimitersForse di nuovo libera @abhiramaab l’ha presa 57 giorni fa e non c’è nessuna pull request aperta. Apertaenhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
commonmark/commonmark-java#428 · 4 commenti ·
Tutte le issue di commonmark/commonmark-java
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
liquid-java/liquidjava#373 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
NationalSecurityAgency/ghidra#9748 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
spring-mcp-tools
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
explyt/spring-plugin#591 ·
I maintainer di solito rispondono entro 1 giorno