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

Use highlight.js to add syntax highlighting to the generated HTML documents. #68

Merged
merged 2 commits into from
Nov 17, 2020

Conversation

zoze0
Copy link
Contributor

@zoze0 zoze0 commented Nov 16, 2020

Use highlight.js to add syntax highlighting to the generated HTML documents.
Users can configure the style option in the smart-doc configuration file (optional).
Style values:

  1. No configuration: default style
  2. Configure a specific value (95 options available): refer to https://www.fenxianglu.cn/highlight.html
  3. randomLight: randomly selects a light-colored style
  4. randomDark: randomly selects a dark-colored style
  5. random: randomly selects a style

Effect:
aa_20201116214711

@zoze0
Copy link
Contributor Author

zoze0 commented Nov 16, 2020

If there are any issues that cannot be merged, please point them out so I can make revisions.

@zoze0 zoze0 changed the title Dev 使用hightlight.js为生成的html文档增加代码高亮 Nov 17, 2020
Copy link
Collaborator

@shalousun shalousun left a comment

Choose a reason for hiding this comment

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

ok

@shalousun shalousun merged commit 61d25f8 into TongchengOpenSource:dev Nov 17, 2020
@shalousun
Copy link
Collaborator

shalousun commented Nov 17, 2020

@jetmit The code is fine, but there are two issues:

  • The default theme's font highlight color is straining to the eyes against the current background in the code blocks.
  • After switching to other themes, the borders of the code snippets appear too abrupt.
    Smart-doc itself, in the process of modifying templates sourced from the internet, was not intended to chase glamour. I personally favor a minimalist design approach; the greatest advantage of this style is its simplicity without sacrificing aesthetics. Many users have also been able to appreciate this point.

@zoze0
Copy link
Contributor Author

zoze0 commented Nov 18, 2020

The border of the code snippet was originally a 1em padding in the code block, which I found too wide and changed to 0.375; because the color differs from the highlight color, it appears as a border.

I also prefer a minimalist and elegant design; however, when the documentation is sent to front-end developers, they feel it's somewhat plain. Therefore, I wanted to add code highlighting, which also makes the structure clearer.
Personally, I think using a light style theme overall remains simple without being overly flashy ^_^

We can continue to adjust and optimize going forward, enhancing the code block section for better completeness.

@zoze0
Copy link
Contributor Author

zoze0 commented Nov 21, 2020

@jetmit The code is fine, but there are two issues:

  • The default theme's font highlighting color is straining to the eyes against the current background in the code blocks.
  • After switching to other themes, the borders of the code snippets appear too abrupt.
    Smart-doc itself, in the process of modifying templates sourced from the internet, was not intended to chase glamour. I personally favor a minimalist design approach; the greatest advantage of this style is its simplicity without sacrificing aesthetics. Many users have also been able to appreciate this point.

The original code block background was F7F7F8, and the added default GitHub theme background is F8F8F8, which looks identical to the naked eye. The white background with borders shown in the screenshot above is a random other style, not the default.
Removing the padding from the code blocks will eliminate the borders; use the colors from highlight.js instead.

--
I just noticed that the method for removing borders has already been changed. Let's leave it as it is for now.

@shalousun shalousun changed the title 使用hightlight.js为生成的html文档增加代码高亮 Use highlight.js to add syntax highlighting to the generated HTML documents. Jul 3, 2024
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.

2 participants