DMPRoadmap / roadmap

DCC/UC3 collaboration for a data management planning tool
MIT License
102 stars 109 forks source link

question text in docx export fails sometimes, depending on the html #3221

Open nicolasfranck opened 1 year ago

nicolasfranck commented 1 year ago

Please complete the following fields as applicable:

What version of the DMPRoadmap code are you running? (e.g. v2.2.0)

3.1.1

Behaviour:

Depending on the html in Question#text (see https://github.com/DMPRoadmap/roadmap/blob/master/app/views/shared/export/_plan.erb#L45), the result of <strong><%= question.text %></strong> fails when exporting to docx. A non working docx is returned

Steps to reproduce:

Put this in your question text (replace * by bullets in the editor):

What is your answer?

* yes
* no

Now it tries to convert

<strong>
  What is your answer<br><br>
  <ul>
    <li>yes</li>
   <li>no</li>
  </ul>
</strong>

but that fails. Removing the <br> helps. Removing <strong> altogether too.

cf. https://github.com/DMPRoadmap/roadmap/blob/master/app/views/shared/export/_plan.erb#L45 cf. https://github.com/karnov/htmltoword/issues/73

johnpinto1 commented 1 year ago

@nicolasfranck It has been suggested by @briri that you have patched this already. Is it possible to send a PR?

nicolasfranck commented 1 year ago

@johnpinto1 not really. Word is not HTML, and there is no way put everything in bold just by wrapping it between <strong> tags. Apparently that only works with regular text. Maybe we just allow too much in the question text? There will always be a case where someone constructs HTML in that rich text editor that is not allowed in docx. Maybe someone puts an entire table in bold? And it possibly breaks the html layout you put it in.

briri commented 1 year ago

Ahh ok. @nicolasfranck have your users encountered the issue more than just this one occasion? We have only seen it happen once in the DMPTool.

I ask this because if has only happened a few times then we may want to place this issue in the backlog because it will possibly be a lot of effort and there are more pressing issues we should address.

johnpinto1 commented 1 year ago

@nicolasfranck Thanks for the quick clarification.

nicolasfranck commented 1 year ago

It hasn't happen a lot. But it is something to take into account when making an interface for entering questions: do we want our users to markup the title of a question knowing that the entered markup will possibly break the intended markup in the resulting html page.

johnpinto1 commented 1 year ago

@briri I think @nicolasfranck makes a good suggestion. I will work on removing any markup for question text. We can then discuss if what I do is a sutable solutioin.