A Renewed ReStructuredText Editor!

Aug 27 2010 Published by under Enthought Tool Suite

Remember the ReStructuredText editor? Well I just spent my Google Summer of Code adding a bunch of new features to it:

  • A new toolbar with nice icons from the Tango icon library to give quick access to old and new features alike.
  • Buttons to apply inline markup for *emphasis*, **strong emphasis** and “inline literal“ to the selected text.
  • Functions to fix the length of the underline and overline of section headings. You can either use these functions with the buttons on the toolbar or use the Ctrl+D (for underline) and Ctrl+Shift+D (for underline and overline) keyboard shortcuts, which makes fixing titles extra quick when youre working on them.
  • View synchronization between the text editor and the HTML previewer. This can be done either by using the synchronize buttons on the toolbar or by activating the Sync view on change feature in the preference menu.
  • Quick conversion to HTML (using Docutils or Sphinx), LaTeX (using Docutils) and PDF (using rst2pdf) through the new Convert menu.
  • And no more being stuck with that ugly default font: the font of the text editor can now be changed through the preference menu.

There is also an experimental auto-fix table function that can be activated in the preference menu. This allows you to write text in an existing table without having to take care of rebuilding all the borders manually. The program will keep the structure of the table intact when writing text in a cell and will increase its length when there is no more room in the cell. Try it out on one of your existing table, but be careful, as said above, it is still very experimental and may cause the editor to crash (so save your files before using it!).

On a more technical side, we dropped support for the wxWidgets backend, so you will need Qt4 to run the editor. Here are two screenshots of the editor running on Ubuntu and Windows 7:

So, whats next?

Well for starters, the table auto-fix function has to be rewritten. As for further new features, Id like to work on allowing the user to select custom CSS files (or themes for Sphinx) for the HTML previewer. Also I think it might slowly be time for the editor to get actual installers, as currently it is still a pain to get it running if you arent familiar with ETS.

How about you, what features would you like to see in the editor?

EDIT:

Since quite a few people asked how to install the editor and that I won’t be able to build proper installer before sometime in September, I figure I’d at least write a small tutorial on how to install it from source.

First, you need to get SVN, Python 2.x (minimum 2.4), SetupTools, PyQt4 and NumPy and install them. (I’m not 100% sure, but MinGW might be needed too on Windows.)

Once that’s done, the following script should download the needed source from Enthought’s SVN and install the rest of the needed libraries by using SetupTools (easy_install…):

svn co https://svn.enthought.com/svn/enthought/EnthoughtBase/trunk EnthoughtBase
svn co https://svn.enthought.com/svn/enthought/Traits/trunk Traits
svn co https://svn.enthought.com/svn/enthought/TraitsGUI/trunk TraitsGUI
svn co https://svn.enthought.com/svn/enthought/TraitsBackendQt/trunk TraitsBackendQt
svn co https://svn.enthought.com/svn/enthought/AppTools/trunk/enthought/rst RestEditor

cd EnthoughtBase
python setup.py install bdist_egg
cd ../Traits
python setup.py install bdist_egg
cd ../TraitsGUI
python setup.py install bdist_egg
cd ../TraitsBackendQt
python setup.py install bdist_egg
cd ..

easy_install -f dist/ -H dist/ EnthoughtBase Traits TraitsGUI TraitsBackendQt
easy_install configobj pygments docutils sphinx rst2pdf

After that, you should be able to run the editor by going in the RestEditor folder and running app.py with Python:

cd RestEditor
python app.py

