Skip to content

Commit

Permalink
Add BROKEN v8r configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
wesley-dean-gsa committed Dec 18, 2024
1 parent 9574033 commit 2992484
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .v8rrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
customCatalog:
schemas:
- name: "Job Postings"
fileMatch: ["pages/jointts/positions/*.md"]
location: "_schemas/job-posting.json"
parser: "md"

plugins:
- "file:./plugins/v8r-plugin-markdown-parser.js"
32 changes: 32 additions & 0 deletions plugins/v8r-plugin-markdown-parser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { BasePlugin, Document } from "v8r";
import yaml from "js-yaml";
import brainmatter from "brainmatter";

class MarkdownParser extends BasePlugin {
static name = "v8r-plugin-markdown-parser";

registerInputFileParsers() {
console.log("Registering md file parser");
return ["md"];
}

parseInputFile(contents, fileLocation, parser) {
const brainmatter = require('brainmatter');
const { html, data } = brainmatter(contents);

console.log("In parseInputFile");

if (parser === "md") {
console.log("parser===md");
return yaml.loadAll(data).map((doc) => new Document(doc));
} else if (parser == null) {
if (fileLocation.endsWith(".md") {
console.log("endsWith .md");
return yaml.loadAll(contents).map((doc) => new Document(doc));
}
}
console.log("fell through tests");
}
}

export default MarkdownParser;

0 comments on commit 2992484

Please sign in to comment.