Skip to content
This repository has been archived by the owner on Jul 27, 2020. It is now read-only.

Commit

Permalink
Merge pull request #9 from j6s/development
Browse files Browse the repository at this point in the history
Extract Library
  • Loading branch information
FokkeZB committed May 23, 2016
2 parents 2881ded + dae008e commit 4f7da14
Show file tree
Hide file tree
Showing 43 changed files with 382 additions and 126 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
site/
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,61 @@
## JIRA to MarkDown text format converter
Convert from JIRA text formatting to GitHub Flavored MarkDown and back again. Just because I got tired of reformatting text between GitHub (PR's) and JIRA.


## Library
### Installation
The J2M library is available via bower (for frontend usage) and npm (for node usage):

```
$ bower install J2M --save
```
```
$ npm install j2m --save
```

### Usage
J2M exposes 2 methods: `toJ` and `toM` for converting to Jira markup and to markdown.

- `J2M.toJ(markdown : string) : string`
- `J2M.toM(jira : string) : string`

#### Usage Example:
```JavaScript
var J2M = require('J2M');

var input = '## cool markdown';
var jira = J2M.toJ(input);
var markdownAgain = J2M.toM(jira);
```


## CLI
J2M is also available as a command line utility.

### Installation
```
$ npm install -g j2m
```

### Usage
```
$ j2m [--toM|--toJ] [--stdin] $filename
Options:
--toM, -m: Treat input as jira text and convert it to Markdown
--toJ, -j: Treat input as markdown text and convert it to Jira
--stdin: Read input from stdin. In this case the give filename is ignored
```

#### Usage Example
```bash
# convert notes to jira markup and copy it to the clipboard (mac)
j2m --toJ notes.md | pbcopy

# retrieve some file in jira markup and save it as markdown
curl http://someserver.com/jira.txt | j2m --toM --stdin > notee.md
```

## Website
Use J2M online at: [http://j2m.fokkezb.nl/](http://j2m.fokkezb.nl/) (updated automagically)

Expand Down
28 changes: 28 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "J2M",
"homepage": "https://github.com/FokkeZB/J2M",
"authors": [
"Fokke Zandbergen <[email protected]>"
],
"description": "Convert from JIRA text formatting to GitHub Flavored MarkDown and back again",
"main": "src/J2M.js",
"moduleType": [
"globals",
"node"
],
"keywords": [
"jira",
"atlassian",
"markdown",
"convert"
],
"license": "Apache-2.0",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests",
"site"
]
}
18 changes: 0 additions & 18 deletions jbootstrap/css/bootstrap.min.css

This file was deleted.

32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "j2m",
"version": "1.0.0",
"description": "Convert from JIRA text formatting to GitHub Flavored MarkDown and back again",
"main": "src/J2M.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"bin": {
"j2m": "src/bin/j2m.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/FokkeZB/J2M.git"
},
"keywords": [
"jira",
"atlassian",
"markdown",
"convert"
],
"author": "Fokke Zandbergen <[email protected]>",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/FokkeZB/J2M/issues"
},
"homepage": "https://github.com/FokkeZB/J2M#readme",
"dependencies": {
"colors": "^1.1.2",
"minimist": "^1.2.0"
}
}
3 changes: 0 additions & 3 deletions pull.php

This file was deleted.

104 changes: 0 additions & 104 deletions script.js

This file was deleted.

1 change: 1 addition & 0 deletions site/J2M.js
3 changes: 2 additions & 1 deletion index.html → site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,10 @@ <h3>MarkDown</h3>
</div>

</div>

<script src="http://code.jquery.com/jquery.js"></script>
<script src="src-min-noconflict/ace.js"></script>
<script src="J2M.js"></script>
<script src="script.js"></script>

</body>
Expand Down
File renamed without changes.
18 changes: 18 additions & 0 deletions site/jbootstrap/css/bootstrap.min.css

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions site/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Sets up handlers for inputs
*
* TODO make more readable
*/
(function () {
var jiraInput = ace.edit("j");
var markdownInput = ace.edit("m");

// setup inputs
jiraInput.setTheme('ace/theme/twilight');
markdownInput.setTheme('ace/theme/twilight');
markdownInput.getSession().setMode('ace/mode/markdown');

var jiraCallback = function () {
var markdown = J2M.toM(jiraInput.getValue());
markdownInput.setValue(markdown);
};

var markdownCallback = function () {
var jira = J2M.toJ(markdownInput.getValue());
jiraInput.setValue(jira);
};

jiraInput.on('focus', function () {
jiraInput.on('change', jiraCallback);
});
jiraInput.on('blur', function () {
jiraInput.off('change', jiraCallback);
});

markdownInput.on('focus', function () {
markdownInput.on('change', markdownCallback);
});
markdownInput.on('blur', function () {
markdownInput.off('change', markdownCallback);
});
})();
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 4f7da14

Please sign in to comment.