Giter Site home page Giter Site logo

Comments (9)

yihui avatar yihui commented on May 18, 2024

That is odd. What is your version of RStudio and operating system?

from bookdown.

FvD avatar FvD commented on May 18, 2024

Ubuntu 14.04 with RStudio 0.99.878.

from bookdown.

yihui avatar yihui commented on May 18, 2024

I cannot reproduce it with the current release of RStudio 0.99.892 on Ubuntu 15.04: https://www.rstudio.com/products/rstudio/download/

from bookdown.

FvD avatar FvD commented on May 18, 2024

The issue persists after updating to RSTudio 0.99.892. I installed knitr from you github repo so that the version is 1.12.21 to solve some initial issues I had rendering the bookdown example in the inst folder. servr is at version 0.3.

To try to narrow the issue down I reduced the example in the inst folder to a minimal template and I can reproduce the issue with that smaller file-set. Perhaps I should update all your packages to the yihui-XRAN repo.

from bookdown.

yihui avatar yihui commented on May 18, 2024

I don't think this is relevant to knitr, because you said even servr::httd() for static HTML files had the same problem.

The possible reason is that your Ubuntu system does not recognize the MIME type of .html files. You may run the system command mimetype on any HTML file to see the output, or servr:::guess_type() on an HTML file. The expected output is text/html, and you system might give application/octet-stream.

from bookdown.

FvD avatar FvD commented on May 18, 2024

Yes, that is probably it!

 > servr:::guess_type("index.html")
 [1] "application/x-extension-html"

It appears to be an oddity introduced by installing firefox. Looking at /etc/mimetypes, everything seems to be in order:

~ ❯❯❯ grep html /etc/mime.types  
     [...]
     text/html                  html htm shtml

But in .local/share/applications

~/.l/s/applications ❯❯❯ ag "x-extension-html"
mimeapps.list
    25:application/x-extension-html=firefox.desktop
    66:application/x-extension-html=firefox.desktop;

I've never run into this before, so I will have a look how to change that.

from bookdown.

yihui avatar yihui commented on May 18, 2024

Do you know how to modify MIME types? If not, you may look at this article: https://help.ubuntu.com/community/AddingMimeTypes It is odd anyway; application/x-extension-html should not be the default MIME type for .html files on Ubuntu.

from bookdown.

FvD avatar FvD commented on May 18, 2024

Yes, it was in fact the mime type that was causing the issue. I am not sure which application made the change, but suspect it was Firefox at some point.

To change the mime type for html files back to the text/html default these were the steps I had to take. Remove the x-extension-html.xml and user-extension-html.xml files from the ~./local/share/mime folder and then rebuild the mime type database. In the steps below I do not delete the files, but copy them to the desktop.

mv ./local/share/mime/application/x-extension-html.xml ~/Desktop
mv ./local/share/mime/packages/user-extension-html.xml ~/Desktop

update-mime-database ~/.local/share/mime

Then log-out and log in again. The mimetype is now correct and the bookdown preview works as expected.

from bookdown.

github-actions avatar github-actions commented on May 18, 2024

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

from bookdown.

Related Issues (20)

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.