|
8 | 8 | from rich.console import Console |
9 | 9 | from rich.markdown import Markdown |
10 | 10 | from rich.syntax import Syntax |
| 11 | +from pygments.lexers import PhpLexer |
11 | 12 | from streamlit.web import cli as stcli |
12 | 13 | from yaspin import yaspin |
13 | 14 |
|
14 | 15 | from codeqai import codeparser, repo, utils |
15 | 16 | from codeqai.bootstrap import bootstrap |
16 | 17 | from codeqai.cache import create_cache_dir, get_cache_path, save_vector_cache |
17 | 18 | from codeqai.config import create_config, get_config_path, load_config |
18 | | -from codeqai.constants import DistillationMode, EmbeddingsModel, LlmHost |
| 19 | +from codeqai.constants import DistillationMode, EmbeddingsModel, Language, LlmHost |
19 | 20 | from codeqai.dataset_extractor import DatasetExtractor |
20 | 21 | from codeqai.embeddings import Embeddings |
21 | 22 | from codeqai.vector_store import VectorStore |
@@ -243,14 +244,26 @@ def run(): |
243 | 244 | doc.metadata["filename"], doc.page_content |
244 | 245 | ) |
245 | 246 |
|
246 | | - syntax = Syntax( |
247 | | - indentation + doc.page_content, |
248 | | - language.value, |
249 | | - theme="monokai", |
250 | | - line_numbers=True, |
251 | | - start_line=start_line, |
252 | | - indent_guides=True, |
253 | | - ) |
| 247 | + # PHP needs startinline=True since code snippets don't have <?php tag |
| 248 | + if language == Language.PHP: |
| 249 | + lexer = PhpLexer(startinline=True) |
| 250 | + syntax = Syntax( |
| 251 | + indentation + doc.page_content, |
| 252 | + lexer=lexer, |
| 253 | + theme="monokai", |
| 254 | + line_numbers=True, |
| 255 | + start_line=start_line, |
| 256 | + indent_guides=True, |
| 257 | + ) |
| 258 | + else: |
| 259 | + syntax = Syntax( |
| 260 | + indentation + doc.page_content, |
| 261 | + language.value, |
| 262 | + theme="monokai", |
| 263 | + line_numbers=True, |
| 264 | + start_line=start_line, |
| 265 | + indent_guides=True, |
| 266 | + ) |
254 | 267 | print( |
255 | 268 | doc.metadata["filename"] + " -> " + doc.metadata["method_name"] |
256 | 269 | ) |
|
0 commit comments