Changeset - 441df63ee7cc
[Not reviewed]
0 4 3
Bradley Kuhn (bkuhn) - 10 years ago 2014-11-06 17:34:18
bkuhn@ebb.org
Hack tex4ht's overlib stuff to use jQuery tooltip

tex4ht supports "overlib" for footnote popups. The hack is pretty
straightforward; it dumps a Javascript area into a .js file that can
then be used by overlib to popup stuff.

This hack is to use that output to make the same thing work with jQuery
UI's tooltip widget.

Note that we run with overlib support first, then *without* it in the
Makefile setup. This is to force the needed .js file to be generated,
but make sure the HTML doesn't try to load overlib (which is default).

(This should be adapted as a patch to upstream tex4ht ultimately.)

Also included herein are improvements to the Makefile to build the HTML
output.
7 files changed with 137 insertions and 12 deletions:
0 comments (0 inline, 0 general)
Makefile
Show inline comments
...
 
@@ -9,4 +9,7 @@ BOOK_CLASS_FILE = gpl-book.cls
 

	
 
HTML_OUTPUT_DIR = public_html
 

	
 
TEX4HT=tex4ht
 
T4HT=t4ht
 
HTLATEX=htlatex
 
PDFLATEX = pdflatex
...
 
@@ -17,3 +20,3 @@ DVIPS=dvips
 

	
 
all:	err $(BOOK_BASE).pdf $(BOOK_BASE).ps $(BOOK_BASE).html
 
all:	err $(BOOK_BASE).pdf $(BOOK_BASE).ps html
 

	
...
 
@@ -21,2 +24,6 @@ pdf:	err $(BOOK_BASE).pdf
 

	
 
html:	$(HTML_OUTPUT_DIR)/monolithic/$(BOOK_BASE).html $(HTML_OUTPUT_DIR)/$(BOOK_BASE).html pdf $(BOOK_BASE).ps
 
	/bin/ln -f $(BOOK_BASE).ps $(HTML_OUTPUT_DIR)/$(BOOK_BASE).ps
 
	/bin/ln -f $(BOOK_BASE).pdf $(HTML_OUTPUT_DIR)/$(BOOK_BASE).pdf
 

	
 
.SUFFIXES: .fig .postscript .eps .pdf .pstex_t .pstex .ps .dvi .tex
...
 
@@ -47,10 +54,36 @@ $(BOOK_BASE).pdf: $(PDF_FIGS) $(LATEX_INPUT_FILES) $(BOOK_CLASS_FILE)
 
	$(PDFLATEX) $(BOOK_BASE)
 
	$(PDFLATEX) $(BOOK_BASE)
 

	
 
$(BOOK_BASE).html: $(LATEX_INPUT_FILES) $(BOOK_CLASS_FILE)
 
	echo "building HTML"
 
	$(LATEX)  '\def\generateHTML{\hfill}'  '\input'  $(BOOK_BASE).tex
 
	$(LATEX)  '\def\generateHTML{\hfill}'   '\input'  $(BOOK_BASE).tex
 
	$(TEX4HT) -f/$(BOOK_BASE).tex -i/$(BOOK_TEX_PATH)
 
	$(T4HT) -f/$(BOOK_BASE).tex
 
	rm $(BOOK_BASE).dvi
 
