Git Product home page Git Product logo

gedit-rest-plugin's Introduction

reStructuredText Plugin

A plugin for GNOME's text editor gedit to render reStructuredText.

reST plugin in side panel

Layout Options

reST plugin preferences reST plugin in bottom panel

Dependencies

Installation

  • Choose the right source for your version of gedit from the releases on GitHub. With git you can checkout the corresponding tag (e.g. git checkout gedit-3.8).
    gedit-3.8:3.8 <= gedit < to 3.10
    gedit-3.10:gedit >= 3.10 (3.18 has been reported to work fine)
    gedit-3.22:gedit >= 3.22 (3.22.1 verified on Ubuntu 17.10)
    gedit-3.28:gedit >= 3.28 (3.28.1 verified on Ubuntu 18.04)
    gedit-3.36:gedit >= 3.36 (3.36.2 verified on Ubuntu 20.04)
  • Put reST.plugin file in gedit's plugins directory. The standard one should be ~/.local/share/gedit/plugins/. Alternatively, the global directory is something like /usr/lib/gedit/plugins/ or /usr/lib/<architecture>-linux-gnu/gedit/plugins/.
  • Copy the whole reST folder into the same directory.

You should then obtain something like this:

.../plugins/
        reST.plugin
        reST/
            schemas/
              gschemas.compiled
              org.gnome.gedit.plug...
            __init__.py
            config.py
            restructuredtext.py
            ...
  • Syntax highlighting works out-of-the-box with any new version of gedit. (Check the language mode drop-down in the footer bar of the editor window.) For older versions follow the instructions in syntax/README.rst to activate syntax highlighting.

Usage

Activate the plugin via Edit > Preferences > Plugins and check the checkbox next to reStructuredText Preview. Optionally, you can also choose whether you want the preview displayed in the bottom or the side panel.

The plugin is now activated, and you should have a new tab inside the bottom panel named reStructuredText. If you don't see the panel on the bottom of the editor window make it visible via View > Bottom Panel. If you use the side panel operate the drop-down selector on top of it to switch between Documents view and reStructuredText.

If the schedtool command is available, the plugin will use that to lower the priority of the rendering thread.

More Features

Prior versions versions of this plugin had more features (manual reloading with Ctrl+Shift+R, export to HTML, LaTeX and LibreOffice formats). See the July 4, 2014 version of this README.

If you want these features in again please get your hands dirty and make a pull request. The refactored code base of the current version should make this more easy than ever. Your contribution is appreciated!

Contributing

Please run flake8 and, optionally, pylint to ensure your contribution adheres to our coding style.

Please compile the GSettings schema if you make schema changes: (DTD)

glib-compile-schemas reST/schemas/

Resources:

Alternatives

If you're not totally happy with this plugin try the following editors for quick and free solutions of editing reStructuredText files:

  • rsted (online reStructuredText editor)
  • ReText (reStructuredText and MarkDown editor)

gedit-rest-plugin's People

Contributors

bittner avatar fpoirotte avatar jankanis avatar mcepl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gedit-rest-plugin's Issues

Table generation : problem with "get_text()"

Hello,
I start gedit with the command :
| user@computer ~ $ gedit

When I want to generate a table, I have those lines in the terminal :
| Traceback (most recent call last):
| File "/usr/local/lib/gedit/plugins/reST/init.py", line 256, in on_create_table
| text = doc.get_text(start, end)
| TypeError: get_text() takes exactly 4 arguments (3 given)

Thank you for your work.

Plugin should only render reStructuredText documents (not any type)

When I enable the plugin, it tries to work on ALL my files. Which is kind of unfortunate, because it tries to run reST processing even on my Python code etc., which obviously doesn't work well. I have suddenly tons of warning messages like:

<string>:75: (ERROR/3) Unexpected indentation.
<string>:79: (WARNING/2) Definition list ends without a blank line; unexpected unindent.
<string>:34: (ERROR/3) Unexpected indentation.
<string>:36: (WARNING/2) Definition list ends without a blank line; unexpected unindent.
<string>:37: (WARNING/2) Block quote ends without a blank line; unexpected unindent.

I know that gedit plugins are not the same as for example Emacs’ modes, so they natively are not limited just to some particular MIME type, but I guess with the heavy processes run by the plugin (e.g., whole WebKit and OpenJDK running) we should try to emulate this somehow with the infrastrcture we have.

If we moved most of the effective work to the Gedit.ViewActivatable child and cover whole processing with something like if filetype == 'reST': and ignore every other document. Of course, we would have to add also some event handler for case the user switches the file type of the edited document to reST (I guess we are talking about the file type used for the highlighting in gedit, MIME type is always just text/plain, right?).

Purpose of selection preview?

One bug that's still remaining is that the preview doesn't update when the text selection changes. It shouldn't be extremely difficult to fix, just finding the right signals to listen to, but I don't really see the point of this feature. When I select something it is usually to copy it. And 90% of the time a selection of a reST document won't be valid reST itself or is just a few words of plain text. Do you know the purpose/use case of this feature? If not, what about taking it out?

Inform user when plugin initialization fails (catch `ModuleNotFoundError`)

When the plugin is activated and required libraries are not installed the initialization of the plugin fails.

Currently, this is being reported on the Preferences dialog > Plugins tab with an error icon, but no other details are supplied. The user remains hence uninformed about what they can do to remediate the situation.

Expected Behavior

  1. The user should be informed (on the user interface) about the error reason,
  2. and should get hints about what they can do to get the plugin working.

Related Resources

Clean up legacy code

There are a few files just lying around, which are effectively unused by the current implementation:

  1. default.odt
  2. default.sty
  3. makeTable.py
  4. to_html.py
  5. to_odt.py
  6. to_tex.py

