Mr0grog / google-docs-to-markdown

A minimal webapp for converting Google Docs to Markdown
https://gdoc2md.com
BSD 3-Clause "New" or "Revised" License
201 stars 37 forks source link

Remove redundant backticks around monospaced text #74

Open Mr0grog opened 1 year ago

Mr0grog commented 1 year ago

Because of Markdown’s popularity, a lot of people have taken to the convention of surrounding code-like text with backticks in Google Docs. For example:

Screenshot of backtick-surrounded text

(From https://docs.google.com/document/d/1cpzIK-BdP7u6RJSar-Z955GV--2Rj8V4x2vl34m36Go)

If the text is also monospaced, we already convert it “code” and wind up with a lot of messy, redundant backticks in the resulting markdown, like:

It’s a plain JavaScript file with `` `.jsm` `` file extension, and `` `EXPORTED_SYMBOLS` `` global variable

Ideally, we should remove these backticks. This should work whether the backticks are monospaced or they are just outside the monospaced text.

(Another nice thing to do might be to detect short runs of backtick-surrounded text and make them code. Right now we only detect monospaced text as code.)

JCardona0110 commented 1 year ago

Hi there! If possible I'd like to be assigned this issue.

Mr0grog commented 1 year ago

Done! Thanks for taking it on.

JCardona0110 commented 1 year ago

hi there, here is the google doc link, is this what you wanted? I think I've been overthinking this and have put it off in fear of doing it wrong so apologies for how long it's been since this got assigned.. let me know how it looks! https://docs.google.com/document/d/1IGdixvVQwdLlaE5nz_Y3l8uUaU9XOJL7BHkNMI6cdcc/edit?usp=sharing

Mr0grog commented 1 year ago

Hmmm, I think there may have been some miscommunication here. The doc you linked looks like a copy of the doc I originally referenced, but I’m not sure what you might have changed in it. Either way, this is a really big and complex doc that covers a lot more stuff than I intended this issue to be about!

I was thinking about a doc like this one: https://docs.google.com/document/d/13mZmi-5oR0J2TPkfngMKtPmQ4raizLfUVTQ2ZUCKU30

Screenshot of demo documented linked above

It currently converts to this markdown:

This is a test of redundant/literal backticks that should be removed.

Sometimes people surround code with literal backticks: \``code`\`

Or with backticks inside the code: `` `code` ``

But this issue is about converting it to this instead:

This is a test of redundant/literal backticks that should be removed.

Sometimes people surround code with literal backticks: `code`

Or with backticks inside the code: `code`

Also, feel free use the doc I linked here as a test case. To add it as a fixture, add a reference to it in scripts/download-fixtures.js: https://github.com/Mr0grog/google-docs-to-markdown/blob/7df0eae26c6349fce6a61d8ac66733732daf4d30/scripts/download-fixtures.js#L11-L20

Then run npm run download-fixtures to download the doc as a fixture.

And finally add a test for it in test/unit/convert.test.js (you can just copy the two lines for one of the other tests, and change the first argument of createFixtureTest() to use whatever name you set for the fixture in the first step: https://github.com/Mr0grog/google-docs-to-markdown/blob/7df0eae26c6349fce6a61d8ac66733732daf4d30/test/unit/convert.test.js#L19-L20

(Every fixture gets two tests: one for the content you’d get from copy & pasting and one for the the content you’d get if you exported the Google Doc as HTML. But the export one gets skipped because there is some complicated stuff in exports that we don’t support yet. It’s just there for whenever someone starts working on #60.)

After all that, you can actually run the tests with: npm run test-unit. If you only want to run a test in one browser (nicer during initial development), you can do: BROWSERS=chrome npm run test-unit.

Mr0grog commented 1 year ago

@JCardona0110 are you still able to work on this, or should I un-assign it?

JCardona0110 commented 1 year ago

I think it's not something I can handle at the moment, please unassign and thanks for your patience.

On Fri, Aug 11, 2023, 6:35 PM Rob Brackett @.***> wrote:

@JCardona0110 https://github.com/JCardona0110 are you still able to work on this, or should I un-assign it?

— Reply to this email directly, view it on GitHub https://github.com/Mr0grog/google-docs-to-markdown/issues/74#issuecomment-1675475742, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7OW2ESL2YGJSMNN4JNQQI3XU2XRLANCNFSM6AAAAAAZ2JWVXI . You are receiving this because you were mentioned.Message ID: @.***>

Mr0grog commented 1 year ago

OK, done.