# Include source text from URI (e.g., Wikipedia)

## Background

Wikipedia content is reasonably current and free to use. Consider the tabular content at:

http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks#Java

## Problem

Copying & pasting the content from Wikipedia into a LaTeX document, converting the content from HTML to LaTeX, is wasteful for a few reasons:

• The Wikipedia content is subject to change over time.
• Duplication of content is error prone.
• It takes a lot of time to manually convert the HTML.

What would be ideal is to have a package that can import content (such as tabular data) from a given URI. In the case of tables, it would be especially useful to select the desired columns.

## Question

What approaches would you recommend to dynamically include content into a LaTeX document that is sourced from a URI?

(In the Wikipedia case, the table id does not exist, making it technically challenging to find the correct table. Although the implementation could look for the first table found.)

## Ideas

Something like:

\importuri{"http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks#Java"}%


Where table_id is optional.

The URI could be written in-line (or force an automatic bibtex entry).

-
That would be pretty hard to do from inside of TeX, as it isn't even able to connect to the Internet. Maybe it is possible with LuaTeX. It is probably easiest with an external script in the programming language of your choice. – Caramdir Feb 27 '11 at 1:19
Of course this sort of thing is trivial with iTeX* ;-). – Caramdir Feb 27 '11 at 1:21
Please keep in mind that tex.sx is for Q&A and not for package requests. Anyway, this is something which must be done by an external tool. The mentioning of automatic bibtex entry remembers me on import features of JabRef. However, I doubt it can import HTML tables or the Wikipedia format of them. – Martin Scharrer Feb 27 '11 at 1:46

With a bit of scripting, it is easy to load external content into a TeX format. For example, I have defined a command \issueTitle[N], which then loads a value of N like so:

\def\issueTitle[#1]{%
\ifthenelse{\equal{#1}{166}}{PHP implementation of set_property will likely corrupt properties file}{}%
\ifthenelse{\equal{#1}{167}}{Add documentation to all model elements for ModelDoc}{}%
\ifthenelse{\equal{#1}{130}}{Automatically mark containers of deleted generated elements as overridden}{}%
...
}


The code behind translating a URL (a Google API in my case) into TeX is probably outside the scope of this answer, but I use PHP, file_get_contents or CURL, and XML DOM. I then have a batch script to automatically update this file, which is called as part of my normal build.

-