jira2markdown
is a text converter from JIRA markup to YouTrack Markdown using parsing expression grammars. The Markdown implementation in YouTrack follows the CommonMark specification with extensions. Thus, jira2markdown
can be used to convert text to any Markdown syntax with minimal modifications.
- Python 3.7+
pip install jira2markdown
from jira2markdown import convert
convert("Some *Jira text* formatting [example|https://example.com].")
# >>> Some **Jira text** formatting [example](https://example.com).
# To convert user mentions provide a mapping Jira internal account id to username
# as a second argument to convert function
convert("[Winston Smith|~accountid:internal-id] woke up with the word 'Shakespeare' on his lips", {
"internal-id": "winston",
})
# >>> @winston woke up with the word 'Shakespeare' on his lips
Jira | Markdown |
---|---|
h1. Biggest heading |
# Biggest heading |
h2. Bigger heading |
## Bigger heading |
h3. Big heading |
### Big heading |
h4. Normal heading |
#### Normal heading |
h5. Small heading |
##### Small heading |
h6. Smallest heading |
###### Smallest heading |
Jira | Markdown |
---|---|
*strong* |
**strong** |
_emphasis_ |
Not converted (the same syntax) |
??citation?? |
<q>citation</q> |
-deleted- |
~~deleted~~ |
+inserted+ |
inserted |
^superscript^ |
<sup>superscript</sup> |
~subscript~ |
<sub>subscript</sub> |
{{monospaced}} |
`monospaced` |
bq. Some block quoted text |
> Some block quoted text |
{quote}Content to be quoted{quote} |
> Content to be quoted |
{color:red}red text!{color} |
<font color="red">red text!</font> |
Jira | Markdown |
---|---|
\\ |
Line break |
--- |
— |
-- |
– |
Jira | Markdown |
---|---|
[#anchor] |
Not converted |
[^attachment.ext] |
[attachment.ext](attachment.ext) |
[http://www.example.com] |
<http://www.example.com> |
[Example|http://example.com] |
[Example](http://example.com) |
[mailto:[email protected]] |
<[email protected]> |
[file:///c:/temp/foo.txt] |
Not converted |
{anchor:anchorname} |
Not converted |
[~username] |
@username |
Jira | Markdown |
---|---|
|
|
|
|
|
|
|
|
Jira | Markdown |
---|---|
|
|
|
|
Jira | Markdown |
---|---|
|
|
Jira | Markdown |
---|---|
|
|
|
|
|
|
To customize the list of markup elements send it as an optional argument to convert
:
from jira2markdown import convert
from jira2markdown.elements import MarkupElements
from jira2markdown.markup.links import Link
from jira2markdown.markup.text_effects import Bold
# Only bold and link tokens will be converted here
elements = MarkupElements([Link, Bold])
convert("Some Jira text here", elements=elements)
Keep in mind that the order of markup elements is important! Elements are matching first from top to bottom in the list.
To override some elements in the default element list use insert_after
/replace
methods:
from jira2markdown import convert
from jira2markdown.elements import MarkupElements
from jira2markdown.markup.base import AbstractMarkup
from jira2markdown.markup.links import Link
from jira2markdown.markup.text_effects import Color
class CustomColor(Color):
...
class MyElement(AbstractMarkup):
...
elements = MarkupElements()
elements.replace(Color, CustomColor)
elements.insert_after(Link, MyElement)
convert("Some Jira text here", elements=elements)