Hi,
I'm watching for the ability to create html block, which references
sage varible in notebook. So, the questions:
1) is it possible to reference sage variable from TiniMCE html block?
or
2) is it possible to generate normal (not '<pre>') html block as
output of sage cell
Rationale:
It is much more convenient to read problem statement and results of
calculations as reach text (mean html), which has introductory words
and formatted with bolds, italic, headers, includes typesetted
fromulas etc.
But now as I cannot reference sage variable (e. g. with result) within
html block, I have to manually copy its value, obtained as result of
calculation cell (or defined within sage cell) to the html block
(which is not very convenient), or to be satisfied with poor output of
calculation cell (or look for varables definition within cell itself).
Example of intended usage:
sage_cell {
%hide
#auto
a = 10
b = 20
}
html_block {
<h1>Problem statement</h1>
<p>We are solving the problem about ... </p>
<p>Solution is given with $$ c = a + b, $$ </p>
<p>where</p>
<p>$a = <reference to sage a variable> $ - descriptionn of variable
a...
<p>$b = <reference to sage b variable> $ - description of variable
b...
}
sage_cell {
c = a + b
# actually inmplementation of some long calculation goes here. May be
with %hide option
}
html_block {
<p>The result of calculation is</p>
<p>$$ c = <reference to c sage variable>$$</p>
}
Of course, real life example would be longer.
I did not find any mentions of such kind of feature in sage
documentation, nor in this group.
I tried to implement second way of solution (see above) using html()
sage command. But the prolems arisen. For some reason result of html()
function is put into the '<pre>' tag in the output (although
documentation says, that it shoud not), so it gives inconvenient
results.
In more details, my idea was to make something like this:
sage_cell {
%hide
#auto
a = 10
b = 20
html(
'<h1>Problem statement</h1>'+
'<p>Introductory text here (with html markup).. It can be very very
very very very long.</p>'+
'<p>$$ a = {0} $$</p>'.format(a) +
'<p>$$ b = {0} $$</p>'.format(b) +
'<p>... more text here, if needed ...</p>'
)
}
As a result of cell evaluation I would like to get necely formatted
(html) output wich includes numbers actually used in calculations. The
result is almost acceptable, except one thing. As it is '<pre>', the
paragraph content is not wrapped into page width, which is
inacceptable. Besides, it is printed with monospaced font, which is
not fatal, but not desireable.
Note, there is still ability to obtain nicely typesetted output using
show() function like this:
sage_cell{
a_i = 12.3456789
show('Acceleratin of i-th particle:\n$a_i = {0:.2f}'.format(float(a_i))
+
' \\; \\mathrm{\\frac{m}{s^2}}$')
}
Although, there are still some clashes with braces used for format()
function and for math markup (in the example given string is splitted
to two for this reason). Either you should remember to escape back-
slashes and explicitly convert sage-typed variables to float (or int)
to use formatting.
If someone knows some some standard methods or tricks for doing
things, discussed above, share them.
Thanks,
Dmitry.
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org