Title: Implement methods to go backwards and look backwards inside Scanner · Issue #395 · commonmark/commonmark-java · GitHub
Open Graph Title: Implement methods to go backwards and look backwards inside Scanner · Issue #395 · commonmark/commonmark-java
X Title: Implement methods to go backwards and look backwards inside Scanner · Issue #395 · commonmark/commonmark-java
Description: 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 ...
Open Graph Description: 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 t...
X Description: 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 pars...
Opengraph URL: https://github.com/commonmark/commonmark-java/issues/395
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Implement methods to go backwards and look backwards inside Scanner","articleBody":"**Is your feature request related to a problem? Please describe.**\nI'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. \n\nThis 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 `)`.\n\n**Describe the solution you'd like**\nI 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):\n```\nval start = scanner.position() // position after the opener has been parsed\nscanner.find { char -> char.isWhitespace() } // scanner gets moved to first whitespace or very end if there is none\nscanner.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\nval end = scanner.position() \nval imageLink = scanner.getSource(start, end).getContent()\n```\n\n**Describe alternatives you've considered**\nAs 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.","author":{"url":"https://github.com/Emplexx","@type":"Person","name":"Emplexx"},"datePublished":"2025-08-18T19:43:13Z","url":"https://github.com/commonmark/commonmark-java/issues/395"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ba82a03a-abda-161b-6a69-6e435c63f6c5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8AE8:2B6B62:A218E:E082A:6AFBB7E6 |
| html-safe-nonce | 6410d01aa28a73875665be313f614119d42a2ce6b7c6c0ad8b39a116dfad6aac |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QUU4OjJCNkI2MjpBMjE4RTpFMDgyQTo2QUZCQjdFNiIsInZpc2l0b3JfaWQiOiIzNzk5MzE0NjU0MzU4NjQ4ODA3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e40b7498d07ca77abfd96dcf75dc878e6d463f4c545f1961bfe85d05a5b17db3 |
| hovercard-subject-tag | issue:3331890801 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/commonmark/commonmark-java/395/issue_layout |
| twitter:image | https://opengraph.githubassets.com/85973e1243ca243932a740faaf0606e6d4206500817f13059a43114e38f301b8/commonmark/commonmark-java/issues/395 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/85973e1243ca243932a740faaf0606e6d4206500817f13059a43114e38f301b8/commonmark/commonmark-java/issues/395 |
| og:image:alt | 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 t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Emplexx |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2b2ef9c1578c18d8ed27027940544c958743213cf4461659f14d3ccdf51e162c |
| turbo-cache-control | no-preview |
| go-import | github.com/commonmark/commonmark-java git https://github.com/commonmark/commonmark-java.git |
| octolytics-dimension-user_id | 8661225 |
| octolytics-dimension-user_login | commonmark |
| octolytics-dimension-repository_id | 39477878 |
| octolytics-dimension-repository_nwo | commonmark/commonmark-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 39477878 |
| octolytics-dimension-repository_network_root_nwo | commonmark/commonmark-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e4cce0e99cf61481a318ff12c2e8580153a6c7c6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width