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

README example doesn't work #5

Open
adelphes opened this issue Aug 30, 2018 · 5 comments
Open

README example doesn't work #5

adelphes opened this issue Aug 30, 2018 · 5 comments

Comments

@adelphes
Copy link

Just running the basic example shown in your README doesn't work.

$ npm install @iarna/rtf-to-html
+ @iarna/rtf-to-html@1.1.0
added 12 packages in 1.829s

$ cat index.js

const rtfToHTML = require('@iarna/rtf-to-html')

rtfToHTML.fromString('{\\rtf1\\ansi\\b hi there\\b0}', (err, html) => {
  console.log(html)
  // prints a document containing:
  // <p><strong>hi there</strong></p>
});

$ node index.js

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <style>
    body {
      margin-left: 90pt;
      margin-right: 90pt;
      margin-top: 72pt;
      margin-bottom: 72pt;
      font-size: 12pt;
      text-indent: 0pt;
    }
    </style>
  </head>
  <body>
    
  </body>
</html>

There's no content inside the <body> tag, no matter what RTF you pass.

Romick2005 added a commit to Romick2005/rtf-to-html that referenced this issue Jan 9, 2019
@cspmosh
Copy link

cspmosh commented Jul 16, 2019

Getting the same as above. Using the example from the README, getting a empty body.

@Romick2005
Copy link
Contributor

Can we close this?

iarna pushed a commit that referenced this issue Jul 9, 2021
@iangilman
Copy link

It's still not working for me. I'm using the npm version, and it doesn't look like it has the fix. I guess someone needs to do a fresh npm publish?

@OphtelDev
Copy link

The problem is in renderPara function:
it assumes that para is a Paragraph but it can be a Span too,

So I replaced line 82 with :
if (!para.content || para.content.length === 0) return renderSpan(para, defaults)

And it works

Please fix it in the project

@iangilman
Copy link

iangilman commented Jun 13, 2023

Indeed. A similar fix is actually already on the master branch here:

.map(para => renderPara(para.content ? para : {content: [para], style: {}}, defaults))

But it hasn't been pushed to npm, so if you're using the npm version, it's broken. For my project, I just downloaded the code from here.

Hopefully someone involved in this library will push the latest version to npm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants