Giter Site home page Giter Site logo

htmlpreview.github.com's Introduction

GitHub & BitBucket HTML Preview

Many GitHub repositories don't use GitHub Pages to host their HTML files. GitHub & BitBucket HTML Preview allows you to render those files without cloning or downloading whole repositories. It is a client-side solution using a CORS proxy to fetch assets.

If you try to open raw version of any HTML, CSS or JS file in a web browser directly from GitHub, all you will see is a source code. GitHub forces them to use the "text/plain" content-type, so they cannot be interpreted. This script overrides it by using a CORS proxy.

Usage

In order to use it, just prepend this fragment to the URL of any HTML file: https://htmlpreview.github.io/? e.g.:

What it does is: load HTML using CORS proxy, then process all links, frames, scripts and styles, and load each of them using CORS proxy, so they can be evaluated by the browser.

GitHub & BitBucket HTML Preview was tested under the latest Google Chrome and Mozilla Firefox.

License

© 2019 Jerzy Głowacki under Apache License 2.0.

htmlpreview.github.com's People

Contributors

0xflotus avatar geoffroy-aubry avatar kolomenkin avatar niutech avatar szepeviktor avatar trianguloy avatar wom-bat avatar yellowdoge avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

htmlpreview.github.com's Issues

Recent replaceAssets change can cause infinite loop in Chrome

It appears that in Chrome the loop in replaceAssets iterating over the documents scripts can get stuck. It appears that the document.write of the outerHtml (for scripts with no src attribute) itself causes the script array to grow by 1, so the loop continues, consuming CPU and memory until it presumably runs out of memory.

Problem can be seen at this URL.

Tests of Firefox and IE show that they seem unaffected by this. I'd be happy to help fix this, however the reasons for the latest commit changes are not clear to me, so I'd risk breaking again what was presumably getting fixed by the latest commits.

Mixed content errors prevent content loading

Github content is served over https, as is htmlpreview, but the part that discovers javascript/css via the Yahoo API is loading via http - leading to mixed content errors and a failure to load the preview in Chrome and Firefox. IE 11 will prompt for whether you want to load the insecure content.

Java 7 generated API docs are not displayed properly

Only the root index.html is rendered properly, other pages are missing their resources making some of the texts and links invisible.

As far as I can see the relative paths to images referenced in the css file are interpreted relative to the url of the document instead of the css file.

The same happens in Chrome and Firefox. IE refuses to display the page.

Here is such an API doc: http://htmlpreview.github.com/?https://github.com/kelemen/api-docs/blob/jtrim-core/api/index.html. This page is rendered properly but clicking on any class should reproduce the problem. For example: the upper menu bar is not displayed properly (missing its background).

Thank you for the page.

A Parser-blocking, cross-origin script ... error

When I try to use your (awesome, thank you so much for coming up with this idea) HTML preview tool for the URL:

 http://htmlpreview.github.io/?https://github.com/jacomyal/sigma.js/blob/master/examples/custom-node-renderer.html

I get a blank page, with only the following warning in my dev tools:

htmlpreview.min.js:1 A Parser-blocking, cross-origin script, http://query.yahooapis.com/v1/public/yql?q=use%20%22https%3A%2F%2Fraw.githurenderer.html%22&format=json&diagnostics=true&callback=HTMLPreview.loadHTML, is invoked via document.write. This may be blocked by the browser if the device has poor network connectivity.

Since the HTML file I'm trying to view doesn't even contain the phrase yahoo, this appears to be a problem with the tool.

License

Hello,

what is the license of your project? Can I reuse parts of it in my project? I see no license info anywhere

Thanks
Karel

Removal of Google ads

Hi,

While looking for a service that displays the contents for gists, I found your project. Since commit 136b43a, Google ads were injected in the landing page. Why were these added?

Can you add it (in the spirit of a public service, hosted by Github)?

Everything seems broken

Links to https://github.com are not preserved

I have HTML a document that points to: https://github.com/mitchellh/vagrant/issues/7610#issuecomment-234609660

The link is replaced by:
https://htmlpreview.github.io/?https://github.com/redhat-developer-demos/kubernetes-lab/blob/master/lab/readme.html#issuecomment-234609660

Support Gists too

Hopefully it should be straightforward to support Gist URLs as well.

Example gist:
https://gist.github.com/4329423

Example raw URL:
https://gist.github.com/raw/4329423/bae710bfc34fad43e782c85bc9f28dbd3cdcdfb8/index.html

Note that this URL also seems to work:
https://gist.github.com/raw/4329423/index.html

Also see a pretty webservice that renders gists with index.html:
http://bl.ocks.org/4329423

Keep in mind that it uses Github's Gist JS API, and I found that after a few minutes of browsing around that site my IP address was getting rate limited by Github.

Another service that renders gist (and a whole lot more):
http://plnkr.co/edit/gist:4329423?p=preview

