Convert gnome-help (yelp) xml to static html with xslt - html

Some of the gnome applications on linux use a help browser called yelp. For example, the gnome-calculator, gcalctool, has its help files located in /usr/share/gnome/help/gcalctool
The folders there are then sorted by language. These help files essentially consist of an xml file and some accompanying png figures.
What I'm trying to do is convert this xml and its accompanying png figures into static HTML because I want to be able to properly view and navigate the document from a different browser (firefox). If you want to see what I'm talking about and you are on Linux, just run gcalctool and open the help menu.
Unfortunately, opening the xml directly with firefox is not successful because there are no stylesheets and thus firefox doesn't know how to format it. I have read that gnome applications make use of a library called libxslt (http://xmlsoft.org/libxslt/) for applying stylesheets. I am not familiar with xslt at all. Are the stylesheets saved elsewhere, or embedded in the source when it is compiled?
I guess what I'm wondering is if it's possible to somehow use libxslt by itself or another tool to convert the xml and figures into static HTML, preferably in the same manner yelp does this when it executes, or in a manner that results in an exact/very similar output to what yelp displays.
Thanks

gcalctool uses docbook. Yelp brings everything to display this xml format. You will find some projects to convert this docbook document to html on http://wiki.docbook.org/DocBookToXhtml.
best regards
Majo

Depending on how old your gcalctool is, its help files might be in DocBook or Mallard. If it's Mallard, you'll see a bunch of .page files. Otherwise, it's DocBook. Either way, you can use yelp-build to create HTML files. It's part of the yelp-tools package, and uses the same transformations as Yelp. For DocBook, pass the top-level XML file:
yelp-build html -o /path/for/output/ /path/to/gcalctool.xml
For Mallard, pass the directory containing the .page files:
yelp-build html -o /path/for/output/ /path/to/gcalctool/
yelp-build will build the HTML, copy the images and other media files, and take care of the CSS and JavaScript.

Related

hhc file of CHM to html

I have created a chm file using HTML Help workshop and it works fine in Windows. However the chm viewer used in Linux is not so good and I prefer not to use it in Linux. I am also restricted from using any other viewers in Linux. So I thought of decompiling the chm and create HTML files which can be used in Linux. However on decompiling, the hhc file generated, though contains the HTML tags, does not display properly in the browser.
<LI> <OBJECT type="text/sitemap">
<param name="Name" value="Main">
<param name="Local" value="Main.html">
</OBJECT>
The above code just displays only a bullet and nothing else. Is there a way by which the data in the param tags can be used. Like it displays Main as a link to Main.html.
NOTE: I don't want to use browser in Windows, so avoiding chm file as such is not a solution. Also I will have to make changes in multiple places if I use chm in Windows and separate HTML file for Linux. So the option I am thinking of is to use the HTML files generated by decompiling the chm in Linux.
You know, .hhc files contain the Table of Contents (TOC) for an HTMLHelp file (CHM), i.e. the entries displayed
in the left pane of the CHM viewer window. It's compiled into the CHM file.
An .hhc file is referred to as a sitemap file. Sitemap is a file format developed and proposed by Microsoft to the World Wide Web Consortium. Sitemap files control many navigation features for CHM files, such as the table of contents and index panes.
Please note HTMLHelp and all this is about 20 years old! The .hhc sitemap file was not standardised (standardized) by W3C e.g. as HTML5 and is a old proprietary Microsoft file format today.
I'd recommend using a so called web-based help under LINUX. If you really have permanent updates of your help topic content you'll need to survey your workflow.
Some thoughts (as I understand your needs):
Low budget and the man's way by using HTMLHelp Workshop (use of tools
recommended e.g. like FAR
HTML
Think about single-sourcing - one source of topics and different target formats (e.g. CHM, web-based (uncompressed help) on a server)
Think about your CHM file as a compiled web, create the HTML topics in structured folders like a web page (best use case for the wizards of FAR HTML)
Create a CHM file from source
Create a uncompressed web based help from source by uploading the web to Intranet or Internet (HTML files, images, ...), completed by a handmade Table of Contents derived from the .hhc file
But, don't decompile. Have single-sourcing in mind - I'd recommend using a time saver tool like mentioned above. To see what I mean navigate to following links:
Example 1: Uncompressed help - a bit dated
Example 2: FAR Web help created using FAR HTML.
For further information go to FAR HTML Tour and scroll down to uncompressed help.

How to convert an HTML file with content folder to a self-contained HTML file?

