Skip to content

Commit

Permalink
Djot integration (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
teomrd authored Nov 22, 2024
1 parent 994ce4a commit 984a6bf
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 37 deletions.
23 changes: 6 additions & 17 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
"author": "teomrd <mironidis.gr@gmail.com>",
"license": "GPL-3.0-only",
"dependencies": {
"@types/showdown": "^2.0.6",
"@djot/djot": "^0.3.1",
"github-markdown-css": "^5.7.0",
"multiformats": "^13.3.1",
"nanoid": "^5.0.8",
"showdown": "^2.1.0",
"textarea-caret": "^3.1.0"
}
}
1 change: 1 addition & 0 deletions src/js/components/organisms/markdown/markDownViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const markDownViewer = (() => {

this.autoLink();

// add a copy button to the code blocks
const { elements } = select("pre");
Array.prototype.slice.call(elements).forEach((el) => {
const copyBtn = button("📋 Copy", async (e) => {
Expand Down
22 changes: 8 additions & 14 deletions src/js/components/organisms/markdown/mdToHtml.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import type _Showdown from "npm:@types/showdown";
import showdown from "showdown";
import { parse, renderHTML } from "@djot/djot";

const converter = new showdown.Converter({
tasklists: true,
underline: true,
emoji: true,
simplifiedAutoLink: true,
tables: true,
openLinksInNewWindow: true,
});

converter.setFlavor("github");

export const convertMarkDownToHtml = (md: string) => converter.makeHtml(md);
export const convertMarkDownToHtml = (md: string) => {
return renderHTML(
parse(md, {
warn: (warning) => console.log(warning.render()),
}),
);
};
1 change: 0 additions & 1 deletion src/js/listeners/urlChange.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "github-markdown-css";
import "../../css/print.css";
import "../../css/styles.css";
import notify from "../components/molecules/notify.ts";
Expand Down
3 changes: 0 additions & 3 deletions src/js/ui/markdown/preview/autoMagicallyCheckBoxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import select from "../../../utils/dom.js";
// but lives temporarily on the browser's state
// Useful feature when you are going to the Super market 😄

// Technically I cloud re-enable the checkboxes that ShowdownJS generates,
// which are by default disabled, but couldn't figure that out. ¯\_(ツ)_/¯

export const autoMagicallyCheckBoxes = () => {
select(".task-list-item").listenAll("click", (el) => {
el.firstChild.checked = !el.firstChild.checked;
Expand Down

0 comments on commit 984a6bf

Please sign in to comment.