Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJérémy Lal <kapouer@melix.org>2010-07-14 16:10:17 +0400
committerRyan Dahl <ry@tinyclouds.org>2010-07-14 20:52:59 +0400
commitfb645f75fb45d5bf70f3d05a586ea067ff273ee5 (patch)
tree7b7349d3732f0c7aa261491dd173fcfe3064782f /tools
parent50c38dec705b3ebfd073bfa6c835572eb1527db8 (diff)
Update ronnjs (fix rendering of html self-closing tags)
Diffstat (limited to 'tools')
-rw-r--r--tools/ronnjs/lib/ext/markdown.js32
-rw-r--r--tools/ronnjs/lib/ronn.js4
2 files changed, 19 insertions, 17 deletions
diff --git a/tools/ronnjs/lib/ext/markdown.js b/tools/ronnjs/lib/ext/markdown.js
index f46f59533df..4c610f9554a 100644
--- a/tools/ronnjs/lib/ext/markdown.js
+++ b/tools/ronnjs/lib/ext/markdown.js
@@ -1252,11 +1252,12 @@ expose.renderJsonML = function( jsonml, options ) {
options = options || {};
// include the root element in the rendered output?
options.root = options.root || false;
+ options.xhtml = options.xhtml || false;
var content = [];
if ( options.root ) {
- content.push( render_tree( jsonml ) );
+ content.push( render_tree( jsonml, options.xhtml ) );
}
else {
jsonml.shift(); // get rid of the tag
@@ -1265,14 +1266,14 @@ expose.renderJsonML = function( jsonml, options ) {
}
while ( jsonml.length ) {
- content.push( render_tree( jsonml.shift() ) );
+ content.push( render_tree( jsonml.shift(), options.xhtml ) );
}
}
- return content.join( "\n" ).replace( /\n+$/, "" );
+ return content.join( "\n\n" );
}
-function render_tree( jsonml ) {
+function render_tree( jsonml, xhtml ) {
// basic case
if ( typeof jsonml === "string" ) {
return jsonml.replace( /&/g, "&amp;" )
@@ -1289,24 +1290,25 @@ function render_tree( jsonml ) {
}
while ( jsonml.length ) {
- content.push( arguments.callee( jsonml.shift() ) );
+ content.push( arguments.callee( jsonml.shift(), xhtml ) );
}
var tag_attrs = "";
for ( var a in attributes ) {
tag_attrs += " " + a + '="' + attributes[ a ] + '"';
}
-
- var newlinetab = "\n ",
- newline = "\n";
-
- if ( ~["em", "strong", "img", "br", "a"].indexOf( tag ) ) {
- newlinetab = "";
- newline = "";
- }
-
+
+ // if xhtml, self-close empty tags
// be careful about adding whitespace here for inline elements
- return "<"+ tag + tag_attrs + ">" + newlinetab + content.join( "" ).replace( /\n$/, "" ).replace( /\n/g, "\n " ) + newline + "</" + tag + ">" + newline;
+ var markup = "<"+ tag + tag_attrs;
+ var contentstr = content.join( "" );
+ if ( xhtml && contentstr.length == 0 ) {
+ markup += " />";
+ }
+ else {
+ markup += ">" + contentstr + "</" + tag + ">";
+ }
+ return markup;
}
function convert_tree_to_html( tree, references ) {
diff --git a/tools/ronnjs/lib/ronn.js b/tools/ronnjs/lib/ronn.js
index 884d91cd00a..aadcb3da606 100644
--- a/tools/ronnjs/lib/ronn.js
+++ b/tools/ronnjs/lib/ronn.js
@@ -267,11 +267,11 @@ exports.Ronn = function(text, version, manual, date) {
function toHTML(node) {
// problème ici : les & sont remplacés par des &amp;
- return md.renderJsonML(node, {root:true});
+ return md.renderJsonML(node, {root:true, xhtml:true});
}
function toHTMLfragment(node) {
- return md.renderJsonML(node);
+ return md.renderJsonML(node, {xhtml:true});
}
function comment(out, str) {