simonw/datasette-ripgrep

Copy results as Markdown feature

simonw opened this issue · 3 comments

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: simonw/datasette#1432 (comment)

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.

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

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