Their original function is described in an older version of the README (and the french README in the doc folder).

@JanKanis Should we simply remove them to clean up the repository, or rather try to restore the features?

What do you think?

Please add to standard gedit package

This is not really an issue, but: why the plugin is not part of standard gedit plugins? It would be far easier to use it in normal environments.
Thanks.

Fails to load on gedit 46.1; Manjaro 23.1.0

When running gedit, I encounter the following error when configuring the settings to display the review on the side panel. However, it's worth noting that everything functions correctly when the default setting is to display the output in the bottom pane. It appears that in the latest update of GNOME, some functions have been either removed or renamed.

The error I got is:

WARNING:reST:Falling back to old implementation. Reason: 'PanelContainer' object has no attribute 'add_titled'
Traceback (most recent call last):
File "/home/javad/.local/share/gedit/plugins/reST/__init__.py", line 86, in add_container_to_panel
self.display_panel.add_titled(self.html_container, panel_name,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'PanelContainer' object has no attribute 'add_titled'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/javad/.local/share/gedit/plugins/reST/__init__.py", line 63, in do_activate
self.add_container_to_panel()
File "/home/javad/.local/share/gedit/plugins/reST/__init__.py", line 90, in add_container_to_panel
self.display_panel.add_item(self.html_container, panel_name,
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'PanelContainer' object has no attribute 'add_item'
Traceback (most recent call last):
File "/home/javad/.local/share/gedit/plugins/reST/__init__.py", line 110, in do_update_state
self.html_container.update_view()
File "/home/javad/.local/share/gedit/plugins/reST/restructuredtext.py", line 125, in update_view
if self.preview_visible():
^^^^^^^^^^^^^^^^^^^^^^
File "/home/javad/.local/share/gedit/plugins/reST/restructuredtext.py", line 118, in preview_visible
self.panel.get_visible_child() == self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'PanelContainer' object has no attribute 'get_visible_child'
Traceback (most recent call last):
File "/home/javad/.local/share/gedit/plugins/reST/__init__.py", line 110, in do_update_state
self.html_container.update_view()
File "/home/javad/.local/share/gedit/plugins/reST/restructuredtext.py", line 125, in update_view
if self.preview_visible():
^^^^^^^^^^^^^^^^^^^^^^
File "/home/javad/.local/share/gedit/plugins/reST/restructuredtext.py", line 118, in preview_visible
self.panel.get_visible_child() == self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'PanelContainer' object has no attribute 'get_visible_child'
Traceback (most recent call last):
File "/home/javad/.local/share/gedit/plugins/reST/__init__.py", line 110, in do_update_state
self.html_container.update_view()
File "/home/javad/.local/share/gedit/plugins/reST/restructuredtext.py", line 125, in update_view
if self.preview_visible():
^^^^^^^^^^^^^^^^^^^^^^
File "/home/javad/.local/share/gedit/plugins/reST/restructuredtext.py", line 118, in preview_visible
self.panel.get_visible_child() == self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'PanelContainer' object has no attribute 'get_visible_child'

Cannot get plugin to work in gedit - Version 3.14.3 (Fedora21 Testing)

I tried to setup reST plugin on Fedora21.
python version available: Python 3.4.1

Steps followed :

clone source and switch to gedit-3.14 branch

https://github.com/bittner/gedit-reST-plugin.git

Install dependencies :

pygments:
pip install pygments

docutils: (http://docutils.sourceforge.net/README.html#installation)
git clone git://repo.or.cz/docutils.git
cd docutils/docutils ; python3 setup.py install

odtwriter : could not find the source for this.

copy reST.plugin and reST/ into the path for edit plugins in fedora21:

/usr/lib64/gedit/plugins

start gedit from terminal and load the plugin. I get the following error on terminal :

[saikrishna@localhost plugins]$ gedit
Traceback (most recent call last):
File "/usr/lib64/gedit/plugins/reST/init.py", line 22, in
from .restructuredtext import RestructuredtextHtmlPanel
File "/usr/lib64/gedit/plugins/reST/restructuredtext.py", line 20, in
from docutils.core import publish_parts
File "/usr/lib/python3.4/site-packages/docutils/init.py", line 68, in
class ApplicationError(StandardError):
NameError: name 'StandardError' is not defined

(gedit:12392): libpeas-WARNING **: Error loading plugin 'reST'

Please suggest.

Show bottom panel (reST preview) when Preview command is triggered

Problem Description

At the moment, when the reStructuredText Preview (Ctrl+Shift+R) is triggered and gedit's bottom panel is closed the reST document is generated, but the document is not displayed to the user. This is very irritating.

Proposed Solution

When the reStructuredText Preview (Ctrl+Shift+R) is triggered gedit should show the bottom panel (Ctrl+F9) if it is not visible yet.

plugin don't active when i ticks it

hi

your plugin might have be usefull fo me if it works .
i can't active the plugin. when i tick it i get a red cercle. wherever i put the pyfile and its folder (user or global) the probleme is the same.

what's wrong?

distro: debian testing/gnome shell
gedit -v > 3.20

"Blacklist" directives which are not in docutils?

Hi, thanks for the plugin!

I'm trying it out to check if I can make it easier for people to write some documentation (written for Sphinx in rst)..
Looks promissing!

Opening one of the rst files I get an error about the 'toctree' Sphinx directive... :

Screenshot-20191101130328-801x665

If I'm right the issue here is that this is a sphinx directive and not a docutils directive?
Which is reasonable.
So I'm coining the idea here to have some list of directives to be ignored during parsing. So the plugin should "preflight" the text and remove the directives that are on that 'blacklist'.
Not sure if this is easy to do, or there are other ways to do this? Is there something like that in docutils maybe?

In the Preview-window one could either ignore it and show nothing, OR add some small message "ignored directive" or so?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.