代码片段管理工具:rofi前端+Java守护进程
This commit is contained in:
11
CodeSnippetDaemon/src/test/java/MarkdownTest.java
Normal file
11
CodeSnippetDaemon/src/test/java/MarkdownTest.java
Normal file
@@ -0,0 +1,11 @@
|
||||
import work.slhaf.snippet.entity.Snippet;
|
||||
import work.slhaf.snippet.service.SnippetReader;
|
||||
|
||||
void main() throws IOException {
|
||||
// Read the test file
|
||||
FileReader reader = new FileReader("../test/test.md", StandardCharsets.UTF_8);
|
||||
String s = reader.readAllAsString();
|
||||
SnippetReader snippetReader = new SnippetReader();
|
||||
Snippet visit = snippetReader.visit(s);
|
||||
System.out.println(visit);
|
||||
}
|
||||
29
CodeSnippetDaemon/src/test/java/SnippetReaderTest.java
Normal file
29
CodeSnippetDaemon/src/test/java/SnippetReaderTest.java
Normal file
@@ -0,0 +1,29 @@
|
||||
import work.slhaf.snippet.entity.Snippet;
|
||||
import work.slhaf.snippet.service.SnippetReader;
|
||||
|
||||
void main() throws IOException {
|
||||
// Read the test file
|
||||
FileReader reader = new FileReader("../test/test.md", StandardCharsets.UTF_8);
|
||||
SnippetReader snippetReader = new SnippetReader();
|
||||
StringBuilder content = new StringBuilder();
|
||||
int ch;
|
||||
while ((ch = reader.read()) != -1) {
|
||||
content.append((char) ch);
|
||||
}
|
||||
reader.close();
|
||||
|
||||
// Parse the content using SnippetReader
|
||||
Snippet snippet = snippetReader.visit(content.toString());
|
||||
|
||||
// Print the extracted information
|
||||
System.out.println("Language: " + snippet.getLanguage());
|
||||
System.out.println("Description: " + snippet.getDescription());
|
||||
System.out.println("Tags: ");
|
||||
if (snippet.getTags() != null) {
|
||||
for (String tag : snippet.getTags()) {
|
||||
System.out.println(" - " + tag);
|
||||
}
|
||||
}
|
||||
System.out.println("Content: ");
|
||||
System.out.println(snippet.getContent());
|
||||
}
|
||||
Reference in New Issue
Block a user