Skip to content

Commit

Permalink
Fixing inline code escaping of symbols, release 2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
fidian committed Mar 17, 2017
1 parent 544a6a3 commit e876abe
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ CHANGELOG
=========


2.0.1 - 2017-03-17
------------------

* Fixing how inline code is sent. Escaping all symbols as HTML encoded decimal entries.


2.0.0 - 2017-03-16
------------------

Expand Down
9 changes: 9 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,19 @@ class ConfluenceRenderer {
*
* Text that has statements, like {{a = true}} or similar.
*
* Be wary. This converts wrong: "Look at `~/file1` or `~/file2`"
* Confluence thinks it is subscript and converts the markup into
* "Look at <code><sub>/file1</code> or <code></sub>/file2</code>".
* That's why some characters need to be escaped.
*
* @param {string} text
* @return {string}
*/
codespan(text) {
text = text.replace(/[^a-zA-Z0-9 ]/g, (match) => {
return `&#${match[0].charCodeAt(0)};`;
});

return `{{${text}}}`;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "markdown2confluence-cws",
"version": "2.0.0",
"version": "2.0.1",
"description": "Convert Markdown to Confluence Wiki Markup.",
"main": "lib/index.js",
"scripts": {
Expand Down
3 changes: 3 additions & 0 deletions spec/lib/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ cow()
it("wraps things in braces", () => {
expect(convert("text `code` text text `code`")).toEqual("text {{code}} text text {{code}}");
});
it("changes unsafe text so Confluence understands it", () => {
expect(convert("`~/file` and `~/folder` and `{braces}`")).toEqual("{{&#126;&#47;file}} and {{&#126;&#47;folder}} and {{&#123;braces&#125;}}");
});
});
describe("del / strikethrough", () => {
it("converts in GFM", () => {
Expand Down

0 comments on commit e876abe

Please sign in to comment.