Skip to content

Commit

Permalink
refactor: return input/output/url for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
0x6b committed Dec 17, 2018
1 parent e0fae46 commit 167cbb8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
14 changes: 7 additions & 7 deletions src/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@ async function main() {
let text = `[${document.title}](${document.URL})`;
let selection = getSelectionAsMarkdown(options);

if (selection !== "") {
if (selection.output !== "") {
if (options["use-quote"]) {
selection = selection
selection.output = selection.output
.split("\n")
.map(line => `> ${line}`)
.join("\n");
}
if (options["link-to-source"]) {
text += `\n\n${selection}`;
text += `\n\n${selection.output}`;
} else {
text = selection;
text = selection.output;
}
}

if (config["debug"]) {
console.log("/* --- copy-selection-as-markdown debug information --- */");
console.log("/* --- INPUT ------------------------------------------ */");
console.log(result.html);
console.log(selection.html);
console.log("/* --- OUTPUT------------------------------------------ */");
console.log(result.output);
console.log(selection.output);
console.log("/* --- URL -------------------------------------------- */");
console.log(result.url);
console.log(selection.url);
console.log("/* ---------------------------------------------------- */");
}
doCopy(text);
Expand Down
9 changes: 3 additions & 6 deletions src/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ import turndownPluginMathJax from "./turndown-plugin-mathjax";

const url = require("url");

const turndownService = TurndownService({
headingStyle: "atx",
bulletListMarker: "-"
});
turndownService.use(turndownPluginMathJax);
const getSelectionAsMarkdown = options => {
const turndownService = TurndownService(options);
turndownService.use(turndownPluginMathJax);

const getSelectionAsMarkdown = () => {
let html = "";
const sel = document.getSelection();

Expand Down

0 comments on commit 167cbb8

Please sign in to comment.