Skip to content

An approach to parsing Org files: a state-machine inside of rg? #3013

Answered by BurntSushi
jdtsmith asked this question in General
Discussion options

You must be logged in to vote

Thanks for the question!

I don't see any obvious way of doing what you want easily with ripgrep. The closest thing ripgrep has to something like this are the --before-context and --after-context flags, but they only accept fixed integer values.

The only structure in files that ripgrep understands is lines. That is partially why it (and other tools, like GNU grep) can be as fast as they are. It is a feature that ripgrep doesn't try to understand anything more, because that winds up making the pre-processing step before searching very expensive. In contrasts, lines are a very lightweight structure that ripgrep can actually mostly "ignore" up-front, and then patch back together later.

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
8 replies
@meedstrom
Comment options

@meedstrom
Comment options

@jdtsmith
Comment options

@meedstrom
Comment options

@meedstrom
Comment options

Answer selected by jdtsmith
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants