@readme/markdown 6.75.0-beta.8 → 6.75.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,7 +18,7 @@ function getHref(href, baseUrl) {
18
18
 
19
19
  const ref = path.match(/^ref:([-_a-zA-Z0-9#]*)$/);
20
20
  if (ref) {
21
- return `${base}/reference-link/${ref[1]}${hashStr}`;
21
+ return `${base}/reference/${ref[1]}${hashStr}`;
22
22
  }
23
23
 
24
24
  // we need to perform two matches for changelogs in case
@@ -6,12 +6,12 @@ const Callout = props => {
6
6
  const [title, ...content] = !props.title ? [null, props.children] : props.children;
7
7
 
8
8
  return (
9
- // eslint-disable-next-line react/jsx-props-no-spreading
9
+ // eslint-disable-next-line react/jsx-props-no-spreading, react/no-unknown-property
10
10
  <blockquote {...attributes} className={`callout callout_${theme}`} theme={icon}>
11
- <h3 className={`callout-heading${title ? '' : ' empty'}`}>
11
+ <h2 className={`callout-heading${title ? '' : ' empty'}`}>
12
12
  <span className="callout-icon">{icon}</span>
13
13
  {title}
14
- </h3>
14
+ </h2>
15
15
  {content}
16
16
  </blockquote>
17
17
  );
@@ -1,81 +1,104 @@
1
- @mixin callout ($l-offset: 1.33rem) {
1
+ /* stylelint-disable no-descending-specificity */
2
+ /* stylelint-disable font-family-no-missing-generic-family-keyword */
3
+ /* stylelint-disable order/properties-alphabetical-order */
4
+ /* stylelint-disable order/order */
5
+ @mixin callout($l-offset: 1.33rem) {
2
6
  --background: #{lighten(#dfe2e5, 8.75%)};
3
7
  --border: #{lighten(#6a737d, 12.5%)};
4
8
 
5
- & {
6
- background: var(--background);
7
- border-color: var(--border);
8
- color: var(--text);
9
- padding: $l-offset;
10
- }
9
+ background: var(--background);
10
+ border-color: var(--border);
11
+ color: var(--text);
12
+ padding: $l-offset;
11
13
 
12
14
  &_info {
13
15
  $color: #46b8da;
16
+
14
17
  --background: #e3edf2;
15
18
  --title: #{$color};
16
19
  --border: #{lighten($color, 5%)}; // should be #5bc0de
17
20
  }
18
21
 
19
- &_warn, &_warning {
22
+ &_warn,
23
+ &_warning {
20
24
  $color: #eea236;
25
+
21
26
  --background: #fcf8f2;
22
27
  --title: #{$color};
23
28
  --border: #{lighten($color, 5%)};
24
29
  }
25
30
 
26
- &_ok, &_okay, &_success {
31
+ &_ok,
32
+ &_okay,
33
+ &_success {
27
34
  $color: #489e49;
35
+
28
36
  --background: #f3f8f3;
29
37
  --title: #{$color};
30
38
  --border: #{lighten($color, 5%)}; // should be #50af51
31
39
  }
32
40
 
33
- &_err, &_error {
41
+ &_err,
42
+ &_error {
34
43
  $color: #d43f3a;
44
+
35
45
  --background: #fdf7f7;
36
46
  --title: #{$color};
37
- --border: #{lighten($color, 5%)}; // should be #d9534f
47
+ --border: #{lighten($color, 5%)}; // should be #d9534f
38
48
  }
39
49
 
40
50
  > * {
41
51
  margin-left: $l-offset;
42
52
  position: relative;
43
53
  }
44
- ul, ol {
54
+
55
+ ul,
56
+ ol {
45
57
  padding-left: 1.3em;
46
58
  }
47
59
 
48
60
  a {
49
61
  color: inherit;
50
62
  }
63
+
51
64
  hr {
52
65
  border-color: var(--border, var(--markdown-edge, #eee));
53
66
  }
67
+
54
68
  blockquote {
55
69
  color: var(--text);
56
70
  border-color: var(--border);
57
71
  border-width: 3px;
58
- padding: 0 0 0 .8em;
72
+ padding: 0 0 0 0.8em;
59
73
  }
60
74
 
61
75
  .callout-heading {
62
76
  color: var(--title, --text);
63
- margin-bottom: calc(#{$l-offset} * .5);
77
+ font-size: 1.25em; // match h3
78
+ font-family: var(--markdown-title-font); // match h3
79
+ font-weight: var(--markdown-title-weight, 600); // match h3
80
+ line-height: 1.25; // match h3
81
+ margin-bottom: calc(#{$l-offset} * 0.5);
82
+
64
83
  &:only-child {
65
84
  margin-bottom: 0;
66
85
  }
86
+
67
87
  &.empty {
68
88
  float: left;
69
- margin-top: calc(#{$l-offset} * .5);
89
+ margin-top: calc(#{$l-offset} * 0.5);
90
+
70
91
  .callout-icon {
71
92
  line-height: 0;
72
93
  }
73
94
  }
95
+
74
96
  > * {
75
97
  color: inherit;
76
98
  margin: 0;
77
99
  }
78
- &:before {
100
+
101
+ &::before {
79
102
  position: absolute;
80
103
  right: 100%;
81
104
  width: 2.4em;
@@ -83,20 +106,24 @@
83
106
  font: normal normal normal 1em/1 FontAwesome;
84
107
  }
85
108
  }
109
+
86
110
  .callout-icon {
87
111
  float: left;
88
- margin-left: calc(-#{$l-offset} - .5em);
89
- margin-right: -.25rem;
112
+ margin-left: calc(-#{$l-offset} - 0.5em);
113
+ margin-right: -0.25rem;
90
114
  }
91
115
  }
92
- @mixin calloutCustomIcons($R: callout) {
116
+
117
+ @mixin callout-custom-icons($R: callout) {
93
118
  --emoji: 1em;
94
- --icon-font: FontAwesome;
119
+ --icon-font: fontawesome;
120
+
95
121
  &-icon {
96
122
  font-size: var(--emoji, 0);
97
123
  color: var(--icon-color, inherit) !important;
98
124
  }
99
- &-icon:before {
125
+
126
+ &-icon::before {
100
127
  content: var(--icon);
101
128
  font-family: var(--icon-font);
102
129
  font-size: var(--icon-size, 1rem);
@@ -109,24 +136,30 @@
109
136
  -webkit-font-smoothing: antialiased;
110
137
  -moz-osx-font-smoothing: grayscale;
111
138
  }
139
+
112
140
  @at-root .rdmdCallouts--useIconFont & {
113
141
  --emoji: unset;
142
+
114
143
  &_okay {
115
144
  /* thumbs up */
116
- --icon: "\f164";
145
+ --icon: '\f164';
117
146
  }
147
+
118
148
  &_info {
119
149
  /* info circle */
120
- --icon: "\f05a";
150
+ --icon: '\f05a';
121
151
  }
152
+
122
153
  &_warn {
123
154
  /* warning triangle */
124
- --icon: "\f071";
155
+ --icon: '\f071';
125
156
  }
157
+
126
158
  &_error {
127
159
  /* warning circle */
128
- --icon: "\f06a";
160
+ --icon: '\f06a';
129
161
  }
162
+
130
163
  &_default {
131
164
  /* warning circle */
132
165
  --emoji: 1rem;
@@ -135,10 +168,13 @@
135
168
  }
136
169
 
137
170
  .callout {
138
- &.callout { // bump specificity
171
+ &.callout {
172
+ // bump specificity
139
173
  @include callout;
140
174
  }
141
- @include calloutCustomIcons;
175
+
176
+ @include callout-custom-icons;
177
+
142
178
  border-top-right-radius: var(--markdown-radius);
143
179
  border-bottom-right-radius: var(--markdown-radius);
144
180
  }
@@ -63,6 +63,8 @@ function Code(props) {
63
63
  data-lang={language}
64
64
  name={meta}
65
65
  suppressHydrationWarning={true}
66
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
67
+ tabIndex={0}
66
68
  >
67
69
  {codeContent}
68
70
  </code>
@@ -1,21 +1,27 @@
1
- @mixin gfmCodeBaseStyles($background: #F6F8FA, $background-dark: #242E34, $text: inherit) {
2
-
1
+ /* stylelint-disable no-duplicate-selectors */
2
+ /* stylelint-disable no-descending-specificity */
3
+ /* stylelint-disable font-family-no-missing-generic-family-keyword */
4
+ /* stylelint-disable declaration-property-value-disallowed-list */
5
+ /* stylelint-disable scss/selector-no-redundant-nesting-selector */
6
+ /* stylelint-disable order/properties-alphabetical-order */
7
+ @mixin gfm-code-base-styles($background: #f6f8fa, $background-dark: #242e34, $text: inherit) {
3
8
  code,
4
9
  kbd,
5
10
  pre {
6
- font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, Courier, monospace;
11
+ font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace;
7
12
  font-family: var(--md-code-font, SFMono-Regular, Consolas, Liberation Mono, Menlo, Courier, monospace);
8
- font-size: 1em
13
+ font-size: 1em;
9
14
  }
10
15
 
11
16
  code,
12
17
  pre {
13
- font-size: 12px
18
+ font-size: 12px;
14
19
  }
15
20
 
16
21
  pre {
17
22
  margin-bottom: 0;
18
- margin-top: 0
23
+ margin-top: 0;
24
+ word-wrap: normal;
19
25
  }
20
26
 
21
27
  code {
@@ -25,25 +31,21 @@
25
31
  color: var(--md-code-text);
26
32
  font-size: 85%;
27
33
  margin: 0;
28
- padding: .2em .4em;
34
+ padding: 0.2em 0.4em;
29
35
 
30
- >div[class*="cm-"] {
36
+ > div[class*='cm-'] {
31
37
  display: inherit;
32
38
  }
33
39
  }
34
40
 
35
- pre {
36
- word-wrap: normal
37
- }
38
-
39
- pre>code {
41
+ pre > code {
40
42
  background: 0 0;
41
43
  border: 0;
42
44
  font-size: 100%;
43
45
  margin: 0;
44
46
  padding: 0;
45
47
  white-space: pre;
46
- word-break: normal
48
+ word-break: normal;
47
49
  }
48
50
 
49
51
  pre {
@@ -57,7 +59,7 @@
57
59
  font-size: 85%;
58
60
  line-height: 1.45;
59
61
  overflow: auto;
60
- padding: 1em
62
+ padding: 1em;
61
63
  }
62
64
 
63
65
  pre code.theme-dark {
@@ -74,7 +76,7 @@
74
76
  max-width: auto;
75
77
  overflow: visible;
76
78
  padding: 0;
77
- word-wrap: normal
79
+ word-wrap: normal;
78
80
  }
79
81
 
80
82
  kbd {
@@ -89,89 +91,86 @@
89
91
  font-size: 11px;
90
92
  line-height: 10px;
91
93
  padding: 3px 5px;
92
- vertical-align: middle
94
+ vertical-align: middle;
93
95
  }
94
96
  }
95
97
 
96
- @mixin copyCodeButton {
98
+ @mixin copy-code-button {
97
99
  button.rdmd-code-copy {
98
- DISPLAY: none !important; // hide by default
99
-
100
- & {
101
- -webkit-appearance: unset;
102
- margin: .5em .6em 0 0;
103
- padding: .25em .7em;
104
- cursor: copy;
105
- font: inherit;
106
- color: inherit;
107
- color: var(--md-code-text, inherit);
108
- border: none;
109
- border-radius: 3px;
110
- outline: none !important;
111
- background: inherit;
112
- background: var(--md-code-background, inherit);
113
- box-shadow:
114
- inset 0 0 0 1px rgba(#aaa, .66),
115
- -1px 2px 6px -3px rgba(black, .1);
116
- transition: .15s ease-out;
117
- }
100
+ appearance: unset;
101
+ background: inherit;
102
+ background: var(--md-code-background, inherit);
103
+ border: none;
104
+ border-radius: 3px;
105
+ box-shadow:
106
+ inset 0 0 0 1px rgba(#aaa, 0.66),
107
+ -1px 2px 6px -3px rgba(black, 0.1);
108
+ color: inherit;
109
+ color: var(--md-code-text, inherit);
110
+ cursor: copy;
111
+ display: none !important; // hide by default
112
+ font: inherit;
113
+ margin: 0.5em 0.6em 0 0;
114
+ outline: none !important;
115
+ padding: 0.25em 0.7em;
116
+ transition: 0.15s ease-out;
118
117
 
119
118
  &:not(:hover) {
120
-
121
- &:before,
122
- &:after {
123
- opacity: .66;
119
+ &::before,
120
+ &::after {
121
+ opacity: 0.66;
124
122
  }
125
123
  }
126
124
 
127
125
  &:hover {
128
126
  &:not(:active) {
129
127
  box-shadow:
130
- inset 0 0 0 1px rgba(#8B8B8B, .75),
131
- -1px 2px 6px -3px rgba(black, .2);
128
+ inset 0 0 0 1px rgba(#8b8b8b, 0.75),
129
+ -1px 2px 6px -3px rgba(black, 0.2);
132
130
  }
133
131
  }
134
132
 
135
133
  &:active {
136
134
  box-shadow:
137
- inset 0 0 0 1px rgba(#8B8B8B, .5),
138
- inset 1px 4px 6px -2px rgba(0, 0, 0, .175);
135
+ inset 0 0 0 1px rgba(#8b8b8b, 0.5),
136
+ inset 1px 4px 6px -2px rgba(0, 0, 0, 0.175);
139
137
 
140
- &:before,
141
- &:after {
142
- opacity: .75;
138
+ &::before,
139
+ &::after {
140
+ opacity: 0.75;
143
141
  }
144
142
  }
145
143
 
146
- &:before,
147
- &:after {
144
+ &::before,
145
+ &::after {
148
146
  display: inline-block;
149
- font: normal normal normal 1em/1 "Font Awesome 5 Free", "FontAwesome";
147
+ font:
148
+ normal normal normal 1em/1 'Font Awesome 5 Free',
149
+ FontAwesome;
150
+ font-family: ReadMe-Icons;
151
+ font-feature-settings: 'liga';
152
+ font-variant-ligatures: discretionary-ligatures;
153
+ line-height: 2;
150
154
  text-rendering: auto;
151
155
  -webkit-font-smoothing: antialiased;
152
-
153
- line-height: 2;
154
- font-family: 'ReadMe-Icons';
155
- font-variant-ligatures: discretionary-ligatures;
156
- font-feature-settings: "liga";
157
156
  }
158
157
 
159
- &:before {
160
- content: "\e6c9";
158
+ &::before {
159
+ content: '\e6c9';
161
160
  font-weight: 800;
162
- transition: .3s .15s ease;
161
+ transition: 0.3s 0.15s ease;
163
162
  }
164
163
 
165
- &:after {
164
+ &::after {
166
165
  // @todo why are these !important @rafe, you dumbell?
167
- content: "\e942" !important;
166
+ content: '\e942' !important;
168
167
  font-weight: 900 !important;
169
- position: absolute;
170
- top: 50%;
171
168
  left: 50%;
172
- transform: translate(-50%, -50%) scale(.33);
173
169
  opacity: 0 !important;
174
- transition: .3s 0s ease;
170
+ position: absolute;
171
+ top: 50%;
172
+ transform: translate(-50%, -50%) scale(0.33);
173
+ transition: 0.3s 0s ease;
175
174
  }
176
175
 
177
176
  &_copied {
@@ -184,16 +183,16 @@
184
183
  opacity: 1;
185
184
  }
186
185
 
187
- &:before {
188
- transition: .3s 0s ease;
189
- transform: scale(.33);
186
+ &::before {
190
187
  opacity: 0 !important;
188
+ transition: 0.3s 0s ease;
189
+ transform: scale(0.33);
191
190
  }
192
191
 
193
- &:after {
194
- transition: .3s .15s ease;
195
- transform: translate(-50%, -50%) scale(1);
192
+ &::after {
196
193
  opacity: 1 !important;
194
+ transition: 0.3s 0.15s ease;
195
+ transform: translate(-50%, -50%) scale(1);
197
196
  }
198
197
  }
199
198
  }
@@ -201,11 +200,11 @@
201
200
  pre {
202
201
  position: relative;
203
202
 
204
- >code {
203
+ > code {
205
204
  background: inherit;
206
205
  }
207
206
 
208
- >code.theme-dark {
207
+ > code.theme-dark {
209
208
  color: white;
210
209
  }
211
210
 
@@ -221,7 +220,7 @@
221
220
  overflow: hidden;
222
221
  padding: 0;
223
222
 
224
- >code {
223
+ > code {
225
224
  display: block !important;
226
225
  overflow: auto;
227
226
  padding: 1em;
@@ -232,7 +231,7 @@
232
231
  // manage copied state style
233
232
  & {
234
233
  &:hover button.rdmd-code-copy:not(:hover) {
235
- transition-delay: .4s;
234
+ transition-delay: 0.4s;
236
235
  }
237
236
 
238
237
  &:not(:hover) button.rdmd-code-copy:not(.rdmd-code-copy_copied) {
@@ -243,7 +242,7 @@
243
242
  }
244
243
 
245
244
  .markdown-body {
246
- // --md-code-background: #F6F8FA;
247
- @include gfmCodeBaseStyles;
248
- @include copyCodeButton;
245
+ // --md-code-background: #F6F8FA;
246
+ @include gfm-code-base-styles;
247
+ @include copy-code-button;
249
248
  }
@@ -1,9 +1,11 @@
1
1
  const { uppercase } = require('@readme/syntax-highlighter');
2
2
  const PropTypes = require('prop-types');
3
3
  const React = require('react');
4
+ const { useState } = require('react');
4
5
 
5
6
  const CodeTabs = props => {
6
7
  const { children, theme } = props;
8
+ const [activeIndex, setActiveIndex] = useState(0);
7
9
 
8
10
  function handleClick({ target }, index) {
9
11
  const $wrap = target.parentElement.parentElement;
@@ -14,23 +16,32 @@ const CodeTabs = props => {
14
16
  const codeblocks = $wrap.querySelectorAll('pre');
15
17
  codeblocks[index].classList.add('CodeTabs_active');
16
18
 
17
- target.classList.add('CodeTabs_active');
19
+ setActiveIndex(index);
18
20
  }
19
21
 
20
22
  return (
21
23
  <div className={`CodeTabs CodeTabs_initial theme-${theme}`}>
22
- <div className="CodeTabs-toolbar">
24
+ <div className="CodeTabs-toolbar" role="tablist">
23
25
  {children.map(({ props: pre }, i) => {
24
26
  const { meta, lang } = pre.children[0].props;
25
27
  /* istanbul ignore next */
26
28
  return (
27
- <button key={i} onClick={e => handleClick(e, i)} type="button">
29
+ <button
30
+ key={i}
31
+ aria-selected={activeIndex === i}
32
+ className={activeIndex === i ? 'CodeTabs_active' : ''}
33
+ onClick={e => handleClick(e, i)}
34
+ role="tab"
35
+ type="button"
36
+ >
28
37
  {meta || `${!lang ? 'Text' : uppercase(lang)}`}
29
38
  </button>
30
39
  );
31
40
  })}
32
41
  </div>
33
- <div className="CodeTabs-inner">{children}</div>
42
+ <div className="CodeTabs-inner" role="tabpanel">
43
+ {children}
44
+ </div>
34
45
  </div>
35
46
  );
36
47
  };
@@ -1,21 +1,24 @@
1
+ /* stylelint-disable no-descending-specificity */
2
+ /* stylelint-disable declaration-property-value-disallowed-list */
1
3
  @import '~codemirror/lib/codemirror.css';
2
4
  @import '~codemirror/theme/neo.css';
3
5
 
4
- @mixin CodeTabs {
5
- $bgc-pre: #F6F8FA;
6
- $bgc-pre-dark: #242E34;
6
+ @mixin code-tabs {
7
+ $bgc-pre: #f6f8fa;
8
+ $bgc-pre-dark: #242e34;
7
9
  $bgc-bar: darken(desaturate($bgc-pre, 17.46), 4.31);
8
10
  $bgc-bar-dark: lighten(desaturate($bgc-pre-dark, 17.46), 4.31);
9
11
  $radius: var(--md-code-radius, var(--markdown-radius, 3px));
10
12
 
13
+ border-radius: $radius !important;
11
14
  color: #333;
12
15
  color: var(--md-code-text, #333);
13
- border-radius: $radius !important;
14
16
  overflow: hidden;
15
17
 
16
18
  &.theme-dark {
17
19
  color: white;
18
20
  color: var(--md-code-text, white);
21
+
19
22
  .CodeTabs-toolbar {
20
23
  background: $bgc-bar-dark;
21
24
  background: var(--md-code-tabs, $bgc-bar-dark);
@@ -28,27 +31,28 @@
28
31
  display: flex;
29
32
  flex-flow: row nowrap;
30
33
  overflow: hidden;
31
- overflow-x: auto;
32
- -ms-overflow-style: none;
33
34
  -webkit-overflow-scrolling: touch;
35
+ -ms-overflow-style: none;
36
+ overflow-x: auto;
37
+
34
38
  &::-webkit-scrollbar {
35
39
  display: none;
36
40
  }
41
+
37
42
  button {
38
- white-space: nowrap;
39
- transition: .123s ease;
40
- -webkit-appearance: none;
41
43
  appearance: none;
42
- display: inline-block;
43
- line-height: 2;
44
- padding: .5em 1em;
45
- border: none;
46
44
  background: transparent;
47
- outline: none;
45
+ border: none;
48
46
  color: inherit;
49
- font: inherit;
50
- font-size: .75em;
51
47
  cursor: pointer;
48
+ display: inline-block;
49
+ font: inherit;
50
+ font-size: 0.75em;
51
+ line-height: 2;
52
+ outline: none;
53
+ padding: 0.5em 1em;
54
+ transition: 0.123s ease;
55
+ white-space: nowrap;
52
56
  }
53
57
  }
54
58
 
@@ -69,16 +73,20 @@
69
73
  color: var(--md-code-text, white);
70
74
  }
71
75
 
72
- &-toolbar button:not(.CodeTabs_active):hover {
73
- background: rgba(0, 0, 0, .075);
76
+ &-toolbar button:not(.CodeTabs_active):hover,
77
+ &-toolbar button:not(.CodeTabs_active):active,
78
+ &-toolbar button:not(.CodeTabs_active):focus {
79
+ background: rgba(0, 0, 0, 0.075);
74
80
  }
75
81
 
76
82
  pre {
77
- border-radius: 0 0 $radius $radius !important;
78
- background: $bgc-pre;
79
83
  background: var(--md-code-background, $bgc-pre);
84
+ border-radius: 0 0 $radius $radius !important;
80
85
  margin-bottom: 0;
81
- &:not(.CodeTabs_active) { display: none }
86
+
87
+ &:not(.CodeTabs_active) {
88
+ display: none;
89
+ }
82
90
  }
83
91
 
84
92
  &.theme-dark pre {
@@ -92,5 +100,5 @@
92
100
  }
93
101
 
94
102
  .CodeTabs {
95
- @include CodeTabs;
103
+ @include code-tabs;
96
104
  }
@@ -83,7 +83,6 @@ Embed.defaultProps = {
83
83
  const CreateEmbed =
84
84
  ({ lazyImages }) =>
85
85
  // eslint-disable-next-line react/display-name
86
- props =>
87
- <Embed {...props} lazy={lazyImages} />;
86
+ props => <Embed {...props} lazy={lazyImages} />;
88
87
 
89
88
  module.exports = CreateEmbed;