Test notice Division of Jekyll Theme Minimal Mistakes

Aug. 12, 2022

Introduction

My personal website1 is created based on Jekyll theme “minimal-mistakes”2. In this theme, there is a .scss file called _notices.scss3 defining a set of notice classes to stress some contents by wrapping them in the colorful box.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* ==========================================================================
   NOTICE TEXT BLOCKS
   ========================================================================== */

/**
 *  Default Kramdown usage (no indents!):
 *  <div class="notice" markdown="1">
 *  #### Headline for the Notice
 *  Text for the notice
 *  </div>
 */

@mixin notice($notice-color) {
  margin: 2em 0 !important;  /* override*/
  padding: 1em;
  color: $text-color;
  font-family: $global-font-family;
  font-size: $type-size-6 !important;
  text-indent: initial; /* override*/
  background-color: mix($background-color, $notice-color, $notice-background-mix);
  border-radius: $border-radius;
  box-shadow: 0 1px 1px rgba($notice-color, 0.25);

  h4 {
    margin-top: 0 !important; /* override*/
    margin-bottom: 0.75em;
    line-height: inherit;
  }

  @at-root .page__content #{&} h4 {
    /* using at-root to override .page-content h4 font size*/
    margin-bottom: 0;
    font-size: 1em;
  }

  p {
    &:last-child {
      margin-bottom: 0 !important; /* override*/
    }
  }

  h4 + p {
    /* remove space above paragraphs that appear directly after notice headline*/
    margin-top: 0;
    padding-top: 0;
  }

  a {
    color: mix(#000, $notice-color, 10%);

    &:hover {
      color: mix(#000, $notice-color, 50%);
    }
  }

  @at-root #{selector-unify(&, "blockquote")} {
    border-left-color: mix(#000, $notice-color, 10%);
  }

  code {
    background-color: mix($background-color, $notice-color, $code-notice-background-mix)
  }

	pre code {
		background-color: inherit;
	}

  ul {
    &:last-child {
      margin-bottom: 0; /* override*/
    }
  }
}

/* Default notice */

.notice {
  @include notice($light-gray);
}

/* Primary notice */

.notice--primary {
  @include notice($primary-color);
}

/* Info notice */

.notice--info {
  @include notice($info-color);
}

/* Warning notice */

.notice--warning {
  @include notice($warning-color);
}

/* Success notice */

.notice--success {
  @include notice($success-color);
}

/* Danger notice */

.notice--danger {
  @include notice($danger-color);
}

Way to stress only one paragraph including merely text and way to stress multiple paragraphs are sort of different; the former is very easy, while the latter is kind of complex (at least not a straightforward extension from the former). In this post, I would talk about them.


Stress one paragraph of text

It is convenient to stress only one paragraph of text, all we need is to press Shift + Enter at the end of the paragraph and add code {: .notice}. That’s it.

(1) notice class

1
2
NOTE:This is `{: .notice}` division[^3].
{: .notice}

NOTE:This is {: .notice} division3.

(2) notice--primary class

1
2
NOTE:This is `{: .notice--primary}` division[^3].
{: .notice--primary}

NOTE:This is {: .notice--primary} division3.

(3) notice--info class

1
2
NOTE:This is `{: .notice--info}` division[^3].
{: .notice--info}

NOTE:This is {: .notice--info} division3.

(4) notice--warning class

1
2
NOTE:This is `{: .notice--warning}` division[^3].
{: .notice--warning}

NOTE:This is {: .notice--warning} division3.

(5) notice--danger class

1
2
NOTE:This is `{: .notice--danger}` division[^3].
{: .notice--danger}

NOTE:This is {: .notice--danger} division3.

(6) notice--success class

1
2
NOTE:This is `{: .notice--success}` division[^3].
{: .notice--success}

NOTE:This is {: .notice--success} division3.


Stress multiple paragraphs including more elements

Method 1: use Jekyll liquid filter

If the purpose is to stress multiple paragraphs including more elements (images etc.) in a single notice, we could use liquid to capture content and then filter it with markdownify option. It is the way that offered by official sample blog of “minimal-mistakes” theme4.

For example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{% capture notice-2 %}

This is the 1st paragraph.

This is the 2nd paragraph.

This is the 3rd paragraph.

This is the text attached with a footnote[^3].

<img src="https://raw.githubusercontent.com/HelloWorld-1017/blog-images/main/imgs/202405312012650.jpg" alt="image-202405312012650" style="zoom:50%;" />

{% endcapture %}

<div class="notice--primary">{{ notice-2 | markdownify }}</div>

The result is like:

This is the 1st paragraph.

This is the 2nd paragraph.

This is the 3rd paragraph.

This is the text attached with a footnote[^3].

image-202405312012650

It looks well but one point: the footnote is plain text with no link that it should’ve had. About this point, I have no idea how to correct it.

Method 2: directly use HTML <div> tag

Another way is directly putting all contents in a <div> tag with class="$CLASS_NAME" and markdown="1"5, which is obtained from the comments of _notices.scss file3.

For example:

1
2
3
4
5
6
7
8
9
10
11
12
13
<div class="notice--primary" markdown="1">

This is the 1st paragraph.

This is the 2nd paragraph.

This is the 3rd paragraph.

This is the text attached with a footnote[^3].

<img src="https://raw.githubusercontent.com/HelloWorld-1017/blog-images/main/imgs/202405312012650.jpg" alt="image-202405312012650" style="zoom:50%;" />

</div>

The result is like:

This is the 1st paragraph.

This is the 2nd paragraph.

This is the 3rd paragraph.

This is the text attached with a footnote3.

image-202405312012650

To my mind, this method is a more obvious way and by which the footnote works normally.


References