parent
e3b8495431
commit
0ff390ed80
7 changed files with 79 additions and 46 deletions
|
|
@ -52,7 +52,7 @@ export type TextElement = { type: 'text', content: string }
|
|||
| TextElementTitle
|
||||
| TextElementUrl
|
||||
| TextElementMotion;
|
||||
export type TextElementProcessor = (text: string, isBegin: boolean) => TextElement | TextElement[];
|
||||
export type TextElementProcessor = (text: string, before: string) => TextElement | TextElement[];
|
||||
|
||||
export default (source: string): TextElement[] => {
|
||||
if (source == null || source == '') {
|
||||
|
|
@ -68,12 +68,10 @@ export default (source: string): TextElement[] => {
|
|||
}
|
||||
}
|
||||
|
||||
let i = 0;
|
||||
|
||||
// パース
|
||||
while (source != '') {
|
||||
const parsed = elements.some(el => {
|
||||
let _tokens = el(source, i == 0);
|
||||
let _tokens = el(source, tokens.map(token => token.content).join(''));
|
||||
if (_tokens) {
|
||||
if (!Array.isArray(_tokens)) {
|
||||
_tokens = [_tokens];
|
||||
|
|
@ -91,8 +89,6 @@ export default (source: string): TextElement[] => {
|
|||
content: source[0]
|
||||
});
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
const combineText = (es: TextElement[]): TextElement =>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue