Skip to content

Commit

Permalink
Rename default section to markdown section
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Jan 19, 2025
1 parent 89bc789 commit 5a13988
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion client/src/components/Markdown/Markdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ onMounted(() => {
</b-alert>
</div>
<div v-for="(obj, index) in markdownObjects" :key="index" class="markdown-components">
<MarkdownDefault v-if="obj.name === 'default'" :content="obj.content" />
<MarkdownDefault v-if="obj.name === 'markdown'" :content="obj.content" />
<MarkdownVega v-else-if="obj.name === 'vega'" :content="obj.content" />
<MarkdownVitessce v-else-if="obj.name === 'vitessce'" :content="obj.content" />
<MarkdownGalaxy
Expand Down
10 changes: 5 additions & 5 deletions client/src/components/Markdown/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const FUNCTION_ARGUMENT_REGEX = `\\s*[\\w\\|]+\\s*=` + FUNCTION_ARGUMENT_VALUE_R
const FUNCTION_CALL_LINE = `\\s*(\\w+)\\s*\\(\\s*(?:(${FUNCTION_ARGUMENT_REGEX})(,${FUNCTION_ARGUMENT_REGEX})*)?\\s*\\)\\s*`;
const FUNCTION_CALL_LINE_TEMPLATE = new RegExp(FUNCTION_CALL_LINE, "m");

type DefaultSection = { name: "default"; content: string };
type DefaultSection = { name: "markdown"; content: string };
type GalaxySection = { name: string; content: string; args: { [key: string]: string } };
type Section = DefaultSection | GalaxySection;

Expand All @@ -23,13 +23,13 @@ function parseResult(result: { name: string; content: string }[], name: string,
export function parseMarkdown(input: string): { name: string; content: string }[] {
const result: { name: string; content: string }[] = [];
const lines = input.split("\n");
let currentName: string = "default";
let currentName: string = "markdown";
let currentContent: string[] = [];
lines.forEach((line) => {
const sectionMatch = line.match(/^```(.*)$/);
if (sectionMatch) {
parseResult(result, currentName, currentContent);
currentName = sectionMatch[1] || "default";
currentName = sectionMatch[1] || "markdown";
currentContent = [];
} else {
currentContent.push(line);
Expand All @@ -53,7 +53,7 @@ export function splitMarkdown(markdown: string, preserveWhitespace = false) {
const defaultContent = rawContent.trim();
if (preserveWhitespace || defaultContent) {
sections.push({
name: "default",
name: "markdown",
content: preserveWhitespace ? rawContent : defaultContent,
});
}
Expand All @@ -76,7 +76,7 @@ export function splitMarkdown(markdown: string, preserveWhitespace = false) {
}
} else {
sections.push({
name: "default",
name: "markdown",
content: digest,
});
break;
Expand Down

0 comments on commit 5a13988

Please sign in to comment.