Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit 0c2e287

Browse files
authored
Merge pull request #27 from withspectrum/fix-complex-characters-in-bold-text
Fix bolding complex text
2 parents 380c8c2 + df749cd commit 0c2e287

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

src/modifiers/__test__/handleInlineStyle-test.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,50 @@ describe("handleInlineStyle", () => {
8787
hasFocus: true,
8888
}),
8989
},
90+
"converts semicolons to bold with astarisks": {
91+
before: {
92+
entityMap: {},
93+
blocks: [
94+
{
95+
key: "item1",
96+
text: "hello **TL;DR:** style",
97+
type: "unstyled",
98+
depth: 0,
99+
inlineStyleRanges: [],
100+
entityRanges: [],
101+
data: {},
102+
},
103+
],
104+
},
105+
after: {
106+
entityMap: {},
107+
blocks: [
108+
{
109+
key: "item1",
110+
text: "hello TL;DR: style",
111+
type: "unstyled",
112+
depth: 0,
113+
inlineStyleRanges: [
114+
{
115+
length: 6,
116+
offset: 6,
117+
style: "BOLD",
118+
},
119+
],
120+
entityRanges: [],
121+
data: {},
122+
},
123+
],
124+
},
125+
selection: new SelectionState({
126+
anchorKey: "item1",
127+
anchorOffset: 14,
128+
focusKey: "item1",
129+
focusOffset: 14,
130+
isBackward: false,
131+
hasFocus: true,
132+
}),
133+
},
90134
"converts to bold with underscores": {
91135
before: {
92136
entityMap: {},

src/modifiers/handleInlineStyle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import changeCurrentInlineStyle from "./changeCurrentInlineStyle";
22

33
const inlineMatchers = {
4-
BOLD: [/\*\*([^(?:**)]+)\*\*/g, /__([^(?:__)]+)__/g],
4+
BOLD: [/\*\*([^(?**)]+)\*\*/g, /__([^(?:__)]+)__/g],
55
ITALIC: [/\*([^*]+)\*/g, /_([^_]+)_/g],
66
CODE: [/`([^`]+)`/g],
77
STRIKETHROUGH: [/~~([^(?:~~)]+)~~/g],

0 commit comments

Comments
 (0)