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

fix: allow also " inside of an embed #1598

Merged
merged 3 commits into from
Jun 25, 2021
Merged

fix: allow also " inside of an embed #1598

merged 3 commits into from
Jun 25, 2021

Conversation

luwol03
Copy link
Contributor

@luwol03 luwol03 commented Jun 22, 2021

Summary

I fixed a bug where ":include" is not handled like ':include'. This is not working because the type of quotes are not supported. The default prettier configuration changes the '' to "". And if you have auto format toggled on, you're not be able to save the file with the right quotes.

What kind of change does this PR introduce?

I added added the " also the the replace regex

str = str
      .replace(/^('|")/, '')
      .replace(/('|")$/, '')

For any code change,

  • Related documentation has been updated if needed
  • Related tests have been updated or tests have been added (I cant find some tests for that already.)

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

Related issue, if any:

closes #1597
closes #1587
closes #1555
closes #1005

Tested in the following browsers:

  • Chrome
  • Firefox
  • Safari
  • Edge
  • IE

@vercel
Copy link

vercel bot commented Jun 22, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/docsify-core/docsify-preview/BJiGEnyE33rV1Pzk3UTtre7AHZqb
✅ Preview: https://docsify-preview-git-fork-luwol03-issue-1597-118886-docsify-core.vercel.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 22, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 633f241:

Sandbox Source
docsify-template Configuration
docsify-template (forked) Issue #1597

Copy link
Member

@sy-records sy-records left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for this?

@Koooooo-7 Koooooo-7 self-requested a review June 23, 2021 11:35
Copy link
Member

@Koooooo-7 Koooooo-7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sy-records
As we all know, this func getAndRemoveConfig has been used for much places.
It seems we need separate it for different functions in case of unpredicted issues.
WDTY?

@sy-records
Copy link
Member

Yes, you're right.

@trusktr
Copy link
Member

trusktr commented Jun 24, 2021

It seems we need separate it for different functions in case of unpredicted issues.

@Koooooo-7 What do you mean?

@Koooooo-7
Copy link
Member

It seems we need separate it for different functions in case of unpredicted issues.

@Koooooo-7 What do you mean?

This func r working in multi place to get configs. such as titles , sidebar headings.
If we add " for embed files, it might cause other problems in other places.
so, we may need separate this func , for sidebar, for titles and for embed files.

@trusktr
Copy link
Member

trusktr commented Jun 25, 2021

@Koooooo-7 I see what you're saying, although it seems very unlikely. My guess would be that there is no one relying on he non-working double quotes.

It seems multiple people have hit this issue, and we closed the issues. It was in fact working before, then it broke:

@Koooooo-7
Copy link
Member

Koooooo-7 commented Jun 25, 2021

@trusktr I checked this func history, it seems never support the " before, the docs either.
You could check this func since Dec 5, 2018 and earlier.
If we support it right now, it would remove the " in other places also.
So, I prefer to separate this func.

@luwol03
Copy link
Contributor Author

luwol03 commented Jun 25, 2021

Can you add a test for this?

sure, will try that.

It seems we need separate it for different functions in case of unpredicted issues.

@Koooooo-7 What do you mean?

This func r working in multi place to get configs. such as titles , sidebar headings.
If we add " for embed files, it might cause other problems in other places.
so, we may need separate this func , for sidebar, for titles and for embed files.

I dont think so. I would also like to use the double ones inside of headlines, or other stuff. Everywhere I can use this style.

And another question, do you prefere an clean commit history, so should I rebase merge upstream changes?

@Koooooo-7
Copy link
Member

Koooooo-7 commented Jun 25, 2021

@luwol03 of cuz we can support this feat for those configs. instead, how about those titles/other stuff without configs but with " ?
e.g a title this is "my title".

@luwol03
Copy link
Contributor Author

luwol03 commented Jun 25, 2021

@luwol03 of cuz we can support this feat for those configs. instead, how about those titles/other stuff without configs but with " ?
e.g a title this is "my title".

Then we should improve the function, so that it only replaces the quotes, if they are followed by a :xxxx and there is also a closing one.

@Koooooo-7
Copy link
Member

Koooooo-7 commented Jun 25, 2021

@luwol03 of cuz we can support this feat for those configs. instead, how about those titles/other stuff without configs but with " ?
e.g a title this is "my title".

Then we should improve the function, so that it only replaces the quotes, if they are followed by a :xxxx and there is also a closing one.

agreed.
If possible, glad to see a good solution for this func/regx to solve those issues above.
I tested some cases locally again, it seems not break something (suppose I haven't missed something.). I think it's okay for now.

@luwol03
Copy link
Contributor Author

luwol03 commented Jun 25, 2021

Is this normal, that your e2e tests failed?

@Koooooo-7
Copy link
Member

Is this normal, that your e2e tests failed?

It seems not this changes broken, it's okay.
I would retry it.

@trusktr
Copy link
Member

trusktr commented Jun 25, 2021

If we support it right now, it would remove the " in other places also.

@Koooooo-7 can you point them out for us?

ESIT: Oh NVM, i see you checked already and think it is fine.

@trusktr
Copy link
Member

trusktr commented Jun 25, 2021

Is this normal, that your e2e tests failed?

Sometimes it fails for some reason despite that it shouldn't. Needs a fix.

@luwol03
Copy link
Contributor Author

luwol03 commented Jun 25, 2021

Before merge, I will try that:

Then we should improve the function, so that it only replaces the quotes, if they are followed by a :xxxx and there is also a closing one.

@trusktr
Copy link
Member

trusktr commented Jun 25, 2021

Before merge, I will try that:

Then we should improve the function, so that it only replaces the quotes, if they are followed by a :xxxx and there is also a closing one.

Is anyone using it without the : like "foo :bar"? Seems like it should be a space-separated set of anything.

@trusktr
Copy link
Member

trusktr commented Jun 25, 2021

Here is an example without the colon: #1587 (comment)

Without a colon means to set a class I believe. Nvm, i don't see a mention in the docs.

str: `[filename](_media/example.md ":include")`,
});
});
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder what the behavior should actually be. Seems funky that it leaves things behind. Seems like it should handle everything.

@trusktr
Copy link
Member

trusktr commented Jun 25, 2021

@jhildenbiddle One test or other keeps randomly failing.

@trusktr
Copy link
Member

trusktr commented Jun 25, 2021

Investigating the failures. Let's not merge until we know it isn't the change from here. Seems unlikely that it is.

Copy link
Member

@trusktr trusktr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I'm not requesting any changes, just blocking from merging to ensure the test is just flaky (that's what it seems like).

@trusktr
Copy link
Member

trusktr commented Jun 25, 2021

I re-ran the test like 6 times already, and one (at random) still keeps failing.

@trusktr
Copy link
Member

trusktr commented Jun 25, 2021

improve the function, so that it only replaces the quotes, if they are followed by a :xxxx and there is also a closing one.

I don't think we should do that, it could break this: "this-is-currently-ignored :but=this-currently-works". If we do, it can be a new PR.

Thanks @luwol03! Merging, since tests pass except one at random, which seems unrelated.

@trusktr trusktr merged commit 74f17a0 into docsifyjs:develop Jun 25, 2021
@trusktr trusktr mentioned this pull request Jun 25, 2021
@luwol03
Copy link
Contributor Author

luwol03 commented Jun 26, 2021

Oh, A few seconds ago, I pushed my changes, before I relized, that you already merged this changes 😂

Can you please take a look at my new commit? @trusktr Should I open a new PR for that?

@sy-records
Copy link
Member

@luwol03 You can open a new PR

@luwol03
Copy link
Contributor Author

luwol03 commented Jun 28, 2021

@luwol03 You can open a new PR
@sy-records done - see #1603

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants