Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant backticks around monospaced text #74

Open
Mr0grog opened this issue Jun 30, 2023 · 7 comments
Open

Remove redundant backticks around monospaced text #74

Mr0grog opened this issue Jun 30, 2023 · 7 comments
Labels
enhancement New feature or request help wanted Extra attention is needed output formatting

Comments

@Mr0grog
Copy link
Owner

Mr0grog commented Jun 30, 2023

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.)

@Mr0grog Mr0grog added enhancement New feature or request help wanted Extra attention is needed output formatting labels Jun 30, 2023
@JCardona0110
Copy link

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

@Mr0grog
Copy link
Owner Author

Mr0grog commented Jul 14, 2023

Done! Thanks for taking it on.

@JCardona0110
Copy link

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
Copy link
Owner Author

Mr0grog commented Aug 3, 2023

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:

const FIXTURES = {
'code-blocks': '1sgDx9lNbL3B7EWBKjpsAaBVIsJAEErfv8uggAFshn3I',
'code-blocks-mixed': '1D56ytnyzkCG-OSn6m83B5JxPjwgZ05iSSUUbLuYzmzc',
'code-inline': '1bEp38sjESFK8q1PLwfesZgNDMwEsqeGulaq4Vb7r9IA',
'headings-and-paragraphs': '1Dm5DIHOVAvsGYgTaPuhq78PefT_5u10RFsRBxunxBtQ',
'inline-formatting': '1-0E8y62m1tI6MWYYbGcbBALylL9hT9Toq9SssCeT-Ew',
'lists': '1bZI3NwaasFZGexGQG9YC07UAovpY9b_mfdI2_KgT8-0',
'list-item-level-styling': '10W_0kk4mBViHMIahKcg4WwBu-HLCyw12BG7NC2lyuA8',
'tables': '1sdDeTF4uEwAlp6VDx_Jk_yJYS0wtnOWj0J63aSU3zsQ',
};

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:

createFixtureTest('code-inline', { type: 'copy' });
createFixtureTest('code-inline', { type: 'export', skip: true });

(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
Copy link
Owner Author

Mr0grog commented Aug 11, 2023

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

@JCardona0110
Copy link

JCardona0110 commented Aug 12, 2023 via email

@Mr0grog
Copy link
Owner Author

Mr0grog commented Aug 13, 2023

OK, done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed output formatting
Projects
None yet
Development

No branches or pull requests

2 participants