2014-01-08

Testing Online Code Syntax Highlighters for Blogs (5): Embedding Makefiles to a Web Page

In my previous post titled Fast Compilation and Execution of Source Code, I included a makefile. After I've been familiar with SyntaxHighlighter, I changed the code of the makefile so that the new tool is used. However, as I've written in my earlier post, SyntaxHighlighter has no makefile support [1], while highlight.js and google-code-prettify have that feature. [2] [3]
I think, therefore I am.
Réné Descartes (1596–1650)
In order to be sure about their claims, I've done a test and the results are as follow.
highlight.js:
hello: hello.c
    gcc -o hello hello.c
clean:
    rm -f hello
Maybe my makefile is too simple that it lacks some typical features for the automatic language recognition of highlight.js. Let's see the sample code copied from the official demo.
# Makefile

BUILDDIR      = _build
EXTRAS       ?= $(BUILDDIR)/extras

.PHONY: main clean

main:
    @echo "Building main facility..."
    build_main $(BUILDDIR)

clean:
    rm -rf $(BUILDDIR)/*
google-code-prettify
hello: hello.c
    gcc -o hello hello.c
clean:
    rm -f hello
Let's see a real one.
# Makefile

BUILDDIR      = _build
EXTRAS       ?= $(BUILDDIR)/extras

.PHONY: main clean

main:
    @echo "Building main facility..."
    build_main $(BUILDDIR)

clean:
    rm -rf $(BUILDDIR)/*
Unluckily, I can't figure out the way to include a tab, instead of whitespaces, for makefiles. Anyways, one who use makefiles will know that after running make on the first day.
References:
[1]: http://alexgorbatchev.com/SyntaxHighlighter/manual/api/autoloader.html
[2]: http://highlightjs.org/static/test.html
[3]: http://google-code-prettify.googlecode.com/svn/trunk/README.html

No comments:

Post a Comment