Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nicolasfranck opened this issue Oct 20, 2022 · 6 comments
Open
Assignees
Labels
bug effort-small less than 1/2 day of dev time templates

Comments

@nicolasfranck
Copy link
Contributor

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. karnov/htmltoword#73

@johnpinto1
Copy link
Contributor

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

@nicolasfranck
Copy link
Contributor Author

nicolasfranck commented Dec 13, 2022

@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
Copy link
Contributor

briri commented Dec 13, 2022

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
Copy link
Contributor

@nicolasfranck Thanks for the quick clarification.

@nicolasfranck
Copy link
Contributor Author

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
Copy link
Contributor

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug effort-small less than 1/2 day of dev time templates
Projects
None yet
Development

No branches or pull requests

3 participants