Giter Club home page Giter Club logo

sublimetext-asciidoc's Introduction

AsciiDoc Package for SublimeText 3

This package provides more complete and up-to-date syntax highlighting, snippets and other goodies for AsciiDoc editing in SublimeText 3.

TODO

Features

Keymaps

  • Asterisks (strong), underscores (emphasis), backticks (monospaced), English quotation marks, and Czech quotation marks are autopaired and will wrap selected text.
    • If you start an empty pair and hit backspace, both elements are deleted.
    • If you start an empty asterisks pair and hit Space or Tab, the right element is deleted (because you probably wanted to start a list, not a strong text).
  • At the end of a (un)ordered list item, pressing Enter will automatically insert the new list item “bullet.”
    • Pressing Enter on the blank list item will remove it.
    • Pressing Tab on the blank list item, or selected item(s), will increase nesting level and indent it.
    • Pressing Shift Tab on the blank list item, or selected item(s), will decrease nesting level and unindent it.
    • You can disable indentation of list items in your settings file.
  • At the end of a callouts list item, pressing Enter will automatically insert the new list item with incremented number.
    • Pressing Enter on the blank list item will remove it.

Snippets

Name Trigger
Button btn⇥
Comment Block //⇥
Document Title h0⇥
Example Block
Footnote Reference fnr⇥
Footnote fn⇥
Image img⇥
Keyboard Shortcut kbd⇥
Listing Block --⇥
Passthrough Block
Quote Block __⇥
Section Title 1–5 h1⇥, …, h5⇥
Sidebar block
Table

Others

  • Displays document and section titles in the local symbol list (Ctrl R / Cmd R) and the global symbol list (Ctrl Shift R / Cmd Shift R).
    • In the local symbol list, titles are nicely indented.
    • In the global symbol list, titles will start with =, so you will know they belong to AsciiDoc files at a glance. Also they will be on top of the list because of the presedence of =.
  • Defines comment markers, so you can use default commands to comment and uncomment lines of text.
  • Provides completions for attributes (built-in and locally defined) and cross references (local anchors and titles).

Installation

Note: If you have installed the AsciiDoc package, then you should remove it, or manually assign .adoc extension to the Asciidoctor plugin.

Package Control

The easiest way to install this plugin is to use the Package Control plugin.

  1. Install Package Control, if you don’t have it already.
  2. Open the Command Palette (Ctrl Shift P, or Cmd Shift P), type “Install package” and hit Enter.
  3. Search for “Asciidoctor” and hit Enter.

Manually

You can also install this plugin manually from GitHub if you want, although Package Control automates just that.

  1. Go to your Packages subdirectory under the ST3’s data directory:

    • OS X: ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/
    • Linux: ~/.config/sublime-text-3/Packages/
    • Windows: %APPDATA%\Sublime Text 3\Packages\
  2. Clone this repository here into subdirectory Asciidoctor:

     git clone https://github.com/asciidoctor/sublimetext-asciidoc.git Asciidoctor
    
  3. Restart SublimeText.

Acknowledgement

The syntax definition is based on AsciiDoc-TextMate-2.tmbundle by Matt Neuburg.

Most of the commands, keymaps and some text in this readme are based on (or inspired by) MarkdownEditing package.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

This project is licensed under MIT License. For the full text of the license, see the LICENSE file.

sublimetext-asciidoc's People

Contributors

jirutka avatar mattneub 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  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sublimetext-asciidoc's Issues

Syntax Highlighting Breaks With `_`

I've encountered problems with the following:

[NOTE]
================================================================================
You might want to output “$400” but “$4” will be interpreted as the indefinite form of the fourth parameter, as described below. So you need to use the ‘_’ to make that happen (“$_400”).
================================================================================

Where the _ in ‘_’ starts a never-ending italic styling in the highlighting, breaking the syntax highlighter from there onward.

