Skip to content

Commit

Permalink
Add support for markdown exports
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmeyers committed Mar 28, 2022
1 parent f82b478 commit a746b7c
Show file tree
Hide file tree
Showing 21 changed files with 11,586 additions and 463 deletions.
57 changes: 57 additions & 0 deletions make-csl-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const fs = require("fs");
const convert = require("xml-js");

function readFiles(dirname, onFileContent, onError, done) {
fs.readdir(dirname, function (err, filenames) {
if (err) {
onError(err);
return;
}

for (let filename of filenames) {
if (!filename.endsWith(".csl")) continue;
const content = fs.readFileSync(dirname + filename);
onFileContent(filename, convert.xml2js(content.toString()));
}

done();
});
}

const cslList = [];

readFiles(
"../styles/",
function (filename, content) {
if (content && content.elements) {
const style = content.elements.find((el) => el.name === "style");

if (style) {
const info = style.elements.find((el) => el.name === "info");

if (info) {
const styleLink = info.elements.find(
(el) =>
el.name === "link" && el.attributes.rel === "self"
);
const titleEl = info.elements.find(
(el) => el.name === "title"
);
const title = titleEl.elements[0].text;
const id = styleLink.attributes.href.split("/").pop();

cslList.push({ value: id, label: title });
}
}
}
},
function (err) {
throw err;
},
function () {
fs.writeFileSync(
"./src/csl-list.json",
JSON.stringify(cslList, null, 2)
);
}
);
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"author": "",
"license": "MIT",
"devDependencies": {
"@types/download": "^8.0.1",
"@types/node": "16.11.6",
"@types/nunjucks": "^3.2.1",
"@typescript-eslint/eslint-plugin": "5.2.0",
Expand All @@ -21,11 +22,14 @@
"obsidian": "0.13.30",
"obsidian-plugin-cli": "0.8.1",
"tslib": "2.3.1",
"typescript": "4.4.4"
"typescript": "4.4.4",
"xml-js": "^1.6.11"
},
"dependencies": {
"@types/react-dom": "17.0.13",
"download": "^8.0.0",
"escape-path-with-spaces": "1.0.0",
"fuse.js": "^6.5.3",
"nunjucks": "3.2.3",
"preact": "10.6.6",
"react": "npm:@preact/compat",
Expand Down
6 changes: 3 additions & 3 deletions src/DebugView.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import ReactDOM from "react-dom";
import { moment, ItemView, WorkspaceLeaf } from "obsidian";
import { pdfDebugPrompt } from "./annotations";
import { pdfDebugPrompt } from "./bbt/annotations";
import ZoteroConnector from "./main";
import { JSONTree } from "react-json-tree";

Expand Down Expand Up @@ -62,7 +62,7 @@ export class DebugView extends ItemView {
{ text: "Prompt For Selection" },
(btn) => {
btn.onClickEvent((e) => {
pdfDebugPrompt(this.plugin.settings.database).then(
pdfDebugPrompt(this.plugin.settings).then(
(res) => {
if (!res || res.length === 0) {
this.wrapper.innerText = "No data retrieved";
Expand All @@ -88,7 +88,7 @@ export class DebugView extends ItemView {
}

getDisplayText() {
return "Zotero Connector";
return "Zotero Data Explorer";
}

mountJsonViewer(json: any) {
Expand Down
File renamed without changes.
Loading

0 comments on commit a746b7c

Please sign in to comment.