You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by ja...@apache.org on 2017/06/19 01:58:47 UTC
[04/29] ant-ivy git commit: improve the xooki2asciidoc convertor
improve the xooki2asciidoc convertor
Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/610c3be2
Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/610c3be2
Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/610c3be2
Branch: refs/heads/master
Commit: 610c3be2cd0105b6e838a69c682e65f594259a25
Parents: 64b328d
Author: Nicolas Lalevée <ni...@hibnet.org>
Authored: Sun Feb 15 23:35:52 2015 +0100
Committer: Nicolas Lalevée <ni...@hibnet.org>
Committed: Sun Feb 15 23:35:52 2015 +0100
----------------------------------------------------------------------
asciidoc-template/helpers.rb | 15 ++++---
build-doc.xml | 1 +
doc/xooki2asciidoc/xooki2asciidoc.js | 65 +++++++++++++++++++++++++++++--
3 files changed, 72 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/610c3be2/asciidoc-template/helpers.rb
----------------------------------------------------------------------
diff --git a/asciidoc-template/helpers.rb b/asciidoc-template/helpers.rb
index b11768b..e62557d 100644
--- a/asciidoc-template/helpers.rb
+++ b/asciidoc-template/helpers.rb
@@ -22,7 +22,12 @@ module IvyDocHelpers
def link(printpage)
l = ''
if self.url
- l += '<a href="' + printpage.relativeRoot + self.url + '"'
+ if self.url.start_with?('http')
+ url = self.url
+ else
+ url = printpage.relativeRoot + self.url
+ end
+ l += '<a href="' + url + '"'
if self.id == printpage.id
l += ' class="current"'
end
@@ -73,7 +78,7 @@ module IvyDocHelpers
def innermenu(page)
m = '<ul id="treemenu" class="treeview">' + "\n"
page.children.each do |p|
- m += '<li id="xooki-' + p.id + '"'
+ m += '<li id="xooki-' + (p.id || "undefined") + '"'
if p.children.length > 0
m += ' class="submenu"'
end
@@ -122,11 +127,11 @@ module IvyDocHelpers
p.title = node['title']
p.parent = parent
if node.has_key?("importRoot")
- p.id = path + child['importRoot'] + '/' + node['importNode']
+ p.id = path + node['importRoot'] + '/' + node['importNode']
p.url = p.id + ".html"
- toc = JSON.parse(IO.read(basedir + '/' + child['importRoot'] + "/toc.json"))
+ toc = JSON.parse(IO.read(basedir + '/' + node['importRoot'] + "/toc.json"))
toc['children'].each do |child|
- p.children << loadPage(basedir, p, child, path + child['importRoot'] + '/')
+ p.children << loadPage(basedir, node, child, path + node['importRoot'] + '/')
end
else
p.id = node['id']
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/610c3be2/build-doc.xml
----------------------------------------------------------------------
diff --git a/build-doc.xml b/build-doc.xml
index e9316f9..671da0e 100644
--- a/build-doc.xml
+++ b/build-doc.xml
@@ -48,6 +48,7 @@
<taskdef uri="antlib:org.asciidoctor.ant" resource="org/asciidoctor/ant/antlib.xml" classpathref="asciidoctor.path" />
<asciidoctor:convert sourceDirectory="${build.dir}/asciidoc" outputDirectory="${doc.build.dir}" backend="xhtml5" templateDir="asciidoc-template" preserveDirectories="true">
<attribute key="basedir" value="${build.dir}/asciidoc" />
+ <attribute key="imagesdir" value="" />
</asciidoctor:convert>
<copy todir="${doc.build.dir}">
<fileset dir="${doc.src.dir}" includes="images/**,style/**,samples/**,js/**,ivy.xsd" />
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/610c3be2/doc/xooki2asciidoc/xooki2asciidoc.js
----------------------------------------------------------------------
diff --git a/doc/xooki2asciidoc/xooki2asciidoc.js b/doc/xooki2asciidoc/xooki2asciidoc.js
index ab5840f..d9ed69a 100644
--- a/doc/xooki2asciidoc/xooki2asciidoc.js
+++ b/doc/xooki2asciidoc/xooki2asciidoc.js
@@ -927,6 +927,18 @@ xooki.input = {
s = xooki.string.find(input, new RegExp('<img\\s*src\\s*=\\s*\\"([^\\"]*)\\"\\s*/>'), from);
}
+ print('search img title\n')
+ s = xooki.string.find(input, new RegExp('<img\\s*src\\s*=\\s*\\"([^\\"]*)\\"\\s*title\\s*=\\s*\\"([^\\"]*)\\"[^/]*/>'));
+ from = 0;
+ while (s != null) {
+ processedSection = " image:" + s.matcher[1] + "[" + s.matcher[2] + "]"
+ input = input.substring(0, s.begin)
+ + processedSection
+ + input.substring(s.end);
+ from = s.begin + processedSection.length;
+ s = xooki.string.find(input, new RegExp('<img\\s*src\\s*=\\s*\\"([^\\"]*)\\"\\s*title\\s*=\\s*\\"([^\\"]*)\\"[^/]*/>'), from);
+ }
+
print('search br\n')
s = xooki.string.find(input, new RegExp('<br\\s*/?>'));
from = 0;
@@ -1065,6 +1077,32 @@ xooki.input = {
s = xooki.string.findXmlSection(input, "center", from);
}
+ print('search p\n')
+ s = xooki.string.findXmlSection(input, "p");
+ from = 0;
+ while (s != null) {
+ processedSection = "\n\n" + input.substring(s.innerStart, s.innerEnd) + "\n\n";
+ input = input.substring(0, s.outerStart)
+ + processedSection
+ + input.substring(s.outerEnd);
+ from = s.outerStart + processedSection.length;
+
+ s = xooki.string.findXmlSection(input, "p", from);
+ }
+
+ print('search blockquote\n')
+ s = xooki.string.findXmlSection(input, "blockquote");
+ from = 0;
+ while (s != null) {
+ processedSection = "\n[quote]\n____\n" + input.substring(s.innerStart, s.innerEnd) + "\n____\n\n";
+ input = input.substring(0, s.outerStart)
+ + processedSection
+ + input.substring(s.outerEnd);
+ from = s.outerStart + processedSection.length;
+
+ s = xooki.string.findXmlSection(input, "blockquote", from);
+ }
+
print('search tt\n')
s = xooki.string.findXmlSection(input, "tt");
from = 0;
@@ -1685,15 +1723,34 @@ if (batchMode) {
xooki.init();
- xooki.pageContent = xooki.pageContent.replace(/<script type="text\/javascript" src="[^"]*xooki.js"><\/script>/g, '');
-
+ m = new RegExp('<script type="text/javascript" src="[^"]*xooki\\.js"></script>').exec(xooki.pageContent);
+ if (m != null) {
+ xooki.pageContent = xooki.pageContent.substring(0, m.index) + xooki.pageContent.substring(m.index + m[0].length);
+ }
+
xooki.render.main();
var dest = generateTo.endsWith(".html") ? generateTo : generateTo+'/'+file;
dest = dest.substring(0, dest.length-5) + ".adoc";
print('generating to '+dest);
- xooki.pageContent = xooki.pageContent.replace(/[\s\S]*<body>/i, '');
- xooki.pageContent = xooki.pageContent.replace(/<\/body>[\s\S]*/i, '');
+
+ m = new RegExp('<body>').exec(xooki.pageContent);
+ if (m != null) {
+ xooki.pageContent = xooki.pageContent.substring(m.index + m[0].length);
+ }
+
+ lastM = null;
+ from = 0
+ m = new RegExp('</body>').exec(xooki.pageContent);
+ while (m != null) {
+ lastM = m;
+ from = from + m.index + m[0].length;
+ m = new RegExp('</body>').exec(xooki.pageContent.substring(from));
+ }
+ if (lastM) {
+ xooki.pageContent = xooki.pageContent.substring(0, from - lastM[0].length);
+ }
+
xooki.io.saveFile(dest, xooki.pageContent);
}
} else {