How to get the whole code of a HTML element in Developer tools? - google-chrome-devtools

I'm looking for possibility to export or just copy the whole code of a HTML element, targeted with Developer Tools. With whole code I mean not only HTML (this option is good visible in context menu), but corresponding CSS and JS code too.
I found a Chrome extension, which claims to copy HTML and CSS, but it isn't reliable in its core function and doesn't copy JS at all.

Related

Visual Studio Code - Live Server - Html Displays but no CSS markup

I have used VSC with LiveServer for some years with only 1 problem, back a few years ago when either LiveServer or Windows10 had an update installed, next time I opened my HTML file in LiveServer, the HTML was rendered in a "basic" layout, and did not include my CSS Styles.
On an Internet search I found a solution for either this site or similar where I needed to add a line of code to either LS or Windows, sorry but I cant remember which. And all was well again until, now. The very same problem has returned, and no matter how much I search, I cant fine the solution.
There are plenty where there were errors in HTML or CSS, but this is occurring on files which haven't changed, and on new ones from the same master I use for my new pages. The screenshot included shows the HTML, LS as basic HTML and how the page loads on the browser directly. I am using Chrome, but have tried on Firefox with same results.
How LS displays and how it should be
You need to open your VS Code project from a directory that contains your HTML and CSS.
Your HTML document is in the root directory of your project (hence the URL being /filename) but you are trying to load CSS from ../../css/filename.
The project needs to be two directories higher for the webserver to include that path.

is it possible to view a question with a browser before importing it to Moodle?

I have created a XML file using R-exams out of just a single exercise to be imported to Moodle. I would like to view it before uploading it in the Moodle question bank. I tried to open it with Firefox and I can see some code but not the output and a message appear saying that the XML file does not seem to have a style sheet associated to it. Is there a way to find this style sheet and to see how the question comes out just using a browser like Firefox or Chrome?
To emulate how the R/exams exercises are converted to HTML by exams2moodle() and how Moodle displays mathematical content, it's best to use
exams2html(..., converter = "pandoc-mathjax")
In recent versions of R/exams the resulting HTML file then automatically loads the MathJax Javascript that enables correct rendering of mathematical content in all modern browsers (including Google Chrome). See also http://www.R-exams.org/tutorials/math/ for some general advice about math in HTML.
To the best of my knowledge there is no tool that would quickly display Moodle XML files in such a way that you can easily assess them.

How does GitHub's Gist embed work?

Let's suppose that I have a file named my_python_code.py, and I upload it to GitHub's gist. Now I embed that gist into my blog, using the code provided by GitHub on the corresponding page.
When I browse my blog and I check the source code for the page, I discover that:
the embed code calls a js file which performs some DocumentWrite commands, inserting the appropriate html tags (with css styles) on my page, and
the associated css file is linked to my page. This file contains css declarations for 'gist' class as well as other classes.
This is all very nice. But I wonder: starting from the same my_python_code.py file, what would I have to do to end up with the same final html code?
I've tried using pygments and rouge (via pygmentize and rougify commands) with reasonable options but none of them highlights the original code using 'gist' tags (among others) as is done when performing the GitHub embed.

Unity web open custom html after build

I made a custom html file for my Unity web project. Though after building my project, it opens the default pre-made one. Is there a way to make Unity open my own html file instead of the default one?
You're looking for the Web Player Templates manual page.
In your Assets folder, create a folder named WebPlayerTemplates, and put your template in there. You'll need an HTML file. To help make this slightly easier, Unity will look in that HTML for certain tokens that it can replace with data from the project.
For example, one such tag is %UNITY_WEB_PATH%, which will be replaced with the path to your built project file.
Some tags include:
UNITY_WEB_NAME Name of the webplayer.
UNITY_WIDTH UNITY_HEIGHT Onscreen width and height of the player in
pixels.
UNITY_WEB_PATH Local path to the webplayer file.
UNITY_UNITYOBJECT_URL In the usual case where the page will download
UnityObject2.js from the Unity’s website (ie, the Offline Deployment
option is disabled), this tag will provide the download URL.
UNITY_UNITYOBJECT_DEPENDENCIES The UnityObject2.js have dependencies
and this tag will be replaced with the needed dependencies for it to
work properly.
In every deployment I've seen, the WebPlayer plugin is is launched via JavaScript, by instantiating a UnityObject2 and calling its initPlugin method:
var u = new UnityObject2();
u.initPlugin(jQuery("#unityPlayer")[0], "Example.unity3d");
The above assumes that you have a div with id #unityPlayer, and that Example.unity3d is a valid path to your Unity build file.
In practice, though, I recommend working from Unity's generated HTML files; they include some failsafes for cases where the WebPlayer plugin isn't installed or fails to load. The manual page linked above also has HTML source examples which include some of those special tags.
UnityObject2 does have some advanced features, which are also documented in the manual. If your game needs to communicate with the outer web page, that is also possible.

is there any way to output the html from google chrome developer tools?

I have a website that uses javascript to change the HTML dynamically based on input. I use google developer tools to examine the HTML at any particular moment in the lifetime of the page. Is there any way easy way to output the HTML from the elements tab to a file or to the clipboard (so that I can run it thru a validator for debugging)? Control + A does not allow me to select all of the HTML.
You can Copy the <html> element as HTML:
... but you can do this easier at the console:
copy(document.documentElement.outerHTML);
Note that neither of these will copy the doctype. Also this is the serialization of the live DOM which could be totally different than the markup you served. But you know that.