Skip to content

Commit

Permalink
Fix for transformer markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
jschm42 committed Mar 5, 2024
1 parent b248b7b commit e896573
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2023-2024 Jean Schmitz.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.talkforgeai.backend.transformers;

import com.talkforgeai.backend.transformers.dto.TransformerContext;
import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MarkdownTextTransformer implements Transformer {

public static final Logger LOGGER = LoggerFactory.getLogger(MarkdownTextTransformer.class);
final Pattern boldRegEx = Pattern.compile("\\*\\*(.*)\\*\\*");

@Override
public String process(String content, TransformerContext context) {
return boldRegEx.matcher(content).replaceAll("<strong>$1</strong>");
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public MessageProcessor(FileStorageService fileStorageService,
transformers.add(new CodePhraseTransformer());
transformers.add(new MarkdownHeaderTransformer());
transformers.add(new MarkdownListTransformer());
transformers.add(new MarkdownTextTransformer());
transformers.add(new NewLineTransformer());

transformers.add(new ImageDownloadTransformer(openAiService));
Expand Down

0 comments on commit e896573

Please sign in to comment.