11*publish.txt* Publish hyperlinked, syntax highlighted source code with Vim
22
33===============================================================================
4- *publish-contents*
54Contents ~
65
7- 1. Introduction | publish-introduction |
8- 2. Installation & usage | publish-installation-usage |
9- 3. Publishing to a remote location (website)
10- 4. Contact | publish-contact |
11- 5. License | publish-license |
6+ 1. Introduction | publish-introduction |
7+ 2. Installation & usage | publish-installation-usage |
8+ 3. Publishing to a remote location (website) | publishing-to-remote-location |
9+ 4. Contact | publish-contact |
10+ 5. License | publish-license |
11+ 6. References | publish-references |
1212
1313===============================================================================
14- *publish-introduction*
14+ *publish-introduction*
1515Introduction ~
1616
17- The Vim text editor includes the script | 2html.vim | which can be used to convert
18- a syntax highlighted buffer in Vim to an HTML document that, when viewed in a
19- web browser, should look exactly the same. After using that script for a while
20- and discovering the excellent Exuberant Ctags [1] I wondered "Wouldn't it be
21- nice to have those tags converted to hyperlinks when I publish source code as
22- HTML?".
17+ The Vim text editor includes the script | 2html.vim | which can be used to
18+ convert a syntax highlighted buffer in Vim to an HTML document that, when
19+ viewed in a web browser, should look exactly the same. After using that script
20+ for a while and discovering the excellent Exuberant Ctags [1] I wondered
21+ _"Wouldn't it be nice to have those tags converted to hyperlinks when I publish
22+ source code as HTML?"_ .
2323
2424After several attempts I managed a working prototype, but it was quite rough
2525around the edges and I didn't really have the time or interest to clean it up.
@@ -29,91 +29,105 @@ wondering what the result looks like, I've published the plug-in source code
2929[2] as a demonstration.
3030
3131===============================================================================
32- *publish-installation-usage*
32+ *publish-installation-usage*
3333Installation & usage ~
3434
35- Unzip the most recent ZIP archive [3] file inside your Vim profile directory
36- (usually this is '~/.vim' on UNIX and '%USERPROFILE%\vimfiles' on Windows),
37- restart Vim and execute the command ':helptags ~/.vim/doc' (use ':helptags
38- ~\vimfiles\doc' instead on Windows). As an example we'll publish the plug-in
39- using itself. First create a tags file that contains entries for the files you
40- want to publish using a shell command such as:
41- >
42- $ ctags -Rf ~/.publish_tags ~/.vim/
35+ _Please note that the vim-publish plug-in requires my vim-misc plug-in which is
36+ separately distributed._
37+
38+ Unzip the most recent ZIP archives of the vim-publish [3] and vim-misc [4]
39+ plug-ins inside your Vim profile directory (usually this is '~/.vim' on UNIX
40+ and '%USERPROFILE%\vimfiles' on Windows), restart Vim and execute the command
41+ ':helptags ~/.vim/doc' (use ':helptags ~\vimfiles\doc' instead on Windows). If
42+ you prefer you can also use Pathogen [5], Vundle [6] or a similar tool to
43+ install & update the vim-publish [7] and vim-misc [8] plug-ins using a local
44+ clone of the git repository.
4345
46+ As an example we'll publish the plug-in using itself. First create a tags file
47+ that contains entries for the files you want to publish using a shell command
48+ such as:
49+ >
50+ $ ctags -Rf ~/.publish_tags ~/.vim/
51+ <
4452If this doesn't work because | ctags | isn't installed you can download it from
4553the Exuberant Ctags homepage [1], or if you're running Debian/Ubuntu you can
4654install it by executing the following shell command:
4755>
48- $ sudo apt-get install exuberant-ctags
49-
56+ $ sudo apt-get install exuberant-ctags
57+ <
5058The plug-in needs an up-to-date tags file so that it can create hyperlinks
5159between the published files. Now start Vim and write a script that registers
5260the tags file you just created and calls the function 'Publish()' as follows:
5361>
54- :set tags=~/.publish_tags
55- :let sources = '/home/peter/.vim'
56- :let target = 'sftp://peterodding.com/code/vim/profile'
57- :call Publish(sources, target, [
58- \ 'autoload/xolox/escape.vim',
59- \ 'autoload/xolox/path.vim',
60- \ 'autoload/publish.vim',
61- \ 'plugin/publish.vim',
62- \ ])
63-
64- Change the 'sources' and 'target' variables to reflect your situation, save
65- the script as '~/publish_test.vim' and try it in Vim by executing the command
62+ :set tags=~/.publish_tags
63+ :let sources = '/home/peter/.vim'
64+ :let target = 'sftp://peterodding.com/code/vim/profile'
65+ :call Publish(sources, target, [
66+ \ 'autoload/xolox/escape.vim',
67+ \ 'autoload/xolox/path.vim',
68+ \ 'autoload/publish.vim',
69+ \ 'plugin/publish.vim',
70+ \ ])
71+ <
72+ Change the 'sources' and 'target' variables to reflect your situation, save the
73+ script as '~/publish_test.vim' and try it in Vim by executing the command
6674':source ~/publish_test.vim'. If everything goes well Vim will be busy for a
6775moment and after that you will find a bunch of syntax highlighted, interlinked
6876HTML documents in the 'target' directory!
6977
7078===============================================================================
79+ *publishing-to-remote-location*
7180Publishing to a remote location (website) ~
7281
7382As you can see from the example above it's possible to publish files directly
7483to your web server using the | netrw | plug-in that's bundled with Vim, simply by
75- starting the 'target' path with 'sftp://'. All you need for this to work is
76- the ability to establish SCP [4 ] connections to your server. There are however
77- two disadvantages to remote publishing over SFTP [5 ]:
84+ starting the 'target' path with 'sftp://'. All you need for this to work is the
85+ ability to establish SCP [9 ] connections to your server. There are however two
86+ disadvantages to remote publishing over SFTP [10 ] :
7887
79- - The 'publish.vim' plug-in can't automatically create directories on the
88+ 1. The 'publish.vim' plug-in can't automatically create directories on the
8089 remote side, which means you'll have to do so by hand -- very bothersome.
8190
82- - It can take a while to publish a dozen files because a new connection is
91+ 2. It can take a while to publish a dozen files because a new connection is
8392 established for every file that's uploaded to the remote location.
8493
8594As a workaround to both of these issues the 'publish.vim' plug-in will
86- automatically use rsync [6 ] when both the local and remote system have it
95+ automatically use rsync [11 ] when both the local and remote system have it
8796installed. This cuts the time to publish to a remote location in half and
8897enables the plug-in to automatically create directories on the remote side.
8998
9099===============================================================================
91- *publish-contact*
100+ *publish-contact*
92101Contact ~
93102
94103If you have questions, bug reports, suggestions, etc. the author can be
95104contacted at peter@peterodding.com. The latest version is available at
96- http://peterodding.com/code/vim/publish/ and http://github.com/xolox/vim-publish .
97- If you like the script please vote for it on Vim Online [7 ].
105+ http://peterodding.com/code/vim/publish/ and http://github.com/xolox/vim -
106+ publish. If you like the script please vote for it on Vim Online [12 ] .
98107
99108===============================================================================
100- *publish-license*
109+ *publish-license*
101110License ~
102111
103- This software is licensed under the MIT license [8 ]. Š 2013 Peter Odding
112+ This software is licensed under the MIT license [13 ] . Š 2013 Peter Odding
104113<peter@peterodding.com>.
105114
106115===============================================================================
107- *publish-references*
116+ *publish-references*
108117References ~
109118
110119[1] http://ctags.sourceforge.net/
111120[2] http://peterodding.com/code/vim/profile/plugin/publish.vim
112121[3] http://peterodding.com/code/vim/downloads/publish.zip
113- [4] http://en.wikipedia.org/wiki/Secure_copy
114- [5] http://en.wikipedia.org/wiki/SSH_file_transfer_protocol
115- [6] http://en.wikipedia.org/wiki/rsync
116- [7] http://www.vim.org/scripts/script.php?script_id=2252
117- [8] http://en.wikipedia.org/wiki/MIT_License
122+ [4] http://peterodding.com/code/vim/downloads/misc.zip
123+ [5] http://www.vim.org/scripts/script.php?script_id=2332
124+ [6] https://github.com/gmarik/vundle
125+ [7] https://github.com/xolox/vim-publish
126+ [8] https://github.com/xolox/vim-misc
127+ [9] http://en.wikipedia.org/wiki/Secure_copy
128+ [10] http://en.wikipedia.org/wiki/SSH_file_transfer_protocol
129+ [11] http://en.wikipedia.org/wiki/rsync
130+ [12] http://www.vim.org/scripts/script.php?script_id=2252
131+ [13] http://en.wikipedia.org/wiki/MIT_License
118132
119133vim: ft=help
0 commit comments