simonw / datasette-ripgrep

Web interface for searching your code using ripgrep, built as a Datasette plugin
https://ripgrep.datasette.io
Apache License 2.0
72 stars 1 forks source link

Copy results as Markdown feature #24

Open simonw opened 3 years ago

simonw commented 3 years ago

I often find myself using this tool to find examples of something that needs to be changed - so being able to copy and paste the results of a search into a GitHub issue as markdown would be really useful.

Example where I could have benefited from this: https://github.com/simonw/datasette/issues/1432#issuecomment-898079507

simonw commented 3 years ago

Ideally this would include copying permalinks to the source code on GitHub, but I don't currently have enough information to calculate those since the plugin doesn't have a way to know which GitHub repo (and which exactly SHA1 hash) the code it is searching refers to.

simonw commented 3 years ago

If this is GitHub flavored markdown I can do this:

<ol start="93">
  <li><code>@pytest.mark.asyncio</code></li>
  <li><code>async def test_notebook_no_csv(db_path)</code></li>
  <li><code><strong>&nbsp;&nbsp;&nbsp;&nbsp;datasette = Datasette([db_path], config={"allow_csv_stream": False})</code></strong></li>
  <li><code>&nbsp;&nbsp;&nbsp;&nbsp;response = await datasette.client.get("/db/big.Notebook")</code></li>
  <li><code>&nbsp;&nbsp;&nbsp;&nbsp;assert ".csv" not in response.text</code></li>
</ol>

Renders as:

  1. @pytest.mark.asyncio
  2. async def test_notebook_no_csv(db_path)
  3.     datasette = Datasette([db_path], config={"allow_csv_stream": False})
  4.     response = await datasette.client.get("/db/big.Notebook")
  5.     assert ".csv" not in response.text
simonw commented 3 years ago

Maybe the options are copy as plaintext and copy as GitHub flavored markdown.