• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

wiki style document editor


コミットメタ情報

リビジョン6e270617e182abbcca805698d54c6e135989c5f0 (tree)
日時2014-09-01 01:41:09
作者Hiromichi Matsushima <hylom@Hiro...>
コミッターHiromichi Matsushima

ログメッセージ

export: fix for table markup

変更サマリ

差分

--- a/tools/export/export-single.js
+++ b/tools/export/export-single.js
@@ -45,6 +45,7 @@ function copyFiles(filelist, from, dest) {
4545
4646 function exportSingle(target, output) {
4747 fs.readFile(target, 'utf8', function (err, data) {
48+ console.log(target);
4849 if (err) {
4950 console.log('Cannot read file: ' + target);
5051 return;
@@ -60,21 +61,25 @@ function exportSingle(target, output) {
6061 // output honmon, caption
6162 fs.writeFileSync(path.join(output, 'honmon.txt'),
6263 result.bodies.join('\n'));
63- fs.writeFileSync(path.join(output, 'caption.txt'),
64- result.captions.join('\n'));
64+
65+ if (result.captions.length != 0) {
66+ fs.writeFileSync(path.join(output, 'caption.txt'),
67+ result.captions.join('\n'));
68+ // output html
69+ var out = fs.createWriteStream(path.join(output, 'figures.html'), {flags: 'w', encoding: 'utf8', mode: 0666});
70+ out.write(HTML_HEAD);
71+ out.write('\n');
72+ out.write(result.htmls.join('\n'));
73+ out.write('\n');
74+ out.write(HTML_FOOT);
75+ out.end();
76+ }
6577
6678 // file copy
6779 var copyFrom = path.join(path.dirname(target), 'figure');
68- copyFiles(result.figures, copyFrom, path.join(output, 'figures'));
69-
70- // output html
71- var out = fs.createWriteStream(path.join(output, 'figures.html'), {flags: 'w', encoding: 'utf8', mode: 0666});
72- out.write(HTML_HEAD);
73- out.write('\n');
74- out.write(result.htmls.join('\n'));
75- out.write('\n');
76- out.write(HTML_FOOT);
77- out.end();
80+ if (result.figures.length != 0) {
81+ copyFiles(result.figures, copyFrom, path.join(output, 'figures'));
82+ }
7883
7984 });
8085 }
@@ -89,6 +94,9 @@ function findFigureFile(caption, imageDir) {
8994 }
9095
9196 function findImageFile(name, targetDir) {
97+ if (fs.existsSync(path.join(targetDir, name))) {
98+ return name;
99+ }
92100 var files = fs.readdirSync(targetDir);
93101 var exts = config.figureFormat;
94102 for (var i = 0; i < files.length; i++) {
@@ -136,6 +144,9 @@ function splitBody(lines) {
136144 && bodies[bodies.length-1] === '' ) {
137145 // do nothing
138146 } else {
147+ // *図、*表を置換
148+ lines[i] = lines[i].replace(/\*図/g, '★図');
149+ lines[i] = lines[i].replace(/\*表/g, '★表');
139150 bodies.push(lines[i]);
140151 }
141152 }
@@ -241,7 +252,8 @@ function makeHtmls(lines, imageDir) {
241252 var html = [];
242253 var figMode = false;
243254 var figTextMode = false;
244- var figName;
255+ var assumedFigName;
256+ var figName
245257 var figId;
246258 for (var i = 0; i < lines.length; i++) {
247259
@@ -253,14 +265,15 @@ function makeHtmls(lines, imageDir) {
253265 // figure
254266 if (lines[i].match(/^☆図/)) {
255267 figId = lines[i].match(/^☆図([0-9]+-[0-9]+)/);
256- figName = 'fig' + figId[1] + '.fw.png';
268+ console.log(lines[i]);
269+ assumedFigName = 'fig' + figId[1] + '.fw.png';
257270 figMode = true;
258- if (isExistsFigure(figName, imageDir)) {
271+ if (isExistsFigure(assumedFigName, imageDir)) {
259272 html.push('<span class="caption">' + lines[i] + '</span>');
260- html.push('<img src="figures/' + figName + '">');
261- html.push('<span class="filename">' + figName + '</span>');
273+ html.push('<img src="figures/' + assumedFigName + '">');
274+ html.push('<span class="filename">' + assumedFigName + '</span>');
262275 i++;
263- while(!lines[i].match(/^>>>>/)) {
276+ while((i < lines.length) && (!lines[i].match(/^>>>>/))) {
264277 if (lines[i].match(/^\s*$/)) {
265278 i++;
266279 continue;
@@ -270,7 +283,7 @@ function makeHtmls(lines, imageDir) {
270283 }
271284 if (figMode) {
272285 figName = findImageFile(lines[i], imageDir);
273- if (figName != '') {
286+ if ((figName != '') && (figName != assumedFigName)) {
274287 html.push('<span class="filename">' + figName + '</span>');
275288 }
276289 }
@@ -309,7 +322,10 @@ function makeHtmls(lines, imageDir) {
309322 html.push('<span class="caption">' + lines[i] + '</span>');
310323 html.push('<table>');
311324 i++;
312- while(!lines[i].match(/^\s+$/)) {
325+ while((i < lines.length) && (!lines[i].match(/^\s*$/))) {
326+ if (lines[i].match(/^>>>>/)) {
327+ break;
328+ }
313329 html.push(lines[i].replace(/^/, '<tr><td>')
314330 .replace(/$/, '</td></tr>')
315331 .replace(/\t/, '</td><td>'));
--- a/tools/export/export.js
+++ b/tools/export/export.js
@@ -22,12 +22,12 @@ function exportPages(taget, output) {
2222 }
2323 var contents = toc.directories[target].contents;
2424 var page = toc.directories[target].pageStart;
25- console.log(toc.directories[target]);
25+ //console.log(toc.directories[target]);
2626 contents.forEach(function (content) {
2727 var outputDirPath = calcOutputDirPath(content, page);
2828 page += content.pages;
2929 var targetPathname = path.join(config.rootDir, target, content.title + '.txt');
30- console.log(targetPathname, outputDirPath);
30+ //console.log(targetPathname, outputDirPath);
3131 exportSinge(targetPathname, outputDirPath);
3232 });
3333 }