Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
spenserblack committed Apr 18, 2023
2 parents 95fde9b + 61c3924 commit f593951
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 10 deletions.
1 change: 0 additions & 1 deletion .devcontainer/.npmrc

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- uses: spenserblack/actions-tag-to-release@v1
- uses: spenserblack/actions-tag-to-release@v2
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,11 @@ newlines
are preserved"
`;

exports[`parse spec list-items 1`] = `
"[list]
[*][url=https://example.com]link[/url]
[*][i]emphasis[/i]
[*][b]strong[/b]
[/list]"
`;
3 changes: 3 additions & 0 deletions packages/steamdown/__tests__/input/list-items.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- [link](https://example.com)
- *emphasis*
- **strong**
2 changes: 1 addition & 1 deletion packages/steamdown/__tests__/snapshots.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { describe, test, expect } from "@jest/globals";
import render from "../src/index";

describe("parse spec", () => {
const tests = ["basic"].map((name) => [name]);
const tests = ["basic", "list-items"].map((name) => [name]);
test.each(tests)("%s", async (name: string) => {
const path = resolve(__dirname, "./input", `${name}.md`);
const src = await readFile(path, "utf8");
Expand Down
7 changes: 0 additions & 7 deletions packages/steamdown/src/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ const space = {
return raw;
},
};
const text = {
name: "text",
renderer({ raw }: GenericToken) {
return raw;
},
};

const underline = {
name: "strong",
Expand Down Expand Up @@ -168,7 +162,6 @@ const blockquote: Extension = {

const extensions: Extension[] = [
space,
text,
underline,
spoiler,
noparse,
Expand Down
18 changes: 18 additions & 0 deletions packages/steamdown/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ import type { marked } from "marked";

type Renderer = marked.RendererObject;

// HACK: Even with the `sanitize: false`, `mangle: false`, and `sanitizer: (html) => ''` options,
// marked still escapes some characters. This is a workaround for that.
const unescapes = {
"&": "&",
"&lt;": "<",
"&gt;": ">",
"&quot;": '"',
"&#39;": "'",
};
const unescape = (text: string) => {
const regexp = new RegExp(Object.keys(unescapes).join("|"), "g");
return text.replace(regexp, (match) => unescapes[match as keyof typeof unescapes]);
};

const renderer: Renderer = {
paragraph(text: string) {
return text;
Expand Down Expand Up @@ -47,6 +61,10 @@ const renderer: Renderer = {
const tag = flags.header ? "th" : "td";
return ` [${tag}]${content}[/${tag}]\n`;
},
text(text: string) {
// TODO: Switch hack with something better (marked option, custom tokenizer, etc.)
return unescape(text);
},
};

export default renderer;

1 comment on commit f593951

@vercel
Copy link

@vercel vercel bot commented on f593951 Apr 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

steamdown – ./

steamdown-spenserblack.vercel.app
steamdown.vercel.app
steamdown-git-main-spenserblack.vercel.app

Please sign in to comment.