45 responses so far

  • avatar Name says:

    The image previews are a bit stretched out. If you remove the height=”..” attribute from the img tags, they should look better.

  • This is awesome. It’s like a WYSIWYG and WYSIWYM combined! Congrats on such a polished end result.

  • Looks cool.

    Minor point: it’s “ReStructuredText”, one word not two.

  • avatar Sebastien Douche says:

    hi,
    how to download the editor?

  • avatar Juha Mustonen says:

    Looking good.

    A common challenge with the plaintext formats are the definitely the tables, and how to modify their contents easily (I haven’t tried to the table auto-fix functionality, though). However, I also suggest to implement some kind of auto-complete/dropdown cross-reference functionality, where application lists all the possible targets (with target name, label and file information) when new link is being added to the text.

  • Wow… it seems a very nice tool! congrats…
    But where can I download it?!

  • avatar Nadav says:

    Nice! I like the fact that it can export Latex documents.

  • avatar Stephen Ferg says:

    >> time for the editor to get actual installers

    +1

  • avatar Stephen Ferg says:

    >>time for the editor to get actual installers

    +1

  • avatar Christof says:

    Great work! Installer would be nice (and for me high priority some people at work use RST but have no programming knowlege at all ;).
    Custom CSS would also be great and really useful.

    BTW, difficult to find a download link anyway, could you add one to your posts?

    Anyway, keep up the good work!

  • avatar Roger Gammans says:

    Why did you drop support for the wxWidget backend ?

    I’d like to use this or something like to provide the text editing capabilities for a program I am working on – so and embeddeng api would be a great think to use, so I can use the editor as a widget . I was hoping to use wxWidgets for my main control set – but it sound like I might need to re -evaulate that..

  • avatar Kevin Salvesen says:

    I updated the post with a small guide to install the editor from source. I realize that’s not optimal, but I won’t have the time to make proper installers before sometime in September. The script I wrote should be pretty straightforward.

    @Juha Mustonen: And parsing those tables (especially since ReStructuredText allows for all kind of complicated tables with cells spanning multiple columns or rows) is quite the challenge too. :) Some kind of auto-complete feature does sound interesting, I’ll note it down for the future.

    @Roger Gammans: from my original GSoC proposal: “Drop support for wx. As mentioned by Bryce Hendrix: “The wx HTML editor is awful and very limited, the text editor (Scintilla) API is also very limiting.” Focusing on a single framework for the interface should also result in a simpler code base.”

    That being said, now that the project is done, I can say that the main reason was that Enthought was working on a new code editor (built with Qt) to replace QScintilla as their default code editor. We decided to use it in the rest editor, and many of the new features work through that editor (and by using Qt). As for me personally, I don’t think I would have the time to add all these features in Wx and Qt over the course of my GSoC.

    I hope that somewhat explains it.

  • avatar Timmie says:

    Hello,
    where shall we report errors or ask questions on usage?

    In this blog here?
    Or at the Enthought-dev list?

    Thanks for the work!

  • avatar Timmie says:

    Features I would like to enjoy:
    * an outline for RST structure based on the headlines and section in the file

    and killer feature for Sphinx-based documentation:
    * ability to preview RST code in docstrings:
    - load a python module
    - all dostrings get searched for
    - RST syntax highlighting is provided for all RST based doctstrings
    - preview is provided for all docstrings

    Thanks for your efforts,
    Timmie

  • avatar Bryce Hendrix says:

    @Timmie – posting questions/bugs/suggestions can be done either here or on enthought-dev, assuming the bugs & suggestions eventually make it into Trac. You can enter tickets yourself at http://svn.enthought.com/enthought

  • avatar Emmanuel Lambert says:

    Sounds great and I just tried it. However, I notice 2 major issues :

    -the HTML is not automatically synchronized when I changed the rest-code, although I have the “sync view on change” option checked. Is this a bug? This is supposed to be one of the key features of the tool…?

    -is it possible to synchronize scrolling between the 2 views?

    regards.
    Emmanuel

    • avatar Bryce Hendrix says:

      @Emmanuel- It should update the HTML when you type in the code editor, though it may take a second or two in some cases. Does it ever display correct HTML? If not, I suspect an issue with Sphinx or docutils

      Synchronizing scrolling should be possible, we’ll definitely keep that in mind for short term enhancements.

  • avatar who says:

    who will package it? when?

  • avatar nickos says:

    That’s nice .it looks more beter in UNIX bat ok

  • avatar Jose Carlos says:

    I’ve seen that it’s been moved to a separate package two weeks ago to reduce dependencies. You can see it at https://svn.enthought.com/enthought/browser/Rested/trunk

    You can do a checkout at https://svn.enthought.com/svn/enthought/Rested/trunk

    • avatar bryce hendrix says:

      Thanks for mentioning that Jose. The plan now is to update its dependencies in the setup.py, do a couple of bug fixes, and do a real release of it.

  • avatar Andre Berg says:

    Hey,

    nice idea with the editor.

    I wanted to see if I can get it to work on OS X.

    And as a matter of fact I succeeded (after a long session of chasing after dependencies and their related problems and bugs) – I got to the point where the editor starts up and I’d say 60% of the core functionality is there.

    Here’s a short list of things that do not work:

    - Menu short cuts keys do not work. They are not represented in the menu bar drop downs and do nothing when pressing with Cmd or Ctrl.

    - Opening rst or txt files opens the file but doesn’t update the HTML preview. It get’s stuck at “Generating HTML…”

    - The odd thing is once you press Ctrl (just the modifier key) A new document “Untitled” is created which has its preview working (if you have Sphinx activated you see the default template immediatly).

    - I couldn’t get the HTML preview to work for saved (rst, txt) files that I opened or reopened through Rested.

    - Sometimes when the validation occurs the executing Python process will crash with the following messages printed to console:

    “The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
    Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.”

    This error is actually very easily fixed and is usually caused by programmers inexperienced with core Mac OS X frameworks. It basically gives the solution in the macro name: after an exec() (execve(), etc…) you must fork() to be able to use CoreFoundation.framework.

    It is unclear where this error originates:
    the backtrace shows python, PyQT, and various enthought components.

    Other times its just:

    Python[79987:9c67] *** __NSAutoreleaseNoPool(): Object 0x1700a800 of class NSConcreteMapTable autoreleased with no pool in place – just leaking

    which is basically harmless as the memory is reclaimed anyway when Rested is closed.

    - Sphinx doesn’t seem to honor extensions added in conf.py of the current project that needs documenting.

    Anyway I really look forward to seeing this editor mature.
    In my eyes it’s the right way to tackle this problem domain.

    PS: if you’re interested in screenshots:

    Rested-01: http://www.bergmedia.de/remote/Rested/Rested-01.png
    Rested-02: http://www.bergmedia.de/remote/Rested/Rested-02.png

    Andr

  • avatar Andre Berg says:

    Just wanted to add:

    With a few nudges in the right direction I’d be willing to try and look at/debug the preview not working on OS X.

    The distributed package structure of the enthought backend made it a bit of a hassle to import the project into Eclipse Pydev so as to be able to step through it in PyDev’s debugger but I think I got it set up now.

    However the whole concepts of Traits has me confused a little so I’d need some general directions if possible.

    • avatar Bryce Hendrix says:

      Andre, Sorry for the late reply. You still interested in looking into the preview issue? I can give you a quick Traits tutorial (or point you towards one).

  • avatar Victor Hooi says:

    heya,

    Is there any update on an installer for Windows?

    You mentioned it might be done in September 2010…lol. Hope it comes out soon! It looks like an awesome project I’d love to use (and my work envs are all Windows).

    Cheers,
    Victor

    • avatar Kevin Salvesen says:

      I promised I’d do it in September but I sadly never did, I got caught up by my university work (which I had underestimated), and never got around working more on the editor. Especially now with my exams coming, I really don’t have time to do it. Maybe someone at Enthought will have time to work on this?

      In any case, I apologize for the lack of news about the project coming from me.

  • avatar Andreas Schoenle says:

    I could not get it to run on Windows7 with both Python 2.7 and 2.6. Downloading from the new location and running the setup everything seems to go ok. Running app.py I get:

    D:\Sources\Enthought\RestEditor\enthought\rst>python app.py
    Traceback (most recent call last):
    File “app.py”, line 23, in
    from rest_editor_view import ReSTHTMLEditorView
    File “D:\Sources\Enthought\RestEditor\enthought\rst\rest_editor_view.py”, line 26, in
    from enthought.qt.api import QtGui, Qt, QTextCursor
    ImportError: cannot import name QtGui

    • avatar Andreas Schoenle says:

      Hi!

      Sorry for the hasty post. I solved the problem by interchanging the ETCConfig and QTGui import lines in rest_editor_view.py:

      # ETS imports
      from enthought.etsconfig.api import ETSConfig
      ETSConfig.toolkit = ‘qt4′
      from enthought.qt.api import QtGui, Qt, QTextCurso

      • avatar Bryce Hendrix says:

        Andreas, thanks for finding that. I injected that error recently adding support for pyside. I’ll make the change once I’m back on a box with PySide once I can test with.

      • avatar Bryce Hendrix says:

        Andreas, I just checked in a change which appears to work with PyQt4 and PySide. Please let me know if you find any other problems with it.

  • avatar Michael says:

    Hi when i try to do this part.
    svn co https://svn.enthought.com/svn/enthought/AppTools/trunk/enthought/rst RestEditor
    svn: URL ‘https://svn.enthought.com/svn/enthought/AppTools/trunk/enthought/rst’ doesn’t exist

    Whats wrong?

    regards Michael

  • avatar Victor Hooi says:

    Hi,

    I’m getting a 404 when I try to access the subversion repository for Rest Editor:

    https://svn.enthought.com/svn/enthought/AppTools/trunk/enthought/rst

    Has the repository moved, or been renamed? Any news on this tool?

    Cheers,
    Victor

  • avatar flipthefrog says:

    easy_install just craps out on trying to install Traits, saying it can’t find vcvarsall.bat

    An installer would be great indeed

  • avatar pankaj says:

    Where is this rsted located now. Last i saw it was not in github where the rest of ETS has moved, so now the ets.py script doesn’t work. It’ll be cool if you could move it there and let it be, even if you don’t have time to maintain it.

  • avatar Geoffrey says:

    is there not a front to back set of install instructions for windows7 python 2.6?
    I’ve been working on installing this wonderful looking tool for the last three days …

    I’m getting tired … but I want this to work.

    please help

  • avatar Peter Hardman says:

    Just installed rsted. A doddle using the instructions here.

    Had to patch file_tree.py – WindowsError doesn’t exist on Linux (ArchLinux) for some reason – what is this Windows thing anyway?

    Some things don’t work – notably up and down arrows. Either a typo in the code (QtGui object has no attribute QtGui) or it’s written for an old version of Qt4 – I’m on 4.7.3.

    Or are these more things that only exist on Windows Qt?

    I’ll have a look at these later…

  • avatar Scottie says:

    I’ve Python v.2.7 version and get following error:

    D:\usr\scr\enthought\RestEditor>python app.py
    The rest editor only supports qt4 as toolkit. Toolkit changed to qt4.
    Traceback (most recent call last):
    File “app.py”, line 23, in
    from rest_editor_view import ReSTHTMLEditorView
    File “D:\usr\scr\enthought\RestEditor\rest_editor_view.py”, line 40, in
    from enthought.pyface.api import AboutDialog, DirectoryDialog, FileDialog, \
    File “C:\Python\Python27\lib\site-packages\enthought\pyface\api.py”, line 18, in
    from clipboard import clipboard, Clipboard
    File “C:\Python\Python27\lib\site-packages\enthought\pyface\clipboard.py”, line 23, in
    clipboard = Clipboard()
    File “C:\Python\Python27\lib\site-packages\enthought\pyface\toolkit.py”, line 92, in __init__
    raise NotImplementedError(“the %s pyface backend doesn’t implement %s” % (ETSConfig.toolkit, oname))
    NotImplementedError: the qt4 pyface backend doesn’t implement Clipboard

    Any suggestions?

  • avatar Scottie says:

    What’s wrong?

    >python app.py
    The rest editor only supports qt4 as toolkit. Toolkit changed to qt4.
    Traceback (most recent call last):
    File “app.py”, line 23, in
    from rest_editor_view import ReSTHTMLEditorView
    File “T:\TEMP\RestEditor\rest_editor_view.py”, line 40, in
    from enthought.pyface.api import AboutDialog, DirectoryDialog, FileDialog, \
    File “C:\Python\Python27\lib\site-packages\enthought\pyface\api.py”, line 18, in
    from clipboard import clipboard, Clipboard
    File “C:\Python\Python27\lib\site-packages\enthought\pyface\clipboard.py”, line 23, in
    clipboard = Clipboard()
    File “C:\Python\Python27\lib\site-packages\enthought\pyface\toolkit.py”, line 92, in __init__
    raise NotImplementedError(“the %s pyface backend doesn’t implement %s” % (ETSConfig.toolkit, oname))
    NotImplementedError: the qt4 pyface backend doesn’t implement Clipboard

  • Hi, interesting editor!

    I had actually a similar idea of implementing an rST based editor but browser based. I thought you might be interested the see what the “competition” does ;D You find it at https://notex.ch; in contrast to your editor my focus is more on PDFs rather than HTMLs (although HTML exports) are also supported.

    Do you plan to add support for tables? I mean like a table wizard which can make operating on the text easier? CU

  • avatar martinqt says:

    Hi,
    I just tried to install your software and i ended up with this error when running python app.py:

    The rest editor only supports qt4 as toolkit. Toolkit changed to qt4.
    Traceback (most recent call last):
    File “app.py”, line 23, in
    from rest_editor_view import ReSTHTMLEditorView
    File “C:\programmedir\RSTEditor\RestEditor\rest_editor_view.py”, line 41, in
    from enthought.pyface.api import AboutDialog, DirectoryDialog, FileDialog, \
    File “C:\programmedir\Python27\lib\site-packages\traitsgui-3.6.1.dev-py2.7.egg\enthought\pyface\api.py”, line 16, in
    from about_dialog import AboutDialog
    File “C:\programmedir\Python27\lib\site-packages\traitsgui-3.6.1.dev-py2.7.egg\enthought\pyface\about_dialog.py”, line 18, in
    from toolkit import toolkit_object
    File “C:\programmedir\Python27\lib\site-packages\traitsgui-3.6.1.dev-py2.7.egg\enthought\pyface\toolkit.py”, line 73, in
    _init_toolkit()
    File “C:\programmedir\Python27\lib\site-packages\traitsgui-3.6.1.dev-py2.7.egg\enthought\pyface\toolkit.py”, line 38, in _init_toolkit
    be = import_toolkit(ETSConfig.toolkit)
    File “C:\programmedir\Python27\lib\site-packages\traitsgui-3.6.1.dev-py2.7.egg\enthought\pyface\toolkit.py”, line 31, in import_toolkit
    __import__(be + ‘init’)
    File “C:\programmedir\Python27\lib\site-packages\traitsbackendqt-3.6.1.dev-py2.7.egg\enthought\pyface\ui\qt4\init.py”, line 18, in
    from enthought.qt import QtCore, QtGui, qt_api
    File “C:\programmedir\Python27\lib\site-packages\enthoughtbase-3.1.1.dev-py2.7.egg\enthought\qt\__init__.py”, line 22, in
    sip.setapi(‘QString’, 2)
    ValueError: API ‘QString’ has already been set to version 1

    Any idea?
    Thanks

Leave a Reply

Featuring Advanced Search Functions plugin by YD