How do I convert an HTML file with content folder to a self-contained HTML file which can be viewed from anywhere with its images etc.
How can it be done so that it's also editable and stays self-contained, post-edit?
I basically need to make HTML file based documentation which can be viewed from anywhere. Unfortunately it HAS to be HTML, otherwise I would have made PDFs
You can use pandoc, it has an option to create self-contained html files https://pandoc.org/MANUAL.html#option--self-contained.
If you start with html, this is the command.
pandoc in.html --self-contained -o out.html
This tool can do a lot more things, for example, you can also generate html from markdown files or generate pdfs instead.
The most direct way is to convert all asset urls to data: urls. (There are online coverters available that will take a provided asset and produce a data: url from it.)
A possibly simpler way is to convert image and font urls to data: urls while instead inlining scripts and css.
Edit: Possibly of interest: inliner, a Node utility for doing this kind of thing. "Turns your web page to a single HTML file with everything inlined". Also performs a number of minifying optimizations.
I don't know exactly what you're envisioning, but HTML was never meant to be fully self-contained. There may be some loopholes that allow it in the end, but to my knowledge there are no premade tools that do this 'conversion'.
It would require the following things:
Converting all linked style sheets and scripts to inline style sheets and scripts. This means that whenever there's a <script src="http://url.to/foo.js"></script> you'll have to download foo.js and include it as such: <script type="text/javascript"> [this is the content of foo.js] </script>. Something similar applies to CSS and other linked source files.
Downloading all linked media (images mostly, I presume) and converting them to blobs (a service that provides you with a base64 blob you can use within a HTML file is https://www.base64-image.de/). This means replacing <img src="http://url.to/image.jpg" /> with <img src="data:image/png;base64,[converted image data goes here] />.
So there's gonna be some manual labour involved there, but it probably can be done (almost) fully.
Possibly there's a way to accomplish what you're wanting to do another way though, what exactly is your reason for wanting this?
Here's another option: write your documentation in markup, then use a tool such as "Marked 2" (http://marked2app.com) to convert to self-contained html. Works slick. Plus you can go back and edit the markup any time you need to update your documentation, then simply re-export your html file.

Is there a way to export a page with CSS/images/etc using relative paths?

I work on a very large enterprise web application - and I created a prototype HTML page that is very simple - it is just a list of CSS and JS includes with very little markup. However, it contains a total of 57 CSS includes and 271 javascript includes (crazy right??)
In production these CSS/JS files will be minified and combined in various ways, but for dev purposes I am not going to bother.
The HTML is being served by a simple apache HTTP server and I am hitting it with a URL like this: http://localhost/demo.html and I share this link to others but you must be behind the firewall to access it.
I would like to package up this one HTML file with all referenced JS and CSS files into a ZIP file and share this with others so that all one would need to do is unzip and directly open the HTML file.
I have 2 problems:
The CSS files reference images using URLs like this url(/path/to/image.png) which are not relative, so if you unzip and view the HTML these links will be broken
There are literally thousands of other JS/CSS files/images that are also in these same folders that the demo doesn't use, so just zipping up the entire folder will result in a very bloated zip file
Anyway -
I create these types of demos on a regular basis, is there some easy way to create a ZIP that will:
Have updated CSS files that use relative URLs instead
Only include the JS/CSS that this html references, plus only those images which the specific CSS files reference as well
If I could do this without a bunch of manual work, if it could be automatic somehow, that would be so awesome!
As an example, one CSS file might have the following path and file name.
/ui/demoapp/css/theme.css
In this CSS file you'll find many image references like this one:
url(/ui/common/img/background.png)
I believe for this to work the relative image path should look like this:
url(../../common/img/background.png)
I am going to answer my own question because I have solved the problem for my own purposes. There are 2 options that I have found useful:
Modern browsers have a "Save Page As..." option under the File menu, or in Chrome on the one menu. This, however does not always work properly when the page is generated by javascript
I created my own custom application that can parse out all of the CSS/Javascript resources and transform the CSS references to relative URLs; however, this is not really a good answer for others.
If anyone else is aware of a commonly available utility or something like that which is better than using the browser built in "Save page as..." option - feel free to post another answer.

Web application that compiles to swf

I have a swf template that can be used with different data input such as colors, texts etc. however i don't want to use the ordinary way of binding data to it such as xml. I would like the application to be able to produce a compiled swf with all the data in it.
Is it possible to inject the data in the compilation time?
Thanks
it should be, but depends on how much you want to mess around with the code of the template.
You can embed resources in flash, so you can just embed the XML with the information you want.
Then all you need to do if find the place in the code where it loads the XML file, and give it your own embedded XML file instead.
Yes it is possible, but only if you have access to the the source .fla file, so that you can generate a new .swf file from it.
If you simply want to change a few colors or other looks of some of the objects in the .fla file you should be able to do that without having to mess with xml, simply open the library items in Flash and edit their colors.
If you want to put your external assets within the actual .swf you can do that too, but if you already have it to pull external assets I would recommend keeping it that way.
For the XML, in ActionScirpt you can actually declare the XML within the actual Actionscript code. Open up the XML file and copy the the XML contents over to your code where it is parsing it.
For images you can simply drag image files directly on the stage or into the library.

Can I decompile a *.chm file to html with a html TOC using MS HTML Workshop? If not how can I?

When I decompile I get an hhc file and a hhk file and no index.html. Can I get MS HTML Workshop to generate a html table of contents index.html file instead when decompiling? If not is there any other free software I can use?
Afaik no. Creating a basic toc->html export would be very easy, since it is essentially a XML to html transformation, but it probably won't be in the style of the rest of the CHM.
Maybe one of the Unix CHM viewers perform such step to view the TOC with a html viewer somewhere. But recycling such code would probably be more work than rewriting it.