$(HTML_OUTPUT_DIR)/monolithic/$(BOOK_BASE).html: $(LATEX_INPUT_FILES) $(BOOK_CLASS_FILE)
 
	mkdir -p $(HTML_OUTPUT_DIR)/monolithic/js
 
	mkdir -p $(HTML_OUTPUT_DIR)/monolithic/css
 
	/bin/rm -f $(BOOK_BASE)*.html
 
	/bin/rm -f $(BOOK_BASE)*.js
 
	$(HTLATEX) comprehensive-gpl-guide.tex "webhacks,xhtml,mouseover"
 
	$(HTLATEX) comprehensive-gpl-guide.tex "webhacks,xhtml,mouseover"
 
	mv ${BOOK_BASE}*js $(HTML_OUTPUT_DIR)/monolithic/js
 
	/bin/rm -f $(BOOK_BASE)*.html
 
	/bin/rm -f $(BOOK_BASE)*.js
 
	$(HTLATEX) comprehensive-gpl-guide.tex "webhacks,xhtml"
 
	mv $(BOOK_BASE)*html $(HTML_OUTPUT_DIR)/monolithic
 
	mv cm*png $(HTML_OUTPUT_DIR)/monolithic
 
	mv ${BOOK_BASE}*css $(HTML_OUTPUT_DIR)/monolithic
 
	cp -pa js/*js $(HTML_OUTPUT_DIR)/monolithic/js
 
	cp -pa css/*css $(HTML_OUTPUT_DIR)/monolithic/css
 

	
 
$(HTML_OUTPUT_DIR)/$(BOOK_BASE).html: $(LATEX_INPUT_FILES) $(BOOK_CLASS_FILE)
 
	mkdir -p $(HTML_OUTPUT_DIR)/js
 
	mkdir -p $(HTML_OUTPUT_DIR)/css
 
	/bin/rm -f $(BOOK_BASE)*.html
 
	/bin/rm -f $(BOOK_BASE)*.js
 
	$(HTLATEX) comprehensive-gpl-guide.tex "webhacks,xhtml,3,next,mouseover"
 
	mv ${BOOK_BASE}*js $(HTML_OUTPUT_DIR)/js
 
	/bin/rm -f $(BOOK_BASE)*.html
 
	/bin/rm -f $(BOOK_BASE)*.js
 
	$(HTLATEX) comprehensive-gpl-guide.tex "webhacks,3,next,webhacks"
 
	mv ${BOOK_BASE}*css $(HTML_OUTPUT_DIR)
 
	mv ${BOOK_BASE}*html $(HTML_OUTPUT_DIR)
 
	mv cm*png $(HTML_OUTPUT_DIR)
 
	cp -pa js/*js $(HTML_OUTPUT_DIR)/js
 
	cp -pa css/*css $(HTML_OUTPUT_DIR)/css
 

	
...
 
@@ -61,4 +94,4 @@ $(BOOK_BASE).dvi: $(LATEX_INPUT_FILES) $(EPS_FIGS) ${BOOK_CLASS_FILE}
 
clean:
 
	/bin/rm -f $(BOOK_BASE).ps $(BOOK_BASE).pdf $(BOOK_BASE).log texput.log $(BOOK_BASE).lg $(BOOK_BASE).tmp $(BOOK_BASE).xref *.4ct *.4tc *.aux *.dvi $(BOOK_BASE)*.html *.idv *.lg *.tmp $(BOOK_BASE).css $(BOOK_BASE).log $(BOOK_BASE).out $(BOOK_BASE)-js.*
 

	
 
	/bin/rm -f $(BOOK_BASE).ps $(BOOK_BASE).pdf $(BOOK_BASE).log texput.log $(BOOK_BASE).lg $(BOOK_BASE).tmp $(BOOK_BASE).xref *.4ct *.4tc *.aux *.dvi $(BOOK_BASE)*.html *.idv *.lg *.tmp $(BOOK_BASE).css $(BOOK_BASE).log $(BOOK_BASE).out $(BOOK_BASE)-js.* cm*png
 
	/bin/rm -rf public_html
 
err: ; $(ERR)
README.md
Show inline comments
...
 
@@ -8,5 +8,7 @@ from the comprehensive-GPL-guide.tex file.
 

	
 
You can likely build a PDF file from:
 
You can build this project with the following command:
 

	
 
    $ pdflatex comprehensive-gpl-guide.tex && pdflatex comprehensive-gpl-guide.tex && pdflatex comprehensive-gpl-guide.tex
 
    $ make
 

	
 
HTML output will be in the public_html directory and a PDF file will be in  comprehensive-gpl-guide.pdf.
 

	
TODO.md
Show inline comments
...
 
@@ -3 +3,3 @@
 
* Document [creating an EPUB](http://tex.stackexchange.com/questions/1551/use-latex-to-produce-epub)
 
* Adapt the jQuery UI tooltip hack used for the overlib replacement with
 
  tex4ht to upstream tex4ht.
comprehensive-gpl-guide.tex
Show inline comments
...
 
@@ -26,2 +26,3 @@
 
\begin{document}
 

	
 
\pagestyle{plain}
css/footnote-hack.css
Show inline comments
 
new file 100644
 
/*  Released as CC0: http://creativecommons.org/publicdomain/zero/1.0/ */
 