linked images should be excluded from passing through htmlpreview (it breaks them)

Although with htmlpreview you can link .html documents hosted in the same repo with relative links, at the moment you cannot link to a .png or possibly any other image with the same mechanism.

I have created a small repo to test and demonstrate this.
When I go to
https://github.com/ens-lg4/htmlpreview-test
and follow the third link from the main README I get a rendered index.html file.
But if I then try to follow the third link in index.html , I get an error.

Somehow htmlpreview.github.io? prefix in front of image URLs breaks them. Because when I remove the prefix it works fine (same as the fourth link from the main README).

I believe URL in should only be auto-prefixed with htmlpreview.github.io? if the URL points to html/htm/xhtml document, or possibly also css or js (I'm not sure). But other files without further references such as images work fine without such a prefix.

Thanks for your time!

what about embedded links?

Your solution works just great for the one page - it's just what I need. BUT if I click on any embedded links - I just get the raw source for the target pages. Is there anything I can do about this?

Robert Ramey

Section intradocument links not working

I am trying to make section intradocument links working in my projects help pages.

Looked into #11 and see the example here:

http://htmlpreview.github.io/?https://raw.github.com/twbs/bootstrap/gh-pages/2.3.2/getting-started.html#contents

I implemented the same kind of sections as in the document above, but my links are not working:
http://htmlpreview.github.io/?https://raw.githubusercontent.com/barrydegraaff/pgp-zimlet/master/tk_barrydegraaff_zimbra_openpgp/help/index.html

I expect the links in Contents:
Why Use PGP?
Generating a new key pair
To be rewritten to go to htmlpreview.github.io, instead they keep pointing to the source.

What am I doing wrong? Probably user error, but I am not seeing it.

Thanks Barry

Preview works often only after 1 or 2 manual reloads

With

  • Firefox (Linux Version 49.0)

  • Chrome/HTMLView (Android 5.1.1)

  • Edge (Windows10)

  • Chrome (Windows 10)

    you often get no preview but instead a "No definition found for Table headers" as output. You need 1 or 2 reloads (F5...) to get the real previews opened.

I had this problem in the last 24 hours very often
Examples:

Error: Cannot load file [source]

When I try to load URL in GitHub & BitBucket HTML Preview I always get the message:
Error: Cannot load file [URL]

Can you fix it?

Cannot load html from rmarkdown

Hi,

I am not able to load a html generated with rmarkdown:
https://htmlpreview.github.io/?https://gitlab.com/mdehollander/biosb2016/raw/master/biosb2016.html

However, a file made by someone else using the same method works:
https://htmlpreview.github.io/?https://raw.githubusercontent.com/psu-psychology/neuro-521/master/neuro-521-gilmore-2016-01-12.html

Other html code hosted externally on gitlab for example works as well:
https://htmlpreview.github.io/?https://gitlab.com/oliver-salzburg/angular-timepicker/raw/master/demo.html

Any clue what is wrong with my html file?

htmlpreview rewrites links that use htmlpreview

My index.html is not loading/ getting error

Please advise>
I need to send a preview link of my git index.html page, and presently the preview format I learn to do is not working. I'm getting error.
I type in: http://htmlpreview.github.io/?https://github.com/teresab/IS_Project1/blob/master/index.html.

I have a successfully preview link for another html.index page (as follows):
http://htmlpreview.github.io/?https://github.com/teresab/project-1/blob/master/src/index.html

Please advise. I am new to git hub and need to submit preview link to this page by end of Monday Dec. 1.

A thousand thanks,
Teresa

Page cannot be loaded

I was browsing aglio's examples section when I ran into this bug.

Not sure why this happens, but the script seems to be hitting this line in loadHtml:

else
    HTMLPreview.previewform.innerHTML = 'Error: Cannot load file ' + HTMLPreview.raw();

External link is not preserved

I use htmlpreview for the following page : https://github.com/AliceO2Group/CodingGuidelines/blob/master/coding_guidelines.html

If you "toggle all summaries" at the top and search for "Getting" you will find the following line :

For more details: Getting #includes right.

The link should point to https://community.kde.org/Policies/Library_Code_Policy#Getting_.23includes_right with the following html :

<a href="https://community.kde.org/Policies/Library_Code_Policy#Getting_.23includes_right">Getting #includes right</a>.

But with htmlpreview it points to https://htmlpreview.github.io/?https://github.com/AliceO2Group/CodingGuidelines/blob/master/coding_guidelines.html#Getting_.23includes_right

How to preserver this external link ?

Thank you
Barth

Intradocument links (<a href="#foo"/>) don't work

(In Firefox, at least)

I think that this is because of the following code:

data.query.results.resources.content.replace(/<head>/i, '<head><base href="' + HTMLPreview.folder() + '">')

That should be relatively easy to fix by setting the base to the filename.

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.