%%
%% chopurl.sty
%%
%% This package is a hack to allow for proper linebreaks in
%% an url, without destroying the hyperlink capacities.
%%
%% Conceptually, the url is split up at every '/',
%% and instead of one href, there are mutiple href's:
%%
%% \url{http://somewhere.dk/bla/blubb/foo.html}
%% -expand to->
%%  \href{http://somewhere.dk/bla/blubb/foo.html}{http:/}\-%
%%  \href{http://somewhere.dk/bla/blubb/foo.html}{/}\-%
%%  \href{http://somewhere.dk/bla/blubb/foo.html}{somewhere.dk/}\-%
%%  \href{http://somewhere.dk/bla/blubb/foo.html}{bla/}\-%
%%  \href{http://somewhere.dk/bla/blubb/foo.html}{blubb/}\-%
%%  \href{http://somewhere.dk/bla/blubb/foo.html}{foo.html}
%% -------------------------------------------------------------------------
%% Known Problems:
%%  * does also allow split at the href:// place
%%  * cannot handle "~" - use \%7e instead !
%%  * cannot handle "_" - use \%5f instead !
%%
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% RELIES ON: hyperref, substr
%%      ** HAS TO BE INCLUDED AFTER THOSE PACKAGES ***
%% (since it redefines url)
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 
%% Synopsis:
%%  What I was told on comp.text.tex, that somthing with this
%%  (or better) functionality did not exist
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% @TABLE OF CONTENTS:                 [TOCD: 14:26 08 Dec 2001]
%%
%%      [0.1] AUX
%%  [1] Chopping an URL into pieces
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% @FILE:    chopurl.sty
%% @PLACE:   BRICS AArhus; host:harald
%% @FORMAT:  LaTeX 2e
%% @AUTHOR:  M. Oliver M'o'ller     <omoeller@verify-it.de>
%% @BEGUN:   Sun Oct 28 02:26:26 2001
%% @VERSION: Sun Dec  9 12:09:32 2001
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{hyperref}
\RequirePackage{substr}[2000/06/15]
%% ----------------------------------------------------
\ProvidesPackage{chopurl}[2001/12/09]

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% [0.1] AUX
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcounter{su@choppercounter}
%% -------------------------------------------------------------------------


%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% [1] Chopping an URL into pieces
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand*{\su@StringUrlSubstringChoper}[3]{%
  \su@IfSubStringInString{#2}{#1}{%
    \href{{#3}}{{\su@ExpandTwoArgs{#2}{#1}\su@BeforeSubString{\nobreak/}}}\-%
    \def\su@rest##1#2##2\@nil{##2}%
    \expandafter\su@StringUrlSubstringChoper\expandafter
    {\su@rest#1\@nil}{#2}{#3}%
  }{%
    \href{{#3}}{{#1}}%
  }%
}
%%
\newcommand*{\ChopUrlSubStrings}[2]{%
  \su@ExpandTwoArgs{#1}{#2}\su@ChopUrlSubStrings
        }
\newcommand*{\su@ChopUrlSubStrings}[2]{%
  \su@StringUrlSubstringChoper{#2}{/}{#1}%
        }
%% -------------------------------------------------------------------------
\renewcommand{\url}[1]{%
  \ChopUrlSubStrings{#1}{#1}%
}
%% -------------------------------------------------------------------------

\endinput

