Skip to content

Commit

Permalink
fix 易首句
Browse files Browse the repository at this point in the history
  • Loading branch information
LingDong- committed Jul 23, 2020
1 parent dac9263 commit 325b804
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions assets/code-fragment-meta.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ X
0
0
X
吾有二數。曰五百七十九。曰二千二百八十三。名之曰「頭」曰「足」。 -2
吾有二數。曰五百七十九。曰二千二百八十四。名之曰「頭」曰「足」。 -2[1:]
0
X
# chapter 4
Expand All @@ -49,7 +49,7 @@ X
0
吾有一列。名之曰「列」。充「列」以一以二以三。 0
0
有數九百九十九。名之曰「始」。 -1
有數九百九十九。名之曰「始」。 -1[1:]
0
0
# chapter 6
Expand Down
17 changes: 15 additions & 2 deletions scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ for (var i = 0; i < bl.length; i++){

var CODEMETA = fs.readFileSync("../assets/code-fragment-meta.txt").toString().split("\n")
.filter(x=>!x.startsWith("#")&&x.length).map(x=>x.trim())
.map(x=>x.split(" ").map(y=>isNaN(parseInt(y))?y:parseInt(y)));
.map(x=>x.split(" ").map(y=>y.includes("[")?y:(isNaN(parseInt(y))?y:parseInt(y))));

function matrix(bl,sem,H){

Expand Down Expand Up @@ -207,7 +207,20 @@ function typeset(T,F,l,r,w,h){
var c = '';
for (var j = 0; j < m.length; j++){
if (typeof m[j] == 'string'){
c += m[j];
if (m[j].includes('[')){
var i0 = parseInt(m[j].split('[')[0]);
var i1 = parseInt(m[j].split('[')[1].split(':')[0]);
var i2 = parseInt(m[j].split(':')[1].split(']')[0]);
if (isNaN(i2)){
i2 = undefined;
}
if (isNaN(i0)){
i1 = 0;
}
c += BLOCKS[_i+i0*2].slice(1).split('\\n').slice(i1,i2).join('\\n');
}else{
c += m[j];
}
}else{
c += BLOCKS[_i+m[j]*2].slice(1);
}
Expand Down

0 comments on commit 325b804

Please sign in to comment.