Skip to content

Commit

Permalink
Remove emypt line for code-block
Browse files Browse the repository at this point in the history
  • Loading branch information
garyyeap committed Oct 24, 2020
1 parent 6e616ea commit 66fa0b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class ConfluenceRenderer {
stylingOptions = `:${stylingOptions}`;
}

return `{code${stylingOptions}}\n${text}\n{code}\n\n`;
return `{code${stylingOptions}}${text}{code}\n\n`;
}


Expand Down
18 changes: 6 additions & 12 deletions spec/lib/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,12 @@ and more
});
describe("code", () => {
it("formats with code fences", () => {
expect(convert("```js\nthis is code\n```")).toEqual(`{code:theme=RDark|linenumbers=true|language=javascript}
this is code
{code}`);
expect(convert("```js\nthis is code\n```")).toEqual(`{code:theme=RDark|linenumbers=true|language=javascript}this is code{code}`);
});
it("formats with indentation", () => {
expect(convert(`
// different code
`)).toEqual(`{code:theme=RDark|linenumbers=true|language=none}
// different code
{code}`);
`)).toEqual(`{code:theme=RDark|linenumbers=true|language=none}// different code{code}`);
});
it("uses the language map (lowercased) and code styling options", () => {
expect(convert("```Moo\ncow()\n```", {
Expand All @@ -73,25 +69,23 @@ this is code
codeStyling: {
anything: "goes_here"
}
})).toEqual(`{code:anything=goes_here|language=cowspeak}
cow()
{code}`);
})).toEqual(`{code:anything=goes_here|language=cowspeak}cow(){code}`);
});
it("allows 20 lines before collapsing", () => {
expect(convert("```\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n```", {
codeStyling: {}
})).toEqual("{code:language=none}\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n{code}");
})).toEqual("{code:language=none}1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20{code}");
});
it("collapses when too big", () => {
expect(convert("```\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n```", {
codeStyling: {}
})).toEqual("{code:language=none|collapse=true}\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n{code}");
})).toEqual("{code:language=none|collapse=true}1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21{code}");
});
it("collapses at a set number", () => {
expect(convert("```\n1\n2\n3\n```", {
codeStyling: {},
codeCollapseAt: 2
})).toEqual("{code:language=none|collapse=true}\n1\n2\n3\n{code}");
})).toEqual("{code:language=none|collapse=true}1\n2\n3{code}");
});
});
describe("codespan", () => {
Expand Down

0 comments on commit 66fa0b3

Please sign in to comment.