#10637: Implement sage -sws2rst
------------------------------------------------------------+---------------
Reporter: nthiery | Owner:
jason, mpatel, was
Type: enhancement | Status:
needs_work
Priority: major | Milestone:
sage-5.2
Component: notebook | Resolution:
Keywords: ReST, worksheet | Work issues:
answer questions, math formatting, lists, maybe absolute paths?
Report Upstream: Workaround found; Bug reported upstream. | Reviewers:
Nicolas ThiƩry, Jason Grout, Karl-Dieter Crisman, Jason Bandlow, John Palmieri
Authors: Pablo Angulo, Karl-Dieter Crisman | Merged in:
Dependencies: #11080, #11459 | Stopgaps:
------------------------------------------------------------+---------------
Comment (by kcrisman):
Some suggestions for code. Ignore if stupid.
----
> * This is just amusing.
> {{{
> arrow $\mapsto$ as "|-->").
> }}}
> becomes the same thing, so it doesn't turn back into {{{|-->}}}, the
arrow! Not sure what to do about that; why didn't the greater than sign
just become a greater than sign when translated from html back? Also, I
thought that {{{|}}} was one of the characters you escaped, but maybe this
one escaped being escaped?
Okay, I think that what happens is that in `replace_latex` you only
replace these characters ''if'' there was no LaTeX to replace in the first
place. But of course that might not always be the case. This isn't a
huge issue, but worth pointing out and probably easy to fix.
----
In `visit_li`, I think that replacing
{{{
return (' '*self._nested_list
+ ('#. ' if self._inside_ol else '- ')
+' '.join(self.visit(tag) for tag in node.contents))
}}}
with `' '*(self._nested_list-1)` should work. That was also a very minor
point.
----
Would reversing the setting in `visit_ol` for `visit_ul` work for allowing
nested mixed lists?
{{{
self._inside_ol = False
blah
self._inside_ol = True
}}}
----
Would replacing, in `visit_display`,
{{{
return ('\n.. MATH::\n\n ' +
}}}
with
{{{
return ('\n\n.. MATH::\n\n ' +
}}}
help with the math display issue?
----
In `visit_li`, maybe a number of potential issues (in addition to the math
not being indented enough) could be solved by
{{{
def visit_li(self, node):
return (' '*self._nested_list
+ ('#. ' if self._inside_ol else '- ')
+' '.join(self.visit(tag) for tag in node.contents))
}}}
with
{{{
def visit_li(self, node):
spacing = ' '*(self._nested_list - 1)
return (spacing
+ ('#. ' if self._inside_ol else '- ')
+' '.join(self.visit(tag) for tag in
node.contents).replace('\n','\n'+spacing) )
}}}
What do you think? This just preserves the indentation until the soup
gives us the end of the list item, if I did it right.
----
To solve the issue with the unexpected indent, it looks like it would
suffice to change the `visit_ul` and `visit_ol` to have
{{{
result = '\n' + '\n'.join(self.visit(tag) for tag in node.contents)
}}}
I think that changing `visit_li` will be less optimal, since there are
already newlines between all of those things. This is where it should be
handled.
----
Sorry for not having nice diffs like John - I haven't tried these out,
just thinking out loud about code.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10637#comment:67>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
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-trac?hl=en.