(this issue might be related to Issue #12)

I've tried various approaches to the problem (escapes, non-curly quotes, and even `_` etc.) but either it solved the problem in ST code preview but broke the intended output, or didn't solve the problem at all.

I'll try to have a look at the syntax file myself when I find some time, but right now I'm just opening an issue to report the problem.

Most likely, the syntax definition that handles italics needs some tweaking, as that underscore should not trigger an italic style.

Also, it seems to lack bail-out fallbback checks to handle malformed code — as a general rule, syntax definitions should account for partial or malformed code, the former to handle when the user momemntarily interrupts what he was coding, leaving behind some incomplete syntax, the latter to handle malformed documents. In both cases the syntax highlighter shouldn't break so badly as to compromise the rest of the document:

Option to NOT trim trailing whitespace on save

Hi!

I use firefox w. the asciidoctor addon to preview my writing.

I'd like to use the package 'Autosave', so that each time I alter the document, the preview is updated. However, it breaks my flow, that the last trailing whitespace is removed, andiendupwritingthingswithnospaceinbetween - which is rather annoying.

Luckily sublime text has a user setting "trim_trailing_white_space_on_save" that I can set to 'false'

Unfortunately, the asciidoctorpackage overrules this setting, and insists on removing trailing whitespace.

I'd suggest an option for the user to decide whether this whitespace should be trimmed or not. Most easy would probablye be, to simply check the "trim_trailing_white_space_on_save" - and behave accordingly

Two line title syntax not working

Description:

Both two line and one line titles are supported in asciidoctor, however they are not parsed correctly in the Sublime test Asciidoctor plugin.

The syntax parser / highlighter should not fail to parse documents that are in proper Asciidoctor accepted formats, even though the two line title format is not documented.

What I tried to do

I tried to edit a document using the title format

My Document Title
=================

What I expected to happen

The syntax highlighter in the asciidoctor pluginn would highlight the two line title, or at least accept the syntax of the two line titile.

What actually happened

The syntax highlighter identified the two line format as an error and failed to properly highlight the remainder of the document.

Recommended Change

Change the Asciidoctor plugin to accept the two line document title format, or at least not generate an error when the two line format is used.

Why this is important

Organizations who have built their documentation standards on Asciidoc, have specified the two line format as part of their standards. Not supporting this important Asciidoc feature, renders the plugin useless in these organizations.

Syntax highlighter doesn't match rendering behaviour

The syntax highlighter's rules don't match asciidoctor rendering for what to do when there's only one
~, ^, *, or _ in a block. For example, if I have the following as a paragraph, the renderer will give the expected output, but the highlighter will highlight my entire text (until it finds another tilde, of course) as though it were subscripted.

Add this line to `~/.bash_profile`:

I can't escape out the tilde, because the actual backslash gets rendered in the output document.

Build system [enhancement]

Add a build system that is automatically associated with text.html.asciidoc selector, to be invoked with + B.

OSX specific:

{
    "cmd": ["/Users/<user>/.rbenv/shims/asciidoctor", "$file"],
    "selector": ["text.html.asciidoc","text.asciidoc"]
}

Snippet enhancement: follow recommended practices for delimited blocks

First of all, thanks for this fantastic extension for Sublime text! That's simply the best way to write AsciiDoc. 😄

I've got a suggestion regarding the snippets: currently, when you create a listing or quote block, a huge number of delimiters is created. E.g.

[source, ruby]
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------

However, the official recommended practices say that you should use no more than 4 such characters.

[source, ruby]
----

----

Since this is the official AsciiDoctor package for Sublime, I think it would make sense to follow these guidelines. If you want, I can send a pull request with the necessary changes.

Thanks a lot in advance for considering this small change!

Checkbox in list breaks highlighting

I don't know if this repository is even maintained anymore, but i just stumbled across the following issue while using bat.

bat uses this library for their syntax highlighting of .adoc files and I've found the issue while implementing a test for the AsciiDoctor syntax highlighting in this PR.

Creating a checked checkbox with the * inside a list breaks the syntax highlighting of subsequent text (the first line below).

* [*] checked
* [x] also checked
* [ ] not checked
*     normal list item

This is considered valid syntax in the AsciiDoc Syntax Quick Reference.

Undesired bold and italic

There is a bug with text becomes italic.

Example 1:

.Hot to become a Vim ninja
1. Edit your _vimrc file.
2. Run Vim.

This text is italic. Bad.

Example 2:

https://en.wikipedia.org/wiki/List_of_concept-_and_mind-mapping_software

This text is italic. Bad.

Example 3:

1. Select any *.html files.
2. Copy them to another directory.

This text is bold. Bad.

Key bindings in User folder are overwritten

Here is my Default (Windows).sublime-keymap file located in Packages/User directory:

[
    // Auto-pair _
    { "keys": ["_"], "command": "insert_snippet", "args": {"contents": "_$0_"}, "context":
        [
            { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
            { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
            { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|>|$)", "match_all": true },
            { "key": "preceding_text", "operator": "not_regex_contains", "operand": "[a-zA-Z0-9_]$", "match_all": true },
            { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.other - punctuation.definition.string.end", "match_all": true },
            { "key": "selector", "operator": "equal", "operand": "text.plain" },
        ]
    },
    { "keys": ["_"], "command": "insert_snippet", "args": {"contents": "_${0:$SELECTION}_"}, "context":
        [
            { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
            { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true },
            { "key": "selector", "operator": "equal", "operand": "text.plain" },
        ]
    },
    { "keys": ["_"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
        [
            { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
            { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
            { "key": "following_text", "operator": "regex_contains", "operand": "^_", "match_all": true },
            { "key": "selector", "operator": "not_equal", "operand": "punctuation.definition.string.begin", "match_all": true },
            { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.other - punctuation.definition.string.end", "match_all": true },
            { "key": "selector", "operator": "equal", "operand": "text.plain" },
        ]
    },
    { "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Left Right.sublime-macro"}, "context":
        [
            { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
            { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
            { "key": "preceding_text", "operator": "regex_contains", "operand": "_$", "match_all": true },
            { "key": "following_text", "operator": "regex_contains", "operand": "^_", "match_all": true },
            { "key": "selector", "operator": "not_equal", "operand": "punctuation.definition.string.begin", "match_all": true },
            { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.other - punctuation.definition.string.end", "match_all": true },
            { "key": "selector", "operator": "equal", "operand": "text.plain" },
        ]
    },

    // Auto-pair *
    { "keys": ["*"], "command": "insert_snippet", "args": {"contents": "*$0*"}, "context":
        [
            { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
            { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
            { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|>|$)", "match_all": true },
            { "key": "preceding_text", "operator": "not_regex_contains", "operand": "(^[*\\s]*$)|([*a-zA-Z0-9_]$)", "match_all": true },
                // ^ Нужно ли экранировать первую звёздочку в (^[*\\s]*$) и звёздочку в ([*a-zA-Z0-9_]$)? Нет, потому что они внутри [].
            { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.other - punctuation.definition.string.end", "match_all": true },
            { "key": "selector", "operator": "equal", "operand": "text.plain" },
        ]
    },
    { "keys": ["*"], "command": "insert_snippet", "args": {"contents": "*${0:$SELECTION}*"}, "context":
        [
            { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
            { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true },
            { "key": "selector", "operator": "equal", "operand": "text.plain" },
        ]
    },
    { "keys": ["*"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
        [
            { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
            { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
            { "key": "following_text", "operator": "regex_contains", "operand": "^\\*", "match_all": true },
            { "key": "selector", "operator": "not_equal", "operand": "punctuation.definition.string.begin", "match_all": true },
            { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.other - punctuation.definition.string.end", "match_all": true },
            { "key": "selector", "operator": "equal", "operand": "text.plain" },
        ]
    },
    { "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Left Right.sublime-macro"}, "context":
        [
            { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
            { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
            { "key": "preceding_text", "operator": "regex_contains", "operand": "\\*$", "match_all": true },
            { "key": "following_text", "operator": "regex_contains", "operand": "^\\*", "match_all": true },
            { "key": "selector", "operator": "not_equal", "operand": "punctuation.definition.string.begin", "match_all": true },
            { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.other - punctuation.definition.string.end", "match_all": true },
            { "key": "selector", "operator": "equal", "operand": "text.plain" },
        ]
    },
]

If you press * it the middle of the line, it will paired (it will be **). However, if you press it in the beginning of the line, it will not be paired (it will be just *).

However, after I have have installed AsciiDoc package, this behavior have changed (in adoc files). The * is now paired in the beginning of the line as well.

I don't like this change, but I opened this issue for the different reason: how is it possible that some package overwrite my key bindings located in User folder? As I know, User folder is loaded the last and therefore it seems that there is no way to overwrite key bindings in it. But I see now, it somehow done.

Coloring Improvement

Hi, first thanks for your work about the integration of asciidoc support :).
I would like to help but I don't know how to enhance the plugin to add color on various title level.
I mean it will be very useful to color titles to have better view when writing an asciidoc.
Thanks in advance if someone can do it or give me documentation or file entry of the plugin to realized it in my side.

Buggy as hell

Sadly, the syntax highlighting is buggy as hell. Here is the list of bugs (incomplete).

== Aaa

== "Bbb"

== Ccc
foo `_vimrc` bar
* For CR and LF - use \, not `.
+
----
MsgBox,,, % RegExReplace("Line 1`nLine 2`n", "\n$", "")
----
[NOTE]
====
They don't support regex syntax and therefore don't support \.
====
Indentation with #If, hotkeys, labels

foo
https://www.apple.com/macos/what-is/#automator
`*.jpg *.png`::
image files

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.