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

Add dynamic code block highlighting documentation #1626

Merged
merged 2 commits into from
Aug 27, 2021
Merged

Add dynamic code block highlighting documentation #1626

merged 2 commits into from
Aug 27, 2021

Conversation

gadhagod
Copy link
Contributor

Summary

Small documentation change that shows how to highlight javascript-created code blocks in docsify.

What kind of change does this PR introduce?

Docs

For any code change,

  • Related documentation has been updated if needed
  • Related tests have been updated or tests have been added

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:

Tested in the following browsers:

  • Chrome
  • Firefox
  • Safari
  • Edge
  • IE

@vercel
Copy link

vercel bot commented Aug 19, 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/E2hU1fuYRKHjcuBd2BGy291C87EH
✅ Preview: https://docsify-preview-git-fork-gadhagod-develop-docsify-core.vercel.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 19, 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 94ea16e:

Sandbox Source
docsify-template Configuration

@Koooooo-7
Copy link
Member

Looks cool, but I find that the ode.setAttribute("class", "lang-bash"); seems not works fine ( it is set to javascript instead).
image

@gadhagod
Copy link
Contributor Author

That code block actually shows how to create a 'code' element and highlight it. It's not a demo of this though, and it's written in JavaScript. If u want, I can add a demo too (you click a button, adds some highlighted code block to page).

@Koooooo-7
Copy link
Member

That code block actually shows how to create a 'code' element and highlight it. It's not a demo of this though, and it's written in JavaScript. If u want, I can add a demo too (you click a button, adds some highlighted code block to page).

yea, what I meant is that the

ode.setAttribute("class", "lang-bash")

should render this code as bash.
but it is a javascript signal on the top right corner of the code block as I showed the pic above.

@gadhagod
Copy link
Contributor Author

Oh I misunderstood your comment @Koooooo-7. This is probably because you need a pre element wrapping around the code element.
Here is an example jist. When you click the button, it adds a highlighted code block to the page: https://gist.github.com/gadhagod/1287c210e8410080a00f55206fcdcc42.

@gadhagod
Copy link
Contributor Author

SInce you need an external Prism script to include bash in recognizable languages, I'll change the language of this example to javascript.

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.

LGTM.

@Koooooo-7 Koooooo-7 requested a review from a team August 27, 2021 07:49
@Koooooo-7 Koooooo-7 merged commit 72485a3 into docsifyjs:develop Aug 27, 2021
@Koooooo-7 Koooooo-7 mentioned this pull request Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants