Giter Club home page Giter Club logo

jira2markdown's People

Contributors

catcombo avatar zyv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

jira2markdown's Issues

ListIndent missing abstract method _generateDefaultName

I believe pyparser is requiring ListIndent to implement _generateDefaultName, per the following error received:

... temp = jira2markdown.convert(text) File "/home/.conda/envs/operations/lib/python3.10/site-packages/jira2markdown/parser.py", line 18, in convert markup << elements.expr(inline_markup, markup, usernames, elements) File "/home/.conda/envs/operations/lib/python3.10/site-packages/jira2markdown/elements.py", line 64, in expr return MatchFirst([ File "/home/.conda/envs/operations/lib/python3.10/site-packages/jira2markdown/elements.py", line 65, in <listcomp> element(inline_markup=inline_markup, markup=markup, usernames=usernames).expr File "/home/.conda/envs/operations/lib/python3.10/site-packages/jira2markdown/markup/lists.py", line 85, in expr + ListIndent(self.indent_state, self.tokens) TypeError: Can't instantiate abstract class ListIndent with abstract method _generateDefaultName

Indentation breaks list recognition

Hello,

  • Thanks for the library, works like a charme in general.

  • I am using jira2markdown in version 0.2.1 in a poetry project.

  • if you use the visual editor in JIRA, you often get a blank in front of the list symbol. It is nonetheless correctly visualized in JIRA.

โฏ python
Python 3.10.5 (main, Jun 23 2022, 17:15:25) [Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import jira2markdown
>>> jira2markdown.convert('* Blue\n* Green')
'- Blue\n- Green'
>>> jira2markdown.convert(' * Blue\n * Green')
' \\* Blue\n \\* Green'

Add underline support

Would be nice to add underline support.
To do it now you can use the following code:

import jira2markdown
from jira2markdown.elements import MarkupElements
from jira2markdown.markup.text_effects import QuotedElement, Underline

text = "This is a +test+"


class CustomUnderline(QuotedElement):
    TOKEN = "+"
    QUOTE_CHAR = "<u>"
    END_QUOTE_CHAR = "</u>"


elements = MarkupElements()
elements.replace(Underline, CustomUnderline)

print(jira2markdown.convert(text, elements=elements))

license

Greetings,

This is great software. My only issue is there is no license. Could you kindly add a license so I can hopefully make use of your code?

Add github image support

Currently no attributes are supported (width, height), it would be nice to support these.
An example how this can be shown:

import re

import jira2markdown
from jira2markdown.elements import MarkupElements
from jira2markdown.markup.base import AbstractMarkup
from jira2markdown.markup.images import Image
from pyparsing import (
    Combine,
    Optional,
    ParserElement,
    ParseResults,
    PrecededBy,
    Regex,
    StringStart,
    Word,
    printables, )


class CustomImage(AbstractMarkup):
    def action(self, tokens: ParseResults) -> str:
        url = tokens.url
        attr_str = self._create_attribute_dict(tokens.attrs)
        return f'<img src="{url}" {attr_str} />'

    @property
    def expr(self) -> ParserElement:
        return (StringStart() | PrecededBy(Regex(r"\W", flags=re.UNICODE), retreat=1)) + Combine(
            "!"
            + Word(printables + " ", min=3, exclude_chars="|!").set_results_name("url")
            + Optional("|")
            + Word(printables + ",", exclude_chars="!").set_results_name("attrs")
            + Optional("!")
        ).set_parse_action(self.action)

    @staticmethod
    def _create_attribute_dict(attrs_str: str) -> str:
        attrs = {}
        for attr in attrs_str.split(','):
            key, value = attr.split('=')
            attrs[key] = value
        attr_str = " ".join([f'{k}="{v}"' for k, v in attrs.items()])
        return attr_str


elements = MarkupElements()
elements.replace(Image, CustomImage)
markdown_text = jira2markdown.convert("!image.png|width=200,height=400!", elements=elements)
print(markdown_text)

This will print

<img src="image.png" width="200" height="400" />

P.S. ChatGPT to the rescue for helping to find the correct parsing

Ordered lists always use "1."

Why do all elements in an ordered list start with "1." instead of incrementing? This is not how they show up in Jira.

Jira Markdown
# a
# numbered
# list
1. a
1. numbered
1. list

Example usage does not execute

I installed the module per the instructions:

pip install jira2markdown

I then copy and pasted the usage code into a python file.

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

When I run this application, I get the following output:

Traceback (most recent call last):
  File "C:\OneDrive\Powershell-Scripts\jira2markdown-sample.py", line 1, in <module>
    from jira2markdown import convert
  File "C:\OneDrive\Powershell-Scripts\jira2markdown.py", line 27, in <module>
    from jira2markdown import convert
ImportError: cannot import name 'convert' from partially initialized module 'jira2markdown' (most likely due to a circular import) (C:\OneDrive\Powershell-Scripts\jira2markdown.py)

I'm running Python 3.3.9 on Windows. I also tried running this using Python 3.8.10 in Ubuntu. I get a similar error.

Can't convert a link in a table in markup language.

Hi, I found that I can't convert a link in a table using jira2markdown.convert().

Here's my code:

import jira2markdown

markup = '||aa||bb||cc||dd||\n|row1|row1-1|row1-2|row1-3[mylink|https://www.google.com]|'
result = jira2markdown.convert(markup)
print(result) # shows '|aa|bb|cc|dd|\n|-|-|-|-|\n|row1|row1-1|row1-2|row1-3|\n'

As you can see from the result above, the link [mylink|https://www.google.com] disappears after the conversion.

I use python 3.8.17 in macOS Monterey 12.6 to run the above code.

And I use the latest version(0.3.4) of jira2markdown.

This error doesn't occur when I run it in macOS Ventura 13.4.1.

How can I run jira2markdown correctly in macOS Monterey 12.6?

What are the dependent libraries of jira2markdown?

Allow new version of pyparsing

jira2markdown pins pyparsing to < 3.0.0. Many new tools uses pyparsing > 3.0.0 and therefore creates pip conflicts if jira2markdown is used.

If there are no breaks, allow pyparsing > 3.0.0

Examples of overriding various markup to "plain text"?

First, thanks for a great library! ๐ŸŽ‰

I'd like to be able to convert more elements to "plain text", for example, when it sees {color:red}Red Text{color}, I'd like the conversion to only have Red Text.

I'm not familiar with pyparsing, so I'm wondering if you have suggestions on the "best" way to override the various classes in the markup directory.

Perhaps you can provide some examples of how to convert some of the various classes of markup to "just text"?

AttributeError

Hi,

First, thanks for this repo that is was I was looking for !

Hi installed it with pip (python 3.8.10)

When running I got :

Traceback (most recent call last):
  File "/home/pyd/Code/Jira-to-wikijs/test.py", line 1, in <module>
    from jira2markdown import convert
  File "/home/pyd/.local/lib/python3.8/site-packages/jira2markdown/__init__.py", line 1, in <module>
    from .parser import convert  # noqa
  File "/home/pyd/.local/lib/python3.8/site-packages/jira2markdown/parser.py", line 7, in <module>
    ParserElement.set_default_whitespace_chars("")
AttributeError: type object 'ParserElement' has no attribute 'set_default_whitespace_chars'

My test file is very easy I used the example you provided :

from jira2markdown import convert
print(convert("Some *Jira text* formatting [example|https://example.com]."))

Do you know what could have possibly go wrong ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.