Simplifies init process and adds github issue publishing

This commit is contained in:
Miguel de la Cruz 2020-04-27 11:42:29 +02:00
parent 21c18b3095
commit be543e2cc4
23 changed files with 581 additions and 390 deletions

12
vendor/github.com/StevenACoffman/j2m/.gitignore generated vendored Normal file
View file

@ -0,0 +1,12 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, build with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out

21
vendor/github.com/StevenACoffman/j2m/LICENSE generated vendored Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Steve Coffman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

15
vendor/github.com/StevenACoffman/j2m/Makefile generated vendored Normal file
View file

@ -0,0 +1,15 @@
.DEFAULT_GOAL := easy
.PHONY: install clean all easy
bin/j2m:
go build -o bin/j2m cmd/j2m.go
all: bin/j2m
install: bin/j2m
cp bin/* ~/bin
clean:
rm -f bin/*
easy: all

61
vendor/github.com/StevenACoffman/j2m/README.md generated vendored Normal file
View file

@ -0,0 +1,61 @@
[![GoDoc](https://godoc.org/github.com/StevenACoffman/j2m?status.svg)](https://godoc.org/github.com/StevenACoffman/j2m)
[![GoReportcard](https://goreportcard.com/badge/github.com/StevenACoffman/j2m?status.svg)](https://goreportcard.com/report/github.com/StevenACoffman/j2m)
# jira-to-md
## JIRA to MarkDown text format converter
Golang tool to convert from JIRA Markdown text formatting to GitHub Flavored MarkDown.
## Credits
This fun toy was heavily inspired by the J2M project by Fokke Zandbergen (http://j2m.fokkezb.nl/). Major credit to Fokke, kylefarris (and other contributors) for establishing the RexExp patterns for this to work. The maintained JavaScript fork I based this on is [here](https://github.com/kylefarris/J2M)
## Supported Conversions
* Headers (H1-H6)
* Bold
* Italic
* Bold + Italic
* Un-ordered lists
* Ordered lists
* Programming Language-specific code blocks (with help from herbert-venancio)
* Inline preformatted text spans
* Un-named links
* Named links
* Monospaced Text
* ~~Citations~~ (currently kinda buggy)
* Strikethroughs
* Inserts
* Superscripts
* Subscripts
* Single-paragraph blockquotes
* Tables
* Panels
## How to Use
### Markdown String
```
**Some bold things**
*Some italic stuff*
## H2
<http://google.com>
```
### Atlassian Wiki MarkUp Syntax (JIRA)
We'll refer to this as the `jira` variable in the examples below.
```
*Some bold things**
_Some italic stuff_
h2. H2
[http://google.com]
```
### Examples
```
cat j2m.jira | j2m
```

3
vendor/github.com/StevenACoffman/j2m/go.mod generated vendored Normal file
View file

@ -0,0 +1,3 @@
module github.com/StevenACoffman/j2m
go 1.12

153
vendor/github.com/StevenACoffman/j2m/j2m.go generated vendored Normal file
View file

@ -0,0 +1,153 @@
package j2m
import (
"fmt"
"regexp"
"strconv"
"strings"
)
type jiration struct {
re *regexp.Regexp
repl interface{}
}
// JiraToMD takes a string in Jira Markdown, and outputs Github Markdown
func JiraToMD(str string) string {
jirations := []jiration{
{ // UnOrdered Lists
re: regexp.MustCompile(`(?m)^[ \t]*(\*+)\s+`),
repl: func(groups []string) string {
_, stars := groups[0], groups[1]
return strings.Repeat(" ", len(stars)-1) + "* "
},
},
{ //Ordered Lists
re: regexp.MustCompile(`(?m)^[ \t]*(#+)\s+`),
repl: func(groups []string) string {
_, nums := groups[0], groups[1]
return strings.Repeat(" ", len(nums)-1) + "1. "
},
},
{ //Headers 1-6
re: regexp.MustCompile(`(?m)^h([0-6])\.(.*)$`),
repl: func(groups []string) string {
_, level, content := groups[0], groups[1], groups[2]
i, _ := strconv.Atoi(level)
return strings.Repeat("#", i) + content
},
},
{ // Bold
re: regexp.MustCompile(`\*(\S.*)\*`),
repl: "**$1**",
},
{ // Italic
re: regexp.MustCompile(`\_(\S.*)\_`),
repl: "*$1*",
},
{ // Monospaced text
re: regexp.MustCompile(`\{\{([^}]+)\}\}`),
repl: "`$1`",
},
{ // Citations (buggy)
re: regexp.MustCompile(`\?\?((?:.[^?]|[^?].)+)\?\?`),
repl: "<cite>$1</cite>",
},
{ // Inserts
re: regexp.MustCompile(`\+([^+]*)\+`),
repl: "<ins>$1</ins>",
},
{ // Superscript
re: regexp.MustCompile(`\^([^^]*)\^`),
repl: "<sup>$1</sup>",
},
{ // Subscript
re: regexp.MustCompile(`~([^~]*)~`),
repl: "<sub>$1</sub>",
},
{ // Strikethrough
re: regexp.MustCompile(`(\s+)-(\S+.*?\S)-(\s+)`),
repl: "$1~~$2~~$3",
},
{ // Code Block
re: regexp.MustCompile(`\{code(:([a-z]+))?([:|]?(title|borderStyle|borderColor|borderWidth|bgColor|titleBGColor)=.+?)*\}`),
repl: "```$2",
},
{ // Code Block End
re: regexp.MustCompile(`{code}`),
repl: "```",
},
{ // Pre-formatted text
re: regexp.MustCompile(`{noformat}`),
repl: "```",
},
{ // Un-named Links
re: regexp.MustCompile(`(?U)\[([^|]+)\]`),
repl: "<$1>",
},
{ // Images
re: regexp.MustCompile(`!(.+)!`),
repl: "![]($1)",
},
{ // Named Links
re: regexp.MustCompile(`\[(.+?)\|(.+)\]`),
repl: "[$1]($2)",
},
{ // Single Paragraph Blockquote
re: regexp.MustCompile(`(?m)^bq\.\s+`),
repl: "> ",
},
{ // Remove color: unsupported in md
re: regexp.MustCompile(`(?m)\{color:[^}]+\}(.*)\{color\}`),
repl: "$1",
},
{ // panel into table
re: regexp.MustCompile(`(?m)\{panel:title=([^}]*)\}\n?(.*?)\n?\{panel\}`),
repl: "\n| $1 |\n| --- |\n| $2 |",
},
{ //table header
re: regexp.MustCompile(`(?m)^[ \t]*((?:\|\|.*?)+\|\|)[ \t]*$`),
repl: func(groups []string) string {
_, headers := groups[0], groups[1]
reBarred := regexp.MustCompile(`\|\|`)
singleBarred := reBarred.ReplaceAllString(headers, "|")
fillerRe := regexp.MustCompile(`\|[^|]+`)
return "\n" + singleBarred + "\n" + fillerRe.ReplaceAllString(singleBarred, "| --- ")
},
},
{ // remove leading-space of table headers and rows
re: regexp.MustCompile(`(?m)^[ \t]*\|`),
repl: "|",
},
}
for _, jiration := range jirations {
switch v := jiration.repl.(type) {
case string:
str = jiration.re.ReplaceAllString(str, v)
case func([]string) string:
str = replaceAllStringSubmatchFunc(jiration.re, str, v)
default:
fmt.Printf("I don't know about type %T!\n", v)
}
}
return str
}
// https://gist.github.com/elliotchance/d419395aa776d632d897
func replaceAllStringSubmatchFunc(re *regexp.Regexp, str string, repl func([]string) string) string {
result := ""
lastIndex := 0
for _, v := range re.FindAllSubmatchIndex([]byte(str), -1) {
groups := []string{}
for i := 0; i < len(v); i += 2 {
groups = append(groups, str[v[i]:v[i+1]])
}
result += str[lastIndex:v[0]] + repl(groups)
lastIndex = v[1]
}
return result + str[lastIndex:]
}

65
vendor/github.com/StevenACoffman/j2m/j2m.jira generated vendored Normal file
View file

@ -0,0 +1,65 @@
h1. Biggest heading
h2. Bigger heading
h1. Biggest heading
h2. Bigger heading
h3. Big heading
h4. Normal heading
h5. Small heading
h6. Smallest heading
*strong*
_emphasis_
{{monospaced}}
-deleted-
+inserted+
^superscript^
~subscript~
{code:javascript}
var hello = 'world';
{code}
!http://google.com/image!
[!http://google.com/image!|http://google.com/link]
[http://google.com]
[Google|http://google.com]
GitHub Flavor
-deleted-
{code}
preformatted piece of text
so _no_ further _formatting_ is done here
{code}
_*Should be bold AND italic*_
* First li
* Second li
** Indented li
*** Three columns in li
* Back to first level li
# First li
# Second li
## Indented li
### Three columns in li
# Back to first level li
* Here's _italic_ inside li
* here's *bold* inside li
* Here's _*bold + italic*_ inside li
** Here they are in one line indented: _italic_ *bold*
bq. Here's a long single-paragraph block quote. It should look pretty and stuff.
{panel:title=A title}
Panel text
{panel}
||Heading 1||Heading 2||
|Col A1|Col A2|
|Col B1|Col B2|

68
vendor/github.com/StevenACoffman/j2m/j2m.md generated vendored Normal file
View file

@ -0,0 +1,68 @@
# Biggest heading
## Bigger heading
# Biggest heading
## Bigger heading
### Big heading
#### Normal heading
##### Small heading
###### Smallest heading
**strong**
*emphasis*
`monospaced`
~~deleted~~
<ins>inserted</ins>
<sup>superscript</sup>
<sub>subscript</sub>
```javascript
var hello = 'world';
```
![](http://google.com/image)
[![](http://google.com/image)](http://google.com/link)
<http://google.com>
[Google](http://google.com)
GitHub Flavor
~~deleted~~
```
preformatted piece of text
so *no_ further _formatting* is done here
```
***Should be bold AND italic***
* First li
* Second li
* Indented li
* Three columns in li
* Back to first level li
1. First li
1. Second li
1. Indented li
1. Three columns in li
1. Back to first level li
* Here's *italic* inside li
* here's **bold** inside li
* Here's ***bold + italic*** inside li
* Here they are in one line indented: *italic* **bold**
> Here's a long single-paragraph block quote. It should look pretty and stuff.
| A title |
| --- |
| Panel text |
|Heading 1|Heading 2|
| --- | --- |
|Col A1|Col A2|
|Col B1|Col B2|