Giter Site home page Giter Site logo

sparkup's Introduction

Sparkup

Sparkup lets you write HTML code faster. Don't believe us? See it in action!

Fixed by Zhao: This is a fork of original version. This version support both python 2 and 3.

You can write HTML in a CSS-like syntax, and have Sparkup handle the expansion to full HTML code. It is meant to help you write long HTML blocks in your text editor by letting you type less characters than needed.

Sparkup is written in Python, and requires Python 2.5 or newer (2.5 is preinstalled in Mac OS X Leopard). Sparkup also offers integration into common text editors. Support for VIM and TextMate are currently included.

A short screencast is available here: http://www.youtube.com/watch?v=Jw3jipcenKc

Usage and installation

You may download Sparkup from GitHub. Download the latest version here.

  • TextMate: Simply double-click on the Sparkup.tmbundle package in Finder. This will install it automatically. In TextMate, open an HTML file (or set the document type to HTML) type in something (e.g., #header > h1), then press Ctrl + E. Pressing Tab will cycle through empty elements.

  • VIM: See the vim/README.txt file for installation. In VIM, create or open an HTML file (or set the filetype to html), type in something (e.g. #header > h1), then press <C-E> whilst in insert mode to expand to HTML. Pressing <C-n> will cycle through empty elements. Variables specified in vim/README.txt can be used to customise key mappings, and to add normal mode mappings as well.

  • Others/command line use: You may put sparkup in your $PATH somewhere. You may then invoke it by typing echo "(input here)" | sparkup, or sparkup --help for a list of commands.

Credits

Sparkup is written by Rico Sta. Cruz and is released under the MIT license.

This project is inspired by Zen Coding of Vadim Makeev. The Zen HTML syntax is forward-compatible with Sparkup (anything that Zen HTML can parse, Sparkup can too).

The following people have contributed code to the project:

  • Guillermo O. Freschi (Tordek @ GitHub) Bugfixes to the parsing system

  • Eric Van Dewoestine (ervandew @ GitHub) Improvements to the VIM plugin

Examples

div expands to:

<div></div>

div#header expands to:

    <div id="header"></div>

div.align-left#header expands to:

    <div id="header" class="align-left"></div>

div#header + div#footer expands to:

    <div id="header"></div>
    <div id="footer"></div>

#menu > ul expands to:

    <div id="menu">
        <ul></ul>
    </div>

#menu > h3 + ul expands to:

    <div id="menu">
        <h3></h3>
        <ul></ul>
    </div>

#header > h1{Welcome to our site} expands to:

    <div id="header">
        <h1>Welcome to our site</h1>
    </div>

a[href=index.html]{Home} expands to:

    <a href="index.html">Home</a>

ul > li*3 expands to:

    <ul>
        <li></li>
        <li></li>
        <li></li>
    </ul>

ul > li.item-$*3 expands to:

    <ul>
        <li class="item-1"></li>
        <li class="item-2"></li>
        <li class="item-3"></li>
    </ul>

ul > li.item-$*3 > strong expands to:

    <ul>
        <li class="item-1"><strong></strong></li>
        <li class="item-2"><strong></strong></li>
        <li class="item-3"><strong></strong></li>
    </ul>

table > tr*2 > td.name + td*3 expands to:

    <table>
        <tr>
            <td class="name"></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td class="name"></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    </table>

#header > ul > li < p{Footer} expands to:

    <!-- The < symbol goes back up the parent; i.e., the opposite of >. -->
    <div id="header">
        <ul>
            <li></li>
        </ul>
        <p>Footer</p>
    </div>

sparkup's People

Contributors

albfan avatar blueyed avatar davidjb avatar duncannz avatar ervandew avatar faceleg avatar fortable1999 avatar grahamc avatar gryftir avatar jefffederman avatar kitmonisit avatar lukaszkorecki avatar maurizi avatar nixon avatar profpatsch avatar rstacruz 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  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  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

sparkup's Issues

Have problem with using sparkup in Win gVim

File "\Program Files\Vim\vimfiles\ftplugin\html\sparkup.py", line 949
print "Usage: %s [OPTIONS]" % sys.argv[0]
^

SyntaxError: invalid syntax

I read readme.txt and still don't know how to use sparkup.
I tried c-e, then get the error.
I installed python 3.1, it cause the error?

Redundant sparkup.py files

The sparkup.py file exists twice, once in the main sparkup folder, and once in the vim plugin folder. That redundancy should be removed for maintenance reasons.

installing sparkup on vim

Hello I am new to both sparkup and vim and I cant get sparkup working. What I have done. Copied the ftplugin folder to ~/.vim/ I have added the following config lines to my .vimrc file

let g:sparkup = 'sparkup'
let g:sparkupArgs = '--no-last-newline'
let g:sparkupExecuteMapping = ''
let g:sparkupNextMapping = ''

I have also put sparkup bin in my /usr/local/bin and i can confirm this is in my path. I restart vim and run :g:sparkup and E486 i get pattern not found. I am new to vim so I am sure I have missed something. Thanks for any help in advance.

Meta tag should not close itself

In html4 or html5, the meta tag should not close itself.
i.e.,
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
not
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />

Not working with eruby

With this commit: 2642aad Sparkup isn't working with .html.erb files, the error message is:

Options error: option --eruby not recognized
Try --help for a list of arguments.

I could not find the exactly source of the problem, but before this commit everything was working fine.

Option to allow tab indentation

I use tabs for indenting my HTML code, so I can't make use of this excellent util.

Maybe if the snippets were defined in \t instead of ' ', it would be easier for all, since you could tell the parser to replace a '\t\ into four spaces or whatever the user wants.

sparkup ignores brackets

statements like this can be useful:

h2+(h3+(div.myclass>p)*3)

This structure allows you to apply multipliers to targeted sections of your semantic structure.

It seems that this cannot be done in sparkup presently.

Sparkup suddenly behaves incorrectly

Hi! I've been using Sparkup extensively in Vim (and in TextMate before) for over one year and a half without any issue.

My primary use for Sparkup is (alas!) coding HTML emails which involves a lot of nested tables.

Well. I've been lucky enough to not do any HTML emails in the last month so I'm not sure when it happened but Sparkup now does something quite weird: whatever stub I use (a,p,table…), the final tag is always a div. For example:

p

would become:

<div></div>

To make things even weirder, the problem only happens on the first tag:

p > span{lorem ipsum}

would become:

<div>
  <span>lorem ipsum</span>
</div>

The issue remains:

  • with or without any of my plugins
  • with or without any of my ftplugins
  • with or without any of my settings
  • with or without any of my mappings
  • with or without any of my custom functions
  • when installing Sparkup "normally" (without Pathogen)

My system:

  • Mac OS X 10.6.8
  • Vim 7.3.315 and the default Vim 7.2.108
  • Python 2.7.3 (via MacPorts)

My Vim files:

FYI, I don't experience the issue on a VPS of mine or my Ubuntu machine at home using a clone of the repo above:

  • Ubuntu 10.04 LTS and 11.04
  • Vim 7.2.330 and Vim 7.3.35
  • Python 2.6.5 and Python 2.7.1

Thanks.

indent-spaces ignored in html:* shortcuts

The html:* shortcuts in HtmlDialect use ' ' + '<meta...' to indent, using 4 hardcoded spaces instead of the option set via 'indent-spaces'. Full example:

    'html:5': {
        'expand': True,
        'opening_tag':
            '<!DOCTYPE html>\n' +
            '<html lang="en">\n' +
            '<head>\n' +
            '    ' + '<meta charset="UTF-8" />\n' +
            '    ' + '<title></title>\n' + 
            '</head>\n' +
            '<body>',
        'closing_tag':
            '</body>\n' +
            '</html>'},

auto numbering not recursive

if i want to do a block of thumbnails:

<a href="#" id="1"><img src="1.jpg"></a>
<a href="#" id="2"><img src="2.jpg"></a>

it would be nice to use:
a[href=#][id=$] *5 > img[src=$.jpg]

And have the numbers match.

Currently I get:

<a href="#" id="1"><img src="1.jpg"></a>
<a href="#" id="2"><img src="1.jpg"></a>

Would like Compass-like feature

see http://wiki.github.com/chriseppstein/compass/

I can run compass -w and it sits in the current path watching for changes to files. It has a config.rb (but you could just do config.yaml or something) which specifies src and target directories. This way you could theoretically keep a directory full of .sparkup files and have the compiler watching them for changes, immediately writing out .html files to the target directory when that occurs.

This would allow you to exclusively maintain projects using sparkup, with version control for the sparkup, and ability to integrate with a wider toolset/environment (such as Aptana, my personal favorite).

Great concept!

Is this project dead?

I don't see much commit activity. There are bunch of pull requests and lot's of issues..

Vim plugin documentation issues

Just from reading the README.txt file, I don't quite understand how to configure the plugin, I can see the description of the options, but don't know where to edit them. A note in the README file would be nice.

Problem with special characters between "{}" in Vim

when you type "a.class-${$}*3" you get:

<a href="" class="class-1">$</a>
<a href="" class="class-2">$</a>
<a href="" class="class-3">$</a>

but if you type "a.class-${+ more}*3" you get:

<a href="" class="class-1"></a>
<more></more>
<more></more>
<more></more>

the correct is:

<a href="" class="class-1">+ more</a>
<a href="" class="class-2">+ more</a>
<a href="" class="class-3">+ more</a>   

i think the order of the regular expressions are the problem...

Suggestion: closure comment

In elements as div, ul, etc its a good practice to comment where your tag ends (because of indentation):

ie:

<div id="test">
    Some Content
</div> <!-- #test -->

<div id="test" class="my-cool-class">
    Some Content
</div> <!-- #test .my-cool-class -->

<div id="parent" class="my-cool-class">
    <div id="child">
        Some Content
    </div><!-- #child -->
</div> <!-- #parent .my-cool-class -->

What do you think?

Cheers

mw

Vim: consider different default mappings, which do not overlap with default maps

Both Ctrl-e and Ctrl-n have default meanings already, and therefore should not get remapped by default:

CTRL-E      Insert the character which is below the cursor.  {not in Vi}
CTRL-N      Find next match for words that start with the
        keyword in front of the cursor, looking in places
        specified with the 'complete' option.  The found
        keyword is inserted in front of the cursor.

While it is quite easy to configure this via g:sparkupExecuteMapping and g:sparkupNextMapping, that does not mean that the defaults might not get improved.

I have no particular suggestion myself, but maybe just something using <Leader> as prefix?

This is related to issue #35.

Setup Sparkup for Vim without ftplugins

I'd like to setup Sparkup vor Vim without using the ftplugins approach.

The thing is, in a situation where I could use Sparkup, I just created a new file and didn't save it yet. Therefore the file has no filetype, and to vim it has no filetype.

Is there a way to get the plugin loades without using the ftplugin approach?

(Also, I heard the ftplugin causes problems with disabled autoindent feature)

Expanding child/parent multiplier line fails…

I'm trying to expand this line but it seems I made a mistake in there somewhere…

ul*4>li.header>h1+p<li*4>a[href=#]

which outputs:

<ul>
    <li class="header">
        <h1></h1>
        <p></p>
    </li>
    <li>
        <a href="#"></a>
    </li>
    <li>
        <a href="#"></a>
    </li>
    <li>
        <a href="#"></a>
    </li>
    <li>
        <a href="#"></a>
    </li>
</ul>
<ul>
    <li class="header">
        <h1></h1>
        <p></p>
    </li>
</ul>
<ul>
    <li class="header">
        <h1></h1>
        <p></p>
    </li>
</ul>
<ul>
    <li class="header">
        <h1></h1>
        <p></p>
    </li>
</ul>

Where it should be:

<ul>
    <li class="header">
        <h1></h1>
        <p></p>
    </li>
    <li>
        <a href="#"></a>
    </li>
    <li>
        <a href="#"></a>
    </li>
    <li>
        <a href="#"></a>
    </li>
    <li>
        <a href="#"></a>
    </li>
</ul>
<ul>
    <li class="header">
        <h1></h1>
        <p></p>
    </li>
    <li>
        <a href="#"></a>
    </li>
    <li>
        <a href="#"></a>
    </li>
    <li>
        <a href="#"></a>
    </li>
    <li>
        <a href="#"></a>
    </li>
</ul>
<ul>
    <li class="header">
        <h1></h1>
        <p></p>
    </li>
    <li>
        <a href="#"></a>
    </li>
    <li>
        <a href="#"></a>
    </li>
    <li>
        <a href="#"></a>
    </li>
    <li>
        <a href="#"></a>
    </li>
</ul>
<ul>
    <li class="header">
        <h1></h1>
        <p></p>
    </li>
    <li>
        <a href="#"></a>
    </li>
    <li>
        <a href="#"></a>
    </li>
    <li>
        <a href="#"></a>
    </li>
    <li>
        <a href="#"></a>
    </li>
</ul>

Any ideas on how I can get this to work?

Thanks for taking a look.

h3 expanded as 'div'

h2+(h3*3)

I expect an h2 followed by three h3's.
However, the h3's get expanded as divs.

I can't get sparkup to work.

I put it in my ftplugins folder, then in vim I do run filetype indent plugin on, the `source ~/.vim/ftplugins/html/sparkup.vim.

Now, in an html file, when I press it acts all funy in insert mode. The cursor jumps to the beginning of the line then back real quickly to the beginning of the shortcut text. I see call :call 78_Sparkup() for a brief moment in my command line. The end result is absolutely nothing; no changes to the buffer.

Am I doing something wrong? I'm using Python 2.7.

Coda Support

How soon can we expect this to be supported in Coda?

Integration in Janus

Hi,

I try to install sparkup in janus (https://github.com/carlhuda/janus) but it seems not to work. What I did was creating a sparkup folder inside my .janus folder and then copy the content from ftplugin into it.

I tried different folder names and nesting the sparkup stuff differentially but noting worked.

Can someone please tell me what I did wrong? Thanks in advance.

  • Stefan

capitalization fail ?

Hello,

simple expansion such as :

groupId{foobar}

will give :

groupid>foobar</groupid>

Case isn't kept.

Any tips on this ?

how to expand, and better install directions for vim on windows?

Hello, I am trying to get this working in windows. I know nothing about python. Is python required in addition to vim?
I have installed vim and put the contents of vim/ftpplugin in the ftpplugin in my vim directory. have no idea what "g:sparkup" means, is that run in vim or command line, or python?
I will install python if necesarry, but please explain sparkup installation in a way that doesn't presume knowledge of python and/or shell commands.

Multiplier and backward selector problem

As reported via email by Michal. Report quoted below.

if you type:
li*2>dd>dt>a>img<<dl

it produces:

 <li>
     <dd>
         <dt>
             <a href="">
                 <img src="" alt="" />
             </a>
         </dt>
         <dl></dl>
     </dd>
 </li>
 <li>
     <dd>
         <dt>
             <a href="">
                 <img src="" alt="" />
             </a>
         </dt>
     </dd>
 </li>

Note the lack of <dl/> tag in second <li/>

Vim: elements being converted to divs

I hope this isn't already reported but the only other information I found about this was a comment on this issue: https://github.com/rstacruz/sparkup/issues#issue/12

I don't have the issue in 'pure' html files. This happens in aspx template files.

Example:
h1#head

result:

.

It's the same other elements. I can work around it by typing something like div > h1 etc and then delete the extra div but it's not very handy.

button -> input[type=button]

I think this synonim is a kind of mistake. Others are ok, but don't forget that the button tag exists and some people like it :)

Unable to call Sparkup in vim `htmldjango` filetypes

Hey,

I'm currently unable to call Sparkup when working with htmldjango filetypes. I was wondering if there was a command I could put in my .vimrc or something enable this — I've messed around with changing the filetypes, etc.

Thanks for any help, man.

Zach

Vim plugin stopped working

I updated the old vim script to the current one, and now it doesn't work anymore. What i did:

  • removed /usr/local/bin/sparkup
  • removed ~/.vim/scripts/sparkup.vim
  • removed mappings in vimrc
  • copied ftplugin folder from current version to ~/vim/ftplugin

If i understood the readme correctly, it should now work with html files. But it doesn't...

expansion code failed ?

I write html:5 press C-e, then it became <html:u></html:u>

div became <diu></diu>

All code expansioned like that, the last latter became 'u' than expansioned...

Is anything i do wrong?

Difficulties having plugin load

I've had some strange behavior with the plugin, and I'm not sure why.

I've tried both vim 7.1 and 7.2, with the same result.

If I save the ftplugin directory in ~/.vim, sparkup does not load when vim starts. If I rename that directory to ~/.vim/plugin, it works just fine.

However, even if it is renamed to ~/.vim/plugin, sparkup will load when vim opens the first file, but if I open a file in another buffer (using :e, :vs, :sp, :tabf, etc), sparkup will not work in that buffer (only in the first one I opened).

Any idea what could be causing this?

Vim: do not add mappings for normal mode

I fail to see why there are default mappings for normal mode:
exec 'nmap ' . g:sparkupExecuteMapping . ' :call Sparkup()'
exec 'imap ' . g:sparkupNextMapping . ' u:call SparkupNext()'

Please consider removing them.

How do we use the "post-tag-guides"?

I was wanting to add the necessary comments to the end of those tags with IDs or Classes, but wasn't sure how to implement it.

Any help is greatly appreciated.

The Tab key is kept mapped to SparkupNext, even after all placeholder positions have been completed

The Tab key is overused by a few plugins I use to edit HTML (Supertab, Snipmate, ...). While I appreciate Sparkup to map the Tab key to cycle through all of the Sparkup placeholder positions, I would also appreciate if it put the original mapping of the Tab key back in place when the "filling" of the placeholders is completed. Instead, the Tab key is kept mapped to :call <SNR>68_SparkupNext() until eternity, effectively disabling my other plugins.

Can Sparkup "detect" that the last placeholder position is filled and then remap the Tab key to whatever mapping was active before Sparkup was triggered?

this project needs attention

cc @lucascaton @timheil @mikesmullin @srushti @MarcWeber @gwrtheyrn @juliangruber @chrisgeo @blueyed @wcmaier

just found this project, I wanted to install it and saw the inactivity on it, went to the network graph and saw a lot of forks doing custom changes and lot of pull requests to the original project (this one) but not being handled.

I understand that people move on to other things, but looking at the number of watchers, forks, issues and pull requests it makes sense to at least transfer the project to other people so they can keep moving it forward.

for this I don't want to make yet another fork and merge the issues, I was thinking on creating an organization and adding all the interested commiters to that organization, we can start merging the pull requests and closing tickets.

what do you think?

PS: I added in this issue all the people that have an open pull request, if you feel spamed you can unsubscribe from this issue (sorry!)

Nested {'s

Let's imagine for a moment you're using sparkup to write some html, but you're doing it for a templating language that uses something like ${variable} for variable replacements. Naturally enough, you try something along the lines of:

html>head>title{${title}}

But instead of getting the expected

<html>
  <head>
    <title>${title}</title>
  </head>
</html>

You get

<html>
  <head>
    <title>${title</title>
  </head>
</html>

Thusly missing the closing }. In short, please don't simply scan for the next } after a {, match the { to the correct }, or alternatively give us an escape character (forgive me if there is one already, couldn't find one).

Sparkup keeps using tab...

Every time I hit tab its calling sparkupNext()... ive tried remapping it to .. Do you have any ideas? Nowhere in my vimrc does it redefine anything that would cause that

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.