Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Convert HTML into JIRA format C#.Net

Hi @Nir Haimov 

 

Can you please help me that how to convert from HTML into JIRA format using C# or javascript?

5 answers

Hello @Nir Haimov

I am using the html-2-jira-markup  nuget package manager.  But facing the problem with ul, ol tag. Can you please suggest is there way to resolve this.

Nir Haimov Community Leader Sep 02, 2021

Hi @Milind Suresh Nikam 

Please share the HTML string you are trying to convert and the output converted string you get

Hello @Nir Haimov

Html String

<b>From</b>: Test \\\\<b>To</b>: Test \\\\<b>Subject</b>: Test for Bullet points \\\\<b>Email Body</b>: <p>Hello,</p><p>&nbsp;</p><p>This is a<strong> test email.</strong></p><ul><li>test</li><li>test</li></ul><p><strong>checking below:</strong></p><ol><li>test</li><li>test</li></ol><p>Thank you,</p><p>&nbsp;</p><p><strong>Test </strong><i>Test<strong> </strong>Test</i></p><p>Test</p>

Nir Haimov Community Leader Sep 02, 2021

@Milind Suresh Nikam and what string you get when you try to convert this?

Also, why you have multiple \\\\ in your HTML string?

Hello @Nir Haimov

I am using this for commenting email subject and body into jira comment. so after subject i want new line so i have added \\

Nir Haimov Community Leader Sep 02, 2021

ok @Milind Suresh Nikam i will check it out

Nir Haimov Community Leader Sep 02, 2021

instead of adding \\\\ use html tag <br>

Nir Haimov Community Leader Sep 03, 2021

new version 1.0.4 published with a fix

Like Patrick Le Garrec likes this

 

Hello @Nir Haimov 

It work's. Thank you for quick response

0 votes
Nir Haimov Community Leader Aug 18, 2021

Hi, this does not work for me:

original string :

<p>Le prix total d&#39;un computer ne peux jamais d&eacute;passer 1000 $<br />
Le contr&ocirc;le est effectu&eacute; sur la page caddie.</p>

 

after using Jira markup Html2JiraMarkup, here is the converted string :

\ \Le prix total d&#39;un computer ne peux jamais d&eacute;passer 1000 $<br />\Le contr&ocirc;le est effectu&eacute; sur la page caddie.\


REST Error 400

After doing this :

private static string CleanStringDescription(string str)
{
string s = HttpUtility.HtmlDecode(str);
string cleanStr;
cleanStr = Regex.Replace(s, @"\n", "");
cleanStr = Regex.Replace(cleanStr, @"\r", "");
cleanStr = Regex.Replace(cleanStr, @"\t", "");
cleanStr = Regex.Replace(cleanStr, @"<p>", "");
cleanStr = Regex.Replace(cleanStr, @"</p>", "");
cleanStr = Regex.Replace(cleanStr, @"<br />", "");

return cleanStr;
}

 

It works ! 

Le prix total d'un computer ne peux jamais dépasser 1000 $Le contrôle est effectué sur la page caddie.

 

I hope this help.



Nir Haimov Community Leader Aug 18, 2021

Hi @Patrick Le Garrec 

except for the <br /> that i will fix, there is nothing to do with Html2JiraMarkup to "REST Error 400"

If the API fails for you that because something you are not doing right.

In worst case, Html2JiraMarkup will convert partial of the HTML string but the still the string will be post to Jira, even if you just send HTML as is to Jira, it will post it, and you will see all the HTML tags in your Jira field, so in any case this should not fail in API, unless you are doing something wrong, and it's not related to the conversion of the HTML string

Yes, you are right.

i edit the post to share the way i fixed the issue. 

Nir Haimov Community Leader Aug 18, 2021

I updated the Html2JiraMarkup package, so now your <br /> will be changed

Like Patrick Le Garrec likes this

i edit the post to share the way i fixed the issue. 
The string is taken from the debugger on local (text format), just after the use of the lib, 


and finaly, got a rest error with the wrong string.


The only way i found is to use the HttpUtility shipped with .Net framework.

Thanks Nir :)   you are very reactive 

Hi @Nir Haimov 

 

can you please try to create and publish for .Net Core so that would be great as of now .Net core is more usable than standard one and thank you so much for looking into this.

Nir Haimov Community Leader Jul 19, 2021

Hi @Kapil Soni 

I will try to to create something, but can't promise anything, i might be able to create a solution only for part of the conversion from HTML to Jira and not all of it.

I will do my best and keep you update

Hi @Nir Haimov 

 

Thank you so much for quick prompt and its enough for all of us to convert HTML to Jira. Meanwhile day after will post my solution here which covers around 95% HTML to Jira convert using javascript/jQuery.

Hi @Kapil Soni @faisalamdani @Michael Cowan @Noah Povis 

I create a nuget package:
https://www.nuget.org/packages/Html2JiraMarkup/

you are welcome to download and use it.

No need to mention i tested it and it works for me, but i didn't tested all use cases, so let me know if something not converting well

Once you confirm it works fine, i will post an article so anyone who will search for the same solution will find it easily.

Like faisalamdani likes this

Hi @Nir Haimov 

 

Thank you so much and I will surely look into and let you know if I encounter any bug.

 

kapil

Hello @Nir Haimov 

I am working on angular how I will use this package?

Or there is any other npm package?

Nir Haimov Community Leader Jul 23, 2021

Hi @faisalamdani 

This package is for C#, it's not a npm package.

Angular is your front-end... if you are using C# in your backend you can use this package. 

What is your backend?

Nir Haimov Community Leader Jul 28, 2021

@Kapil Soni any update?

Hi @Nir Haimov 

Will provide you update here by End of this week. Due to some project related urgency i wouldn't got chance but for sure by end of this week will validate this and keep you posted here

Nir Haimov Community Leader Aug 10, 2021

Hi @Kapil Soni 

Any update? :)

Hi, is it possible to use your package with nodejs?

Nir Haimov Community Leader Aug 18, 2021

Hi @Felipe Santos 

No,

But when i  will get time, i will create npm package so it will be available for you too

Like Felipe Santos likes this
Like Felipe Santos likes this

@Nir Haimov thanks, you saved my life sz

@Nir Haimov Do you have any package for Java. To Convert HTML to Jira MarkUp

0 votes
Nir Haimov Community Leader Jul 20, 2020

Hi @Kapil Soni 

I'm not really familiar with a way to achieve this.

Try the answer on this post:

https://community.atlassian.com/t5/Jira-questions/Jira-Text-Formatting-to-HTML-JavaScript-Parser/qaq-p/607235

I am REALLY confused how Jira has not provided a simple SDK or tool to convert HTML into the Jira Markup for use with the REST API. Does everyone have to painfully map HTML tags to markup blocks? 

yeah i agree this is ridiculous

@Michael Cowan  @Kapil Soni I am also facing the same issue.

there is one npm module is present though its not converting it properly but you can give it a try

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you