Fixed mpost to render LaTeX
This commit is contained in:
parent
b9c9b7aed9
commit
84b9837592
1 changed files with 11 additions and 8 deletions
17
lib/mpost.rb
17
lib/mpost.rb
|
@ -4,9 +4,9 @@ class MPost < Nanoc3::Filter
|
|||
@@name=["Zero","One","Two","Three"]
|
||||
def solarized(str)
|
||||
str.gsub(
|
||||
%r{base([0123])},'base'+@@name[0]+@@name[$2]
|
||||
%r{base0([0123])},'base'+@@name[0]+@@name[$1.to_i]
|
||||
).gsub(
|
||||
%r{base([0123])},'base'+@@name[$2]
|
||||
%r{base([0123])},'base'+@@name[$1.to_i]
|
||||
).gsub(
|
||||
%{red},'s_red'
|
||||
).gsub(
|
||||
|
@ -21,8 +21,7 @@ class MPost < Nanoc3::Filter
|
|||
title=$2
|
||||
str=$3
|
||||
filename=title.gsub(/[^a-zA-Z0-9_]/,"_")
|
||||
File.open(@@tmpfic,'w') do |f|
|
||||
f.write %{
|
||||
code=%{
|
||||
color baseZeroThree, baseZeroTwo, baseZeroOne, baseZeroZero
|
||||
, baseZero, baseOne, baseTwo, baseThree, yellow, orange
|
||||
, s_red, magenta, violet, s_blue, cyan, s_green;
|
||||
|
@ -44,10 +43,14 @@ class MPost < Nanoc3::Filter
|
|||
cyan :=(0.164705882352941 ,0.631372549019608,0.596078431372549);
|
||||
s_green :=(0.52156862745098 ,0.6 ,0.0);
|
||||
|
||||
prologues:=3;
|
||||
drawoptions (withcolor base02);
|
||||
beginfig(1)
|
||||
}
|
||||
f.write str
|
||||
f.write %{\nendfig;\nend\n}
|
||||
}.sub(%r{^\s*},"")
|
||||
code <<= str
|
||||
code <<= %{\nendfig;\nbye;\n}
|
||||
File.open(@@tmpfic,'w') do |f|
|
||||
f.write solarized(code)
|
||||
end
|
||||
FileUtils.mkdir_p('output'+@item.path+'mpost')
|
||||
webpath=@item.path + 'mpost/' + filename + '.png'
|
||||
|
|
Loading…
Reference in a new issue