/*   by Bradley M. Kuhn <bkuhn@ebb.org>  */
 

	
 
.ui-tooltip, .arrow:after {
 
background: black;
 
border: 2px solid white;
 
}
 
.ui-tooltip {
 
padding: 10px 20px;
 
color: white;
 
border-radius: 20px;
 
box-shadow: 0 0 7px black;
 
max-width: 50%;
 
}
 
.arrow {
 
width: 70px;
 
height: 16px;
 
overflow: hidden;
 
position: absolute;
 
left: 50%;
 
margin-left: -35px;
 
bottom: -16px;
 
}
 
.arrow.top {
 
top: -16px;
 
bottom: auto;
 
}
 
.arrow.left {
 
left: 20%;
 
}
 
.arrow:after {
 
content: "";
 
position: absolute;
 
left: 20px;
 
top: -20px;
 
width: 25px;
 
height: 25px;
 
box-shadow: 6px 5px 9px -9px black;
 
-webkit-transform: rotate(45deg);
 
-ms-transform: rotate(45deg);
 
transform: rotate(45deg);
 
}
 
.arrow.top:after {
 
bottom: -20px;
 
top: auto;
 
}
js/tex4ht-footnote-hack.js
Show inline comments
 
new file 100644
 
//  Released as CC0: http://creativecommons.org/publicdomain/zero/1.0/
 
//   by Bradley M. Kuhn <bkuhn@ebb.org>
 

	
 
$(function() {
 
$( ".footnote-mark" ).tooltip({
 
    items: "a",
 
    hide: { duration: 5000 },
 
    position: {
 
        my: "center bottom-20",
 
        at: "center left",
 
        using: function( position, feedback ) {
 
            $( this ).css( position );
 
            $( "<div>" )
 
                .addClass( "arrow" )
 
                .addClass( feedback.vertical )
 
                .addClass( feedback.horizontal )
 
                .appendTo( this );
 
        }
 
    },
 
    content: function() {
 
        var element = $( this );
 
        if ( element.is( 'a' ) ) {
 
            var footnoteVal = element.attr( "href" );
 
            return tex4ht[footnoteVal.substring(footnoteVal.search("#") + 1)];
 
        }
 
    }});
 
});
 
// $(function() {
 
// $( document ).tooltip({
 
// content: function() {
 
//     var element = $( this );
 
//     return "HI";
 
// }});});
webhacks.cfg
Show inline comments
 
new file 100644
 
\Preamble{xhtml}
 
\begin{document}
 
\Configure{@HEAD}{\HCode{<link rel="stylesheet" type="text/css" href="css/footnote-hack.css" /> \Hnewline}}
 
  \Configure{@HEAD}{\HCode{<script type="text/javascript" src="http://copyleft.org/jquery-1.10.2.js"></script>\Hnewline}}
 
  \Configure{@HEAD}{\HCode{<script type="text/javascript" src="http://copyleft.org/jquery-ui-1.11.2.js"></script>\Hnewline}}
 
  \Configure{@HEAD}{\HCode{<script type="text/javascript" src="js/comprehensive-gpl-guide-js.js"></script>\Hnewline}}
 
  \Configure{@HEAD}{\HCode{<script type="text/javascript" src="js/tex4ht-footnote-hack.js"></script>\Hnewline}}
 
\EndPreamble
0 comments (0 inline, 0 general)