Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ class J2M {
// Remove color: unsupported in md
.replace(/\{color:[^}]+\}([^]*?)\{color\}/gm, '$1')
// panel into table
.replace(/\{panel:title=([^}]*)\}\n?([^]*?)\n?\{panel\}/gm, '\n| $1 |\n| --- |\n| $2 |')
.replace(/\{panel:title=([^}]*)\}\n?([^]*?)\n?\{panel\}/gm, '| $1 |\n| --- |\n| $2 |')
// table header
.replace(/^[ \t]*((?:\|\|.*?)+\|\|)[ \t]*$/gm, (match, headers) => {
const singleBarred = headers.replace(/\|\|/g, '|');
return `\n${singleBarred}\n${singleBarred.replace(/\|[^|]+/g, '| --- ')}`;
return `${singleBarred}\n${singleBarred.replace(/\|[^|]+/g, '| --- ')}`;
})
// remove leading-space of table headers and rows
.replace(/^[ \t]*\|/gm, '|')
Expand Down Expand Up @@ -120,7 +120,7 @@ class J2M {
str
// Tables
.replace(
/^\n((?:\|.*?)+\|)[ \t]*\n((?:\|\s*?-{3,}\s*?)+\|)[ \t]*\n((?:(?:\|.*?)+\|[ \t]*\n)*)$/gm,
/^((?:\|.*?)+\|)[ \t]*\n((?:\|[ \t]*?-+[ \t]*?)+\|)[ \t]*\n((?:(?:\|.*?)+\|[ \t]*\n?)*)$/gm,
(match, headerLine, separatorLine, rowstr) => {
const headers = headerLine.match(/[^|]+(?=\|)/g);
const separators = separatorLine.match(/[^|]+(?=\|)/g);
Expand Down Expand Up @@ -164,7 +164,7 @@ class J2M {
.join('')} `;
})
// Un-Ordered Lists
.replace(/^([ \t]*)\*\s+/gm, (match, spaces) => {
.replace(/^([ \t]*)[*-]\s+/gm, (match, spaces) => {
return `${Array(Math.floor(spaces.length / 2 + 1))
.fill('*')
.join('')} `;
Expand All @@ -180,10 +180,18 @@ class J2M {
// Named/Un-Named Code Block
.replace(/```(.+\n)?((?:.|\n)*?)```/g, (match, synt, content) => {
let code = '{code}';
let codeBody = content;
if (synt) {
code = `{code:${synt.replace(/\n/g, '')}}\n`;

// Especially for yaml code blocks, we have to
// add two more spaces in every line ending.
// Otherwise Jira shows it distorted.
if (synt === 'yaml\n') {
codeBody = codeBody.replace(/\n/g, ' \n');
}
}
return `${code}${content}{code}`;
return `${code}${codeBody}{code}`;
})
// Inline-Preformatted Text
.replace(/`([^`]+)`/g, '{{$1}}')
Expand Down
155 changes: 63 additions & 92 deletions package-lock.json

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

Loading