Replies: 4 comments 3 replies
-
I didn't know if this was worth a theme change, so I didn't submit a PR and just shared it as an idea. But this has a serious disadvantage. It is more troublesome to type every time. If you have any suggestions on how to improve it, I will be grateful. |
Beta Was this translation helpful? Give feedback.
-
I think it would be best to be compatible with GitHub alerts. |
Beta Was this translation helpful? Give feedback.
-
Personally, I don't like inserting HTML tags in markdown files. Instead I prefer IAL. e.g.:
This will be built as: <blockquote class="box-info">
<p class="title">Shakespeare</p>
<p>To be or not to be. That is a question.</p>
</blockquote> |
Beta Was this translation helpful? Give feedback.
-
@NichtsHsu Thanks. In fact, I don't like to insert too many HTML tags into Markdown either. The I referred to the plugin @zhang-nianqiang provided, and using Liquid markup language to create HTML tags should be a better choice. Creat a new file in module Jekyll
class ColorBoxes < Liquid::Block
def initialize(tag_name, markup, tokens)
super
# Check if the markup contains a space, indicating both tag type and title
if markup.strip.include?(" ")
@box_type, @title = markup.strip.split(" ", 2)
@title = @title&.gsub(/^"(.*)"$/, '\1')
else
# If no space, treat the markup as only tag type and set title to nil
@box_type = markup.strip
@title = nil
end
end
def render(context)
content = super
# Generate HTML for the title if it exists, otherwise leave it empty
title_html = @title ? "<div class=\"title\">#{@title}</div>" : ""
# Render the appropriate box type with the title HTML and content
case @box_type
when "info"
"<div class=\"box-info\" markdown=\"1\">#{title_html}#{content}</div>"
when "tip"
"<div class=\"box-tip\" markdown=\"1\">#{title_html}#{content}</div>"
when "warning"
"<div class=\"box-warning\" markdown=\"1\">#{title_html}#{content}</div>"
when "danger"
"<div class=\"box-danger\" markdown=\"1\">#{title_html}#{content}</div>"
else
# If the tag type is unknown, it renders without any additional styling
end
end
end
end
Liquid::Template.register_tag('box', Jekyll::ColorBoxes) Then just enter the Liquid tags in a markdown file, e.g. : {% box info "Shakespeare" %}
To be or not to be. That is a question.
{% endbox %}
{% box tip "Shakespeare" %}
To be or not to be. That is a question.
{% endbox %}
{% box warning "Shakespeare" %}
To be or not to be. That is a question.
{% endbox %}
{% box danger "Shakespeare" %}
> To be or not to be. That is a question.
> --- Shakespeare
$$x^2 + y^2 =z^2$$
{% endbox %}
{% box info %}
To be or not to be. That is a question.
{% endbox %}
{% box tip %}
To be or not to be. That is a question.
{% endbox %}
{% box warning %}
To be or not to be. That is a question.
{% endbox %}
{% box danger %}
To be or not to be. That is a question.
{% endbox %} The results they produce are the same as the pictures I provided at the beginning. What do you think these changes? |
Beta Was this translation helpful? Give feedback.
-
The author has designed 4 prompts, but their styles are relatively simple, so I designed 4 new prompts (or colorboxes, alerts). Because you know, there are really many definitions, theorems and propositions in mathematics.
You can find a mathematics note I wrote here to see the effect.
SCSS
You can add the following code to the file
assets/css/jekyll-theme-chirpy.scss
:Examples
You can use html in your post (
.md
file), see the following examples:Of course you can also delete the title:
The specific effect can be seen in the following figures:
Anything else?
Fix #1195.
Beta Was this translation helpful? Give feedback.
All reactions