Table of Contents

Texinfo

This module documents the builtin texinfo language and parser.

Use

Hop.js extends the genuine texinfo syntax by supporting embedded Hop.js expressions. As JavaScript template strings, expression starting with the prefix ${ are evaluated and the result of this evaluation is added as is in the parsed HTML tree.

Functions

texinfo.loadDocument( file )

Parse a texinfo file and return an return it as an HTML document.

Parse a texinfo file. On success, returns an object with the following

texinfo.load( file )

Parse a texinfo file. On success, returns an object with the following properties:

The evaluation environment of the embedded expressions contains the following global variables:

texinfo.eval( string )

Parse a texinfo string. On success the result is an object with the following properties:

HTML

<texinfo.TEXINFO src charset fontifier>

A wrapper to the texinfo.eval function that let's texinfo documents be directly inserted into HTML containers.

Example:

This example shows how to embed markdown elements into HTML.

The example uses a service that returns an HTML document whose sole element is a markdown text. Before being delivered to the client, the markdown text is parsed and automatically compiled into HTML.

mdtag/mdtag.js

var md = require( hop.markdown );

service mdtag( o ) {
   var name = o && "name" in o ? o.name : "bar";
   return <html>
     <md.markdown>
toto n'est pas content

  * toto
  * tutu ${name}
  * titi
  
tutu non plus.
   </md.markdown>
</html>;
}

console.log( "Go to \"http://%s:%d/hop/mtag\"", hop.hostname, hop.port );