Skip to content

Commit

Permalink
Merge pull request #4 from IronBlood/fix/20210205
Browse files Browse the repository at this point in the history
对 0.2.0 的修正
  • Loading branch information
IronBlood committed Feb 6, 2021
2 parents ea868bd + 2a98e74 commit ecfd1b2
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 7 deletions.
1 change: 0 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"root": true,
"env": {
"jest": true,
"browser": true,
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ TBD
* CSS - `css`
* Diff - `diff`
* Docker - `docker``dockerfile`
* DOT(Graphviz) - `dot``gv`
* Erlang - `erlang`
* Fortran - `fortran`
* Go - `go`
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bmybbs/bmybbs-content-parser",
"version": "0.2.0",
"version": "0.2.1",
"description": "This is a library to convert bmybbs content, including articles and mails, to HTML format.",
"main": "dist/index.js",
"types": "dist/index.d.js",
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/codeblockParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const codeblockParser: LineParser = (line, config) => {
// TODO 终止之前的状态

config.states.isInCodeBlock = true;
const lang = line.substring(4).toLowerCase();
const lang = line.substring(3).toLowerCase();
const langstr = langSets.has(lang) ? lang : langFallback;

return `<pre><code class="language-${langstr}">`;
Expand Down
2 changes: 0 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ langSets.add("css");
langSets.add("diff");
langSets.add("docker");
langSets.add("dockerfile");
langSets.add("dot");
langSets.add("gv");
langSets.add("erlang");
langSets.add("fortran");
langSets.add("go");
Expand Down
13 changes: 13 additions & 0 deletions test/01-codeblock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ describe("Code Block Parser Test", () => {
expect(parser(content)).toBe(result);
});

test("code block with lines", () => {
const content = { text: "```c\n#include <stdio.h>\n```", attaches: [] },
result = [
"<article>",
"<pre><code class=\"language-c\">",
"#include &lt;stdio.h&gt;\n",
"</code></pre>",
"</article>"
].join("");

expect(parser(content)).toBe(result);
});

// TODO
});

0 comments on commit ecfd1b2

Please sign in to comment.