mgaitan / sublime-rst-completion Goto Github PK
View Code? Open in Web Editor NEWRestructured Text snippets and code completion hotkeys for Sublime Text 2 and 3
License: BSD 3-Clause "New" or "Revised" License
Restructured Text snippets and code completion hotkeys for Sublime Text 2 and 3
License: BSD 3-Clause "New" or "Revised" License
When I add some text to table with merged cells and press ctrl-t, enter it breaks everything.
Original table:
+---+------------------------------+-------------------------+------------------------+-------------------------+
| | | XXXXXXXXXX | XXXXXXXXXX | XXXXXXXXX |
+===+==============================+=========================+========================+=========================+
| | **X** XXXXXXXXXXX | *X*: __ | *X*: __ | *X*: __ |
+---+------------------------------+-------------------------+------------------------+-------------------------+
| X | **XX** XXX. XXXёX | *XXX*: __ | *XXX*: __ | *XXX*: __ |
| X +------------------------------+-------------------------+------------------------+-------------------------+
| X | **X** XXXёX: (**X** + **XX**)| *XX*: __ | *XX*: __ | *XX*: __ |
| X +------------------------------+-------------------------+------------------------+-------------------------+
| X | **X** XXXXXX | *XX*: __ | *XX*: __ | *XX*: __ |
| X +------------------------------+-------------------------+------------------------+-------------------------+
| | **X** XXXXXXXXX | *XX*: __ | *XX*: __ | *XX*: __ |
+---+------------------------------+------------+------------+------------+-----------+------------+------------+
| | **X** XXXXXX: **X** / 2 | *XX*: __ | *XX*: __ | *XX*: __ |
+---+------------------------------+------------+------------+------------+-----------+------------+------------+
| X | | | | | | | |
| X | +------------+------------+------------+-----------+------------+------------+
| X | | | | | | | |
| X | +------------+------------+------------+-----------+------------+------------+
| X | | | | | | | |
| X | +------------+------------+------------+-----------+------------+------------+
| X | | | | | | | |
| X | +------------+------------+------------+-----------+------------+------------+
| X | | | | | | | |
| X | +------------+------------+------------+-----------+------------+------------+
| X | | | | | | | |
+---+------------------------------+------------+------------+------------+-----------+------------+------------+
Broken table:
+-----------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+------------+---------------------------+-----------+
| | | XXXXXXXXXX | XXXXXXXXXX | XXXXXXXXX |
+=================================================================================================================+================================================================================+============+===========================+===========+
| | **X** XXXXXXXXXXX | *X*: __ | sdfsdfsd fsdf sdf *X*: __ | *X*: __ |
+-----------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+------------+---------------------------+-----------+
| X | **XX** XXX. XXXёX | *XXX*: __ | *XXX*: __ | *XXX*: __ |
| X +------------------------------+-------------------------+------------------------+-------------------------+ | **X** XXXёX: (**X** + **XX**) | *XX*: __ | *XX*: __ | *XX*: __ |
| X | **X** XXXXXX | *XX*: __ | *XX*: __ | *XX*: __ |
| X +------------------------------+-------------------------+------------------------+-------------------------+ | **X** XXXXXXXXX | *XX*: __ | *XX*: __ | *XX*: __ |
| X | | | | |
| X +------------------------------+-------------------------+------------------------+-------------------------+ | | | | |
+-----------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+------------+---------------------------+-----------+
| | **X** XXXXXX: **X** / 2 | *XX*: __ | *XX*: __ | *XX*: __ |
+-----------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+------------+---------------------------+-----------+
| X | +------------+------------+------------+-----------+------------+------------+ | | | |
| X | +------------+------------+------------+-----------+------------+------------+ | | | |
| X | +------------+------------+------------+-----------+------------+------------+ | | | |
| X | +------------+------------+------------+-----------+------------+------------+ | | | |
| X | +------------+------------+------------+-----------+------------+------------+ | | | |
| X | | | | |
| X | | | | |
| X | | | | |
| X | | | | |
| X | | | | |
| X | | | | |
+-----------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------+------------+---------------------------+-----------+
The syntax highlighting built-in with SublimeText is very poor (many users agree: 1, 2, 3)
Important things it doesn't hightlight are:
I've researched a bit to compare another editors with this content.
Hello
-----
:author: Martín Gaitán
:date: today ;-)
Lorem ipsum |genius| sit amet, consectetur
.. code-block::
print 'Hello world'
| quoted
| text
+------+-------+
| this | is |
+======+=======+
| a | table |
+------+-------+
* Link: `this is my blog`_
* Item 2 [1]_
.. |genius| replace:: Lionel Messi
.. [1] A footnote
.. _this is my blog: http://mgaitan.github.io
Using this plugin though Wine
This attemp didn't worked for me. It just changed the color of .. code-block::
directive.
ST3 Build 3083 deactivated tab completions for completions ending in numbers.
Thanks for the package.
CTRL+k shortcut is used in Sublime Text 2 by default, often in combination with secondary keys. All of these don't work for Python/ReST files with this pugin installed.
Please choose something else.
Thank you!
add Sphinx to the list of available render engines, at least to produce HTML.
It's not trivial to render a file standalone, but this trick could be enough: have a project template with a unique rst as source, and write the content in that file before call sphinx-builder
Check this function:
The description of this repo says it only work with Sublime Text 2, but the package info indicates it works with ST3 also.
when I hit "ctrl+t enter" nothing happens. Are the shortcuts for the german keyboard layout different?
Tried header autocompletion for cyrillic header and got this:
заголовок
******************
I think that it will have same issues for other non-latin characters
Sublime can fold a region with self.view.fold
. Make a feature that parse the header tree and fold/unfold each different level
An started point is SmartMarkdown's implementation
https://github.com/demon386/SmartMarkdown/blob/master/smart_folding.py
I am often using :ref: to insert a reference to another chapter, figure, table or whatever. I miss a list of chapters, figures or tables where I can simply select a reference with a keystroke or mouse click.
i pressed ctrl+shift+r
and choosed rst2html,but it outputted nothing and no error reported.
then i modified your codes like below:
def open_result(self, outfile, target):
if target == "html":
os.system("open %s" % outfile)
# webbrowser.open_new_tab(outfile)
now,it works temporarily.
"smart list" should recognize ordered sublist pattern:
For example:
1. Item 1
1.1. Item 1.1
1.2 ....
When I am writing a list like this:
* one cat
* a hippopotamus
* and another hippop<TAB>
the plugin thinks I am writing an h1 and autocompletes to:
****************
* a hippopotamus
****************
note that a blank line above the start of the list needed to replicate this bug, related to #36.
I'm used to using ==
as the title header, and it would be great if there is an option which I can change the default header options. Thanks!
Footnotes definitions should be grouped and ordered in specific region of the document.
Study Markdown's implementation as a starting point
https://github.com/ttscoff/MarkdownEditing/blob/master/footnotes.py
Rstcheck is a simple rst checker.
https://github.com/tkf/rstcheck/blob/master/rstcheck.py
Use flake8lint as example integration.
to https://github.com/dreadatour/Flake8Lint/blob/master/Flake8Lint.py
rstcheck.py
should be run with system python (require docutils)
Hi,
if i write header in chinese, the number of = is not correct as using auto complete.
expected:
What we get after auto complete
The problem is that docutil regard a chinese character as two character, but the python len() function regard it as one character so this plugin make wrong auto completion, is it possible to solve the problem?
foo foo\|\|bar
+-----------+---+-----+
| foo foo\ | \ | bar |
+===========+===+=====+
On Sublime Text 3, the footnote shortcut fails and prints the following to the console:
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 549, in run_
return self.run(edit)
File "footnotes in /Users/phil/Library/Application Support/Sublime Text 3/Installed Packages/Restructured Text (RST) Snippets.sublime-package", line 109, in run
TypeError: begin_edit() missing 2 required positional arguments: 'edit_token' and 'cmd'
As far as I found out, Sublime Text 3 has changed the way begin_edit() is used.
I am unable to render rst files on Mac. I have rst2pdf and pandoc both installed and functional using MacPorts.
When I execute rendering option (rst2pdf) I get two pop-ups the first says
Am I missing something?
At this moment, items are autonumbered is are appended sequentially:_
1. item 1
2. dfdsf
3. xxx
4. |
But if a new item is inserted beetwen 1. and 2. the next are not changed.
1. item 1
2. new item
2. dfdsf
3. xxx
4. |
so, just update the whole list.
A frequent use case for me when writing a long document is to sketch the table of content in advance, in the form of nested unordered lists.
Having this I get a general overview of the structure and can be focused in the content for each "bock", reducing the post-production process (cut & paste paragraphs).
So I want a feature that expand a block like this
- Installing Nikola
- Creating a Blog Post
- Teasers
- Drafts
- Retired Posts
- Creating a Page
to this
Installing Nikola
=================
Creating a Blog Post
====================
Teasers
-------
Drafts
++++++
Retired Posts
+++++++++++++
Creating a Page
===============
The expansion should start at "level 2"
https://github.com/demon386/SmartMarkdown/blob/master/pandoc_render.py
target output (pdf, html, etc. ) could be requested via the mini dialog (prepolutated with common options)
as header parser look for a "block" (separated by blank lines), this not work if there is no blank lines above or below. It happens, for example for top header in the line 1.
Is this functional enough for ST3 that it can be marked as compatible in the package control list? Currently it's only marked as ST2, which means that it doesn't show up and can't be installed from packaged control in ST3.
Example:
IMO, highlighting was
in:
my aunt was a moose
and hitting **
should result in:
my aunt **was** a moose
trying to render a table with in st3 beta I got a TypeError
Traceback (most recent call last):
File "/opt/sublime_text/sublime_plugin.py", line 549, in run_
return self.run(edit)
File "rst_tables in /home/mgaitan/.config/sublime-text-3/Installed Packages/Restructured Text (RST) Snippets.sublime-package", line 72, in run
File "rst_tables in /home/mgaitan/.config/sublime-text-3/Installed Packages/Restructured Text (RST) Snippets.sublime-package", line 249, in parse_table
File "rst_tables in /home/mgaitan/.config/sublime-text-3/Installed Packages/Restructured Text (RST) Snippets.sublime-package", line 209, in unify_table
File "rst_tables in /home/mgaitan/.config/sublime-text-3/Installed Packages/Restructured Text (RST) Snippets.sublime-package", line 209, in <lambda>
TypeError: object of type 'map' has no len()
Hitting <return>
after typing:
.. note::
or
.. admonition:: Example
or
.. math::
should indent to 4 spaces past the '.'
Regression: should be possible to go to a footnote definition with the cursor over the reference ([X]_
) and shift+down
The "Go to anything" is one of the best features in ST, ,making find and navigation a "fuzzymatched" piece of cake. ctrl+R
(or ctrl+P, @
) is the "go to symbol" .
Feed this finder with the parsed header tree data (done in headers.py
).
The h1
and h1o
completions leave one trailing space after the heading text.
So, for instance, if you type h1
, press tab
, enter My New Header
, and press tab
again, then an extra space will remain on the line My New Header
. No extra space appears on the line with the underline or overline characters.
I recorded this animation to show what I mean:
The other heading levels do not leave behind a trailing space, so I assume this is a bug.
Title says it all, but on Mac OS X Mavericks in ST2, writing out lines with two spaces between desired columns and then, with the cursor somewhere in there, hitting then has no effect.
The current "magic table" feature works parsing a grid table line by line, and returning cells content as a raw list of lists. This behavior limits it to parse tables with the same quantity of cells on each row.
So, after use the "merge cell" feature, the table can't be redrawn/reflowed again.
For example, this table
+--------+-------+
| hhol | fddsf |
+========+=======+
| dsfdsf | dfdsf |
| +-------+
| dcdsf | df |
+--------+-------+
Turns into this after apply magically redraw it.
+-----------+-------+
| hhol | fddsf |
+===========+=======+
| dsfdsf | dfdsf |
| +-------+ | df |
| dcdsf | |
+-----------+-------+
I propose replace the current rudimentary parser by the actual code docutils uses here
(see GridTableParser
) and code a complementary writer that understand the parsed output format to write an ascii grid table. I mean get a tuple like:
([24, 12, 10, 10],
[[(0, 0, 1, ['Header row, column 1']),
(0, 0, 1, ['Header 2']),
(0, 0, 1, ['Header 3']),
(0, 0, 1, ['Header 4'])]],
[[(0, 0, 3, ['body row 1, column 1']),
(0, 0, 3, ['column 2']),
(0, 0, 3, ['column 3']),
(0, 0, 3, ['column 4'])],
[(0, 0, 5, ['body row 2']),
(0, 2, 5, ['Cells may span columns.']),
None,
None],
[(0, 0, 7, ['body row 3']),
(1, 0, 7, ['Cells may', 'span rows.', '']),
(1, 1, 7, ['- Table cells', '- contain', '- body elements.']),
None],
[(0, 0, 9, ['body row 4']), None, None, None]])
and return
+------------------------+------------+----------+----------+
| Header row, column 1 | Header 2 | Header 3 | Header 4 |
+========================+============+==========+==========+
| body row 1, column 1 | column 2 | column 3 | column 4 |
+------------------------+------------+----------+----------+
| body row 2 | Cells may span columns. |
+------------------------+------------+---------------------+
| body row 3 | Cells may | - Table cells |
+------------------------+ span rows. | - contain |
| body row 4 | | - body elements. |
+------------------------+------------+---------------------+
Having this, we could not only redraw complex grid tables but do any kind of cell/multicell merges.
Magic Table feature has a flaw with CJK(Chinese, Japanese, Korean) characters. Following text:
aa b.b.
가 나
will be converted into:
+----+----+
| aa | bb |
+====+====+
| 가 | 나 |
+----+----+
which generates 'Malformed Table' error with Sphinx. Right conversion will be:
+----+----+
| aa | bb |
+====+====+
| 가 | 나 |
+----+----+
I guess you should count a CJK character takes two-spaces.
Vim's RST table plugin also has same issue. So, there are specific plugin to solve this:
https://github.com/vim-scripts/RST-Tables-CJK
Following python package might be handy for you:
https://pypi.python.org/pypi/wcwidth/
I hope you can fix it without much trouble.
Thank you.
The default key map of ctrl+b for strongemphasis on windows system conflict to the key binding for sublime's Build command. I guess it is better to avoid ctrl+b by default.
'cause "A picture is worth a thousand words".
I like the "live demo" style of Ninja-Ide's one, with the on screen keys
https://www.youtube.com/watch?v=tDlWk_Z7JPQ
show ctrl+shift+r
a quick window , but this can't be canceled.
ESC
select the last option (docx
by default) and, depending the system, libreoffice it's open.
So, allow esc
cancel the render preview silently
I wonder it is the problem on pandoc side or arguments passing? Both selection of html (pandoc)', 'html (rst2html)' are the same error.
The file is located at C:\Users{Username}\AppData\Local\Temp but the file is 0 bytes.
I manually tested this command below and the HTML successful generated.
C:\Users\User>pandoc C:\Users\User\Desktop\rstTest.rst -o C:\Users\User\Desktop\rstTest.html
The Pandoc Path was
C:\Users\User\AppData\Local\Pandoc
Installed a fresh copy of ST3 on new machine with Yosemite.
Installed Package Control and sublime-rst-completion.
I've tried installing both the PC version and source via GitHub.
Many of the key bindings (super+shift+t, super+shift+b, etc)
I notice that in the console that after trying what should be this packages key binding:
no command for selector: noop:
Not even sure what is wrong or going on.
super+shift+r seems to be the only binding that I can find that works.
* I once was a hippopotamus
* hippo<TAB>
does not autocomplete.
the header autocompletion trigger only recognize a very reduced subset of valid adornments characters.
{ "key": "preceding_text", "operator": "regex_contains", "operand": "^[=\\-\\*\\+]+" }
So if you have something like
A valid header
~~~<TAB>
It wont be autocompleted.
Complete the regex operand with a complete list of valid adornemets . In python it is:
ADORNEMENTS = r"""[!\"#$%&'\\()*+,\-./:;<=>?@\[\]\^_`{|}~]"""
This plugin supports the main admonitions and things of the form:
.. something::
that are defined in docutils documentation, but could it also support others e.g. the ones defined by Sphinx here or plugins for Sphinx like the mathjax/pngmath plugin that uses the syntax:
.. math::
Supporting all of Sphinx's extensions may also get unwieldy pretty fast, especially with reserved keyword shortcuts for each. Perhaps this plugin can suggest an auto-completion when .. m
(for example) has been typed. Also, if this method were used for all explicit markup constructs (like .. note::
, .. danger::
, etc.), there would be less conflict with the built-in word autocompletion provided by Sublime Text.
An example of the conflict I'm talking about:
If I want to write "admonition", and have typed it before, I could type:
admon<TAB>
but if I wanted the explicit markup construct, I could type:
.. ad<TAB>
Feel free to disagree with me; there are a lot of Sphinx extensions, it seems. (built-in extensions are listed and documented here)
env:
I want to render .rst to html, so ctrl+shift+r to choose rst2html
, but it outputs following error:
WindowsError Traceback (most recent call last)
<ipython-input-52-ec60d029fb7d> in <module>()
1 reload(subprocess)
----> 2 subprocess.call(['rst2html.py', r'c:\Users\honghe\bae\hello_sphinx\index
.rst',r'd:\test.html'])
D:\Python27\lib\subprocess.py in call(*popenargs, **kwargs)
523 """
524 print 'popenargs', popenargs
--> 525 return Popen(*popenargs, **kwargs).wait()
526
527
D:\Python27\lib\subprocess.py in __init__(self, args, bufsize, executable, stdin
, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, st
artupinfo, creationflags)
710 p2cread, p2cwrite,
711 c2pread, c2pwrite,
--> 712 errread, errwrite)
713 except Exception:
714 # Preserve original exception in case os.close raises.
D:\Python27\lib\subprocess.py in _execute_child(self, args, executable, preexec_
fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell,
p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite)
948 env,
949 cwd,
--> 950 startupinfo)
951 except pywintypes.error, e:
952 # Translate pywintypes.error to WindowsError, which is
WindowsError: [Error 193] %1 is not a valid Win32 application
Windows can't interpret the file rst2html.py
?
#!D:\Python27\python.exe
# $Id: rst2html.py 4564 2006-05-21 20:44:42Z wiemann $
# Author: David Goodger <[email protected]>
# Copyright: This module has been placed in the public domain.
Add a keybinding for decreasing or increasing headline levels.
The level markup should be autodetected from the document, or use a default (sphinx's convention, may be)
reference:
https://github.com/demon386/SmartMarkdown/blob/master/headline_level.py
Look like Default (Windows).sublime-keymap was not updated with last additions from others OS.
I'm not sure why, but the h1-h6 snippets do not work on OSX. All the other snippets do work.
Hi there, I've been trying to install this package this morning. Either manually or through Package control, i couldn't get the package to work properly. Even the completion doesn't work at all. I first thought there must be some conflicts with my old packages, so I removed the HTML and CCS snippets. But the issue is still there, trying find same problems using google as well as possible solutions. Anybody can help me out? Thank you.
SmartMarkdown has a feature to move to the next/previous headline (any level, same level or higher level). Borrow and improve that.
Reference
https://github.com/demon386/SmartMarkdown/blob/master/headline_move.py
The plugin doesn't work with Sublime Text 3 (at least, not the version installed from Package Control).
Here are the errors I get:
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 73, in reload_plugin
m = importlib.import_module(modulename)
File "X/importlib/__init__.py", line 88, in import_module
File "<frozen importlib._bootstrap>", line 1577, in _gcd_import
File "<frozen importlib._bootstrap>", line 1558, in _find_and_load
File "<frozen importlib._bootstrap>", line 1525, in _find_and_load_unlocked
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 671, in load_module
exec(compile(source, source_path, 'exec'), mod.__dict__)
File "headers in /Users/lorin/Library/Application Support/Sublime Text 3/Installed Packages/Restructured Text (RST) Snippets.sublime-package", line 1, in <module>
ImportError: No module named 'helpers'
reloading plugin Restructured Text (RST) Snippets.headline_move
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 73, in reload_plugin
m = importlib.import_module(modulename)
File "X/importlib/__init__.py", line 88, in import_module
File "<frozen importlib._bootstrap>", line 1577, in _gcd_import
File "<frozen importlib._bootstrap>", line 1558, in _find_and_load
File "<frozen importlib._bootstrap>", line 1525, in _find_and_load_unlocked
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 671, in load_module
exec(compile(source, source_path, 'exec'), mod.__dict__)
File "headline_move in /Users/lorin/Library/Application Support/Sublime Text 3/Installed Packages/Restructured Text (RST) Snippets.sublime-package", line 198
print "lenght", tree._text_lenght
^
SyntaxError: invalid syntax
reloading plugin Restructured Text (RST) Snippets.helpers
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 73, in reload_plugin
m = importlib.import_module(modulename)
File "X/importlib/__init__.py", line 88, in import_module
File "<frozen importlib._bootstrap>", line 1577, in _gcd_import
File "<frozen importlib._bootstrap>", line 1558, in _find_and_load
File "<frozen importlib._bootstrap>", line 1525, in _find_and_load_unlocked
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 671, in load_module
exec(compile(source, source_path, 'exec'), mod.__dict__)
File "helpers in /Users/lorin/Library/Application Support/Sublime Text 3/Installed Packages/Restructured Text (RST) Snippets.sublime-package", line 33
print e
^
SyntaxError: invalid syntax
reloading plugin Restructured Text (RST) Snippets.render_rst
reloading plugin Restructured Text (RST) Snippets.rst_tables
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 73, in reload_plugin
m = importlib.import_module(modulename)
File "X/importlib/__init__.py", line 88, in import_module
File "<frozen importlib._bootstrap>", line 1577, in _gcd_import
File "<frozen importlib._bootstrap>", line 1558, in _find_and_load
File "<frozen importlib._bootstrap>", line 1525, in _find_and_load_unlocked
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 671, in load_module
exec(compile(source, source_path, 'exec'), mod.__dict__)
File "rst_tables in /Users/lorin/Library/Application Support/Sublime Text 3/Installed Packages/Restructured Text (RST) Snippets.sublime-package", line 54, in <module>
ImportError: No module named 'helpers'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.