Skip to content

Commit

Permalink
refactor: typeings
Browse files Browse the repository at this point in the history
  • Loading branch information
littletof committed Apr 21, 2024
1 parent 052fbc1 commit 6c1be79
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.vscode
eggs-debug.log
cov

TODO.md
test/tableTest.md
Expand Down
2 changes: 1 addition & 1 deletion example.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { renderMarkdown } from "./mod.ts";

export const demoText = `
export const demoText: string = `
# deno charmd
This is an example, to showcase https://github.com/littletof/charmd
Expand Down
2 changes: 1 addition & 1 deletion generator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { colors } from "./deps.ts";
import { Options } from "./renderer.ts";
import type { Options } from "./renderer.ts";
import type { Node } from "./nodeTypes.ts";
import { generateTable, getHeaderFormatter } from "./utils.ts";

Expand Down
48 changes: 18 additions & 30 deletions mdast-util-from-markdown@1_2_0-shimmed.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This code was bundled using `deno bundle` and it's not recommended to edit it manually

function l(r, t) {
var { includeImageAlt: i = !0 } = t || {};
var { includeImageAlt: i = !0 } = t || {};
return a(r, i);
}
function a(r, t) {
Expand Down Expand Up @@ -76,7 +76,7 @@ function p1(n, t, i, u) {
return s(r) ? (n.enter(i), e(r)) : t(r);
}
function e(r) {
return s(r) && (I++) < o ? (n.consume(r), e) : (n.exit(i), t(r));
return s(r) && I++ < o ? (n.consume(r), e) : (n.exit(i), t(r));
}
}
function a3(n) {
Expand Down Expand Up @@ -2230,7 +2230,7 @@ function I(l) {
if (p = l[e], e && p[1].type === "chunkFlow" && l[e - 1][1].type === "listItemPrefix" && (s = p[1]._tokenizer.events, n = 0, n < s.length && s[n][1].type === "lineEndingBlank" && (n += 2), n < s.length && s[n][1].type === "content")) for(; ++n < s.length && s[n][1].type !== "content";)s[n][1].type === "chunkText" && (s[n][1]._isInFirstContentOfListItem = !0, n++);
if (p[0] === "enter") p[1].contentType && (Object.assign(c, _(l, e)), e = c[e], u = !0);
else if (p[1]._container) {
for(n = e, r = void 0; (n--) && (o = l[n], o[1].type === "lineEnding" || o[1].type === "lineEndingBlank");)o[0] === "enter" && (r && (l[r][1].type = "lineEndingBlank"), o[1].type = "lineEnding", r = n);
for(n = e, r = void 0; n-- && (o = l[n], o[1].type === "lineEnding" || o[1].type === "lineEndingBlank");)o[0] === "enter" && (r && (l[r][1].type = "lineEndingBlank"), o[1].type = "lineEnding", r = n);
r && (p[1].end = Object.assign({}, l[r][1].start), f = l.slice(r, e), f.unshift(p), u1(l, r, e - r + 1, f));
}
}
Expand Down Expand Up @@ -2621,7 +2621,7 @@ function dn(n, u, r1) {
}
function s(S) {
let g;
return S === 59 && l ? (g = n.exit("characterReferenceValue"), a === C && !n1(t.sliceSerialize(g)) ? r1(S) : (n.enter("characterReferenceMarker"), n.consume(S), n.exit("characterReferenceMarker"), n.exit("characterReference"), u)) : a(S) && (l++) < o ? (n.consume(S), s) : r1(S);
return S === 59 && l ? (g = n.exit("characterReferenceValue"), a === C && !n1(t.sliceSerialize(g)) ? r1(S) : (n.enter("characterReferenceMarker"), n.consume(S), n.exit("characterReferenceMarker"), n.exit("characterReference"), u)) : a(S) && l++ < o ? (n.consume(S), s) : r1(S);
}
}
var tt = {
Expand Down Expand Up @@ -2930,7 +2930,7 @@ var Vt = {
};
function _t(n) {
let u = n.length;
for(; (u--) && !(n[u][0] === "enter" && n[u][1].type === "htmlFlow"););
for(; u-- && !(n[u][0] === "enter" && n[u][1].type === "htmlFlow"););
return u > 1 && n[u - 2][1].type === "linePrefix" && (n[u][1].start = n[u - 2][1].start, n[u + 1][1].start = n[u - 2][1].start, n.splice(u - 2, 2)), n;
}
function Qt(n, u, r) {
Expand Down Expand Up @@ -3583,7 +3583,7 @@ function Sn(t) {
}
function _(s) {
let h = r.length;
for(; (h--) > s;){
for(; h-- > s;){
let g = r[h];
e.containerState = g[1], g[0].exit.call(e, t);
}
Expand Down Expand Up @@ -3679,7 +3679,7 @@ function Fn(t, e) {
}
}
if (a) {
let d1 = {
let d = {
type: r === t.length || p || a < 2 ? "lineSuffix" : "hardBreakTrailing",
start: {
line: n.end.line,
Expand All @@ -3690,13 +3690,13 @@ function Fn(t, e) {
},
end: Object.assign({}, n.end)
};
n.end = Object.assign({}, d1.start), n.start.offset === n.end.offset ? Object.assign(n, d1) : (t.splice(r, 0, [
n.end = Object.assign({}, d.start), n.start.offset === n.end.offset ? Object.assign(n, d) : (t.splice(r, 0, [
"enter",
d1,
d,
e
], [
"exit",
d1,
d,
e
]), r += 2);
}
Expand Down Expand Up @@ -4008,7 +4008,7 @@ function x1() {
}
case 9:
{
for(o = Math.ceil(i / 4) * 4, e.push(-2); (i++) < o;)e.push(-1);
for(o = Math.ceil(i / 4) * 4, e.push(-2); i++ < o;)e.push(-1);
break;
}
case 10:
Expand Down Expand Up @@ -4187,14 +4187,14 @@ function Me(h = {}) {
r = C(e, u, r);
}
for(r = -1; ++r < e.length;){
let u1 = s[e[r][0]];
B1.call(u1, e[r][1].type) && u1[e[r][1].type].call(Object.assign({
let u = s[e[r][0]];
B1.call(u, e[r][1].type) && u[e[r][1].type].call(Object.assign({
sliceSerialize: e[r][2].sliceSerialize
}, w), e[r][1]);
}
if (i.length > 0) {
let u2 = i[i.length - 1];
(u2[1] || q).call(w, void 0, u2[0]);
let u = i[i.length - 1];
(u[1] || q).call(w, void 0, u[0]);
}
for(t.position = {
start: S(e.length > 0 ? e[0][1].start : {
Expand Down Expand Up @@ -4668,18 +4668,6 @@ function k1() {
return "~";
}
export { m1 as gfmStrikethroughFromMarkdown, p2 as gfmStrikethroughToMarkdown };
({
enter: {
strikethrough () {
this.tag("<del>");
}
},
exit: {
strikethrough () {
this.tag("</del>");
}
}
});
function x2(m = {}) {
let l = m.singleTilde, p = {
tokenize: S,
Expand Down Expand Up @@ -4780,15 +4768,15 @@ function x2(m = {}) {
}
}
globalThis.document = {
createElement: (...data)=>{
createElement: (..._data)=>{
return new class {
set innerHTML(data) {
this.textContent = data;
}
textContent = '';
textContent = "";
}();
}
};
document.createElement();
export { x2 as gfmStrikethrough };
export { Pe as mdast };
export { x2 as gfmStrikethrough };
1 change: 1 addition & 0 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export type { Node } from "./nodeTypes.ts";
export { toAst } from "./utils.ts";
export { transformer } from "./transformer.ts";
export { generator } from "./generator.ts";
Expand Down
2 changes: 1 addition & 1 deletion transformer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { colors } from "./deps.ts";
import { Options } from "./renderer.ts";
import type { Options } from "./renderer.ts";
import type { Node, TableNode, TextNode } from "./nodeTypes.ts";
import { isMarkdownTable } from "./utils.ts";

Expand Down
2 changes: 1 addition & 1 deletion utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { colors, fromMarkdown } from "./deps.ts";
import { MdastOptions } from "./mod.ts";
import type { MdastOptions } from "./mod.ts";
import type { Node } from "./nodeTypes.ts";

function polyfillDocumentCreateForMDAST() {
Expand Down

0 comments on commit 6c1be79

Please sign in to comment.