Lynx and XHTML

This page describes how to make lynx render local XHTML files (files with .xhtml extension). This might be useful, for example, if you want to read documentation in XHTML saved on the disk. Unfortunately current version of lynx (2.8.4 at the time this is written) does not support XHTML yet, so it will only be able to render HTML compatible XHTML.

Also you may find that lynx can already handle XHTML files for you. This is due to the fact that older /etc/mime.types file does not define proper file extensions for application/xhtml+xml mime type. Once you upgrade your mime.types things will most likely break.

In essence, the idea of making lynx render .xhtml files boils down to overriding correct mapping in /etc/mime.types that looks something like this:

application/xhtml+xml    xhtml

with incorrect that looks like this

text/html                xhtml

It is not such a good idea to do it in /etc/mime.types because it will affect other users and applications (like apache). A better solution would be to override it in your ~/.lynx.conf:

# .lynx.conf

# Include default configuration file. Note that you may
# need to adjust path according to your installation.

# Make lynx treat .xhtml files like .html .

Also you will need to add something like this to your .bash_login or .profile:

# Lynx configuration file.
export LYNX_CFG=~/.lynx.conf

You can save this page and use it as a test for your new lynx configuration.

Note, however, that this method won't help you in accessing XHTML page on the web that are served as application/xhtml+xml. There is no easy fix for this problem. Of course one can always implement XHTML support in lynx. The other solutions requires tricky content negotiation between user agent (lynx in our case) and web server (that's what the server from which you are viewing this page does).