跳转到内容

帮助:文本编辑器支持

本页使用了标题或全文手工转换
维基百科,自由的百科全书

通常,使用成熟的文本编辑器编写维基条目,要比使用浏览器中的标凖文本编辑区编写方便得多。文本编辑器会提供许多非常有用的功能,例如拼写检查,查找替换,操作和语法高亮等,特别有助于编写条目,尤其是条目很长的时候。文本编辑器还可以快速、简单保存条目的本地版本,以方便将来的离线编辑。

本文包含一些用外部编辑器或浏览器内置编辑器来编写维基条目的指南。

怎样在文本编辑器打开条目

[编辑]

当然,你可以用手工的方法来使用外部的GUI文本编辑器:首先选择浏览器中文本编辑区的所有内容(比如使用Ctrl-A或⌘A),然后把内容复制并贴到一个外部编辑器当中,开始编辑,最后再把编辑好的内容重新复制并贴回浏览器的文本编辑区。

但某些软件可能会提供更有效的方法:

Mozilla和Mozilla Firefox

[编辑]

如果你使用MozillaMozilla Firefox浏览器,你可以使用以下方法来调用外部编辑器编辑网页中的文本框,这就不用在浏览器和编辑器之间复制、粘贴了。

当你完成编辑时,你需要在编辑器中保存,然后点击浏览器的文本框,文本框中的文字就会被更新成你在编辑器中编辑的结果。然后你就可以点击“预览”。如果你希望在预览之后继续编辑,点击浏览器中的“后退”,然后在你的编辑器中编辑。你也可以在开始编辑之前就预览,然后在编辑器中编辑,保存,预览,继续编辑,保存,预览,直到你满意,而不需要在这中间点击“后退”。

用It's All Text!来调用外部编辑器(如vim,gvim,notepad,wordpad等)

[编辑]

如果你在Windows或Linux使用Firefox2或3®,并且习惯 vim(或者几乎所有其他编辑器), It's All Text是你最好的选择,它易于安装和使用。你只需要点击一次鼠标来安装Firefox的这个附加组件,然后Firefox会提示你重启以激活这个附加组件。

然后,你需要为这个附加组件指定编辑器的路径。

There are two ways to bring up the Preferences window: (0)Switch to edit mode by clicking the Edit tab of a wiki page,or use the shortcut Shift+Alt+e,with the "accesskey" being Shift+Alt(in some other systems,the "accesskey" may be the Alt key; see Keyboard shortcuts for more details),then (1) Right click in the textarea; a dropdown menu will appear; move the cursor to It's All Text for another dropdown menu, and select Preferences at the bottom of this menu; or (2) Right click at the little button "Edit" at the lower-right corner of the textarea window. The path to your editor can be put in the Editor box of the Preferences window.

To invoke vim,you need to use the graphical version of vim called gvim, and thus put the path /usr/bin/gvim in the Editor box of the Preferences window. Putting /usr/bin/vim will not work; see below on how to get vim to work.

Once the above is done,to edit a wiki page,switch to Edit mode(as mentioned above)to bring up the textarea,and click at the little Edit button at the lower-right corner of the textarea.

To maximize the gvim window,press Alt+F5 in the xfce desktop environment.

After editing,you can save(write)the current file in gvim by pressing :w, then toggle back to the textarea of the wiki page(by pressing Alt+Tab if you use xfce or other desktop environments); you would see the textarea background turned yellow briefly, meaning that the textarea had been just modified and saved. Actually,each time you save the edited file,it takes about 1 or 2 seconds for the textarea to turn yellow briefly,indicating the saved version of the wiki article had been loaded into the textarea. You would see this color effect if your gvim widow did not occupy the whole monitor screen,and a portion of the text area could be seen beside the gvim window while editing.

All vim macros previously developed for use in editing latex files,html files,etc. worked.(See below in case you need to use vim instead of gvim.)

To preview what you have just edited,just toggle back to the wiki window(by pressing Alt+Tab if you use xfce), then type Shift+Alt+p. If you want to continue to see what you have just edited with gvim and included in the textarea,you can go back to the edit textarea by pressing Alt+LeftArrow to get your Firefox to display the previous page.

The location of the saved files edited with gvim are in the directory

  ~/.mozilla/firefox/default*/itsalltext/

with the filenames having the syntax:

  IP_address.random_code.txt

e.g.

  en.wikipedia.org.23311k351x.txt

The files in this directory will be removed. So if you want to preserve a text file for later editing,you may want to change the filename and move the file to another directory.

Another tip: While editing with It's All Text with gvim,if you were previewing the previous saved version of the text in Wikipedia,to preview a newer version,you want to first save this newer version in gvim. Then toggle back to the Wikipedia window,press Alt+RightArrow to go back to the edit textarea of the wiki article,wait for 1 or 2 seconds for the textarea to turn yellow briefly indicating that the newer version of the article had been loaded to the textarea. Next, press Shift+Alt+p to preview this newer version. To save the edited wiki page,you can use the shortcut Shift+Alt+s.

Getting vim to work with It's All Text: Some macro may work under vim,but not under gvim for some reasons (e.g.,the macro to format text paragraphs). Or you just want to use vim within an X terminal as you used to do, instead of using gvim. To invoke vim within an X terminal window, you can write a shell script(see below) to invoke an X terminal and to run the vim command within that X terminal, or generally your preferred editor. Assume that the filename of this script is wiki.edit.vim, and that you put the script in the directory /home_dir/bin/ so that the path of the script would be

  /home_dir/bin/wiki.edit.vim

Put the above path in the Preferences box(instead of /usr/bin/gvim)of It's All Text. It should work. Note that /home_dir/ is the complete path to your home directory from the root(/)directory; don't use ~/(tilde)instead of /home_dir/; it won't work.

The listing of the script wiki.edit.vim is given below:

#! /bin/sh
# $Id$
# vql, Thu, 27 Sep 2007, 17:56:09 EDT
#
# To pop up an X terminal (xterm) and run vim command within this
# terminal window.
# This script is intended to be invoked by the Firefox addon It's
# All Text for editing wiki pages
#
# The arguments for xterm are the same as those used to open up
# X terminals in laptop io2.  See ~/manuals/laptop.io2.fc3.html,
# Section on xfce.
# For gray background: (NOT NEEDED, since the X terminal would be
#   closed down after quitting the wiki file); the \ is for
#   continuation to the next line:
#
#   -bg gray \
#
# For font size:
#   -fn -misc-fixed-medium-r-normal--18-120-100-100-c-90-iso10646-1 \
#
# For the sidebar:
#   -sb
#
# For the size of the window (80 columns, 39 lines, right justified)
#   -geometry 80x39+800 \
#
# For executing vim on the file being the first argument of the script
#   -e /usr/bin/vim $argv[1]
#
# Exit codes:
# 0 = no problem
#
# Updated for generic Bourne shell by Eeera 2008-03-27

/usr/bin/xterm \
   -sb \
   -fn -misc-fixed-medium-r-normal--18-120-100-100-c-90-iso10646-1 \
   -geometry 80x39+800 \
   -e /usr/bin/vim "$1"

You can delete one or more xterm options used in the above script such as -sb,-fn,-geometry,etc.,if you don't need them. For example,the option -bg was already deleted, as explained in the comment block of the script. Enjoy editing wiki pages!

外部编辑器特性

[编辑]

从1.5版的MediaWiKi开始,可以使用任意外部工具来编辑维基资源。细节请参见Help:外部编辑器

文本浏览器

[编辑]
[编辑]

纯文本浏览器elinks也提供一种编辑文本区的功能。组合键Ctrl-T会调用一个外部编辑器(比如Vim),这便可以使用语法高亮、各种编辑功能、拼写检查并可以保存本地的备份。

w3m

[编辑]

w3m默认情况下就会使用外部编辑器来编辑文本区。

Lynx

[编辑]

Lynx使用外部编辑器编辑文本区的方法是:把光标放在文本区内,按组合键Ctrl-X + e。用户也可以自定快捷键。一些软件包打包者可能使用lynx本身的配置文件来自定义快捷键。

命令行工具

[编辑]

There are also command line tools that allow you to download articles,edit them using your favorite text editor,and upload the edited articles back into the Wikipedia(or into any MediaWiki server). This bypasses the need for a web browser. These are(at least):

  • mvs,a Perl program available from CPAN. There's more information at Meta:WWW::Mediawiki::Client. Unfortunately,mvs uses the name of the local file as the title of the page for the wiki remote server. If you need title pages in UTF-8 for Russian,Japanese or Arabic for example,you won't be able to upload such files. It seems that Mediawiki::Client as well as Perl libraries are not enough advanced in the management of UTF-8 characters to be fully operational,even if your terminal and shell are correctly set for UTF-8. But see Debian bug reports.
  • mwiki is a program to retrieve and upload articles from/to wikipedia servers. It is also capable of editing(sub)sections of articles. It stores the pagename(and other information)inside the file and seems to work well with UTF-8.
  • Meta:pywikipedia is an extensive library and set of utilities for doing innumerable things with wikipedia. It can also do something as simple as editing wikipedia pages. It has some ways to avoid the wrong transmission of titles in UTF-8,for example it allows to incorporate the name of the title within the file itself and to use another command line tool. The local filename could then be written in simple ASCII. Here is an example of a file,named locally 'foo.wiki',using pagefromfile.py(from Meta:pywikipedia):
{{-start-}}'''Демография'', или наука о народонаселении, изучает численность, состав, размещение и движение населения. 
{{-stop-}}

{{-start-}}'''人口学'''はヒトの人口の科学的研究をいい、主としてその大きさ、構造 2そしてその成長発展を研究対象とする。
{{-stop-}}

{{-start-}}'''Demography''' is the scientific study of human populations primarily with respect to their size, their structure and their development
{{-stop-}}

{{-start-}}'''الديمغرافية''': علم يتناول دراسة المجتمعات البشرية من حيث حجومها و بناها و تطورها و خصائصها العامة و لا سيما من النواحي الكمية.
{{-stop-}}

In the above example,the command line to upload the four pages in one submission(the 'start' and 'stop' markups drive successively the four different pages Демография,人口学,Demography and الديمغرافية)is:

  python pagefromfile.py -file:foo.wiki

Wikipediafs

[编辑]

使用POSIX兼容的操作系统(如Linux或Mac OS X)的用户也可以使用基于PythonFUSEWikipedia filesystem虚拟文件系统。它可以使用户在编辑任何基于Mediawiki的系统上的文章,就好像编辑本地文件一样。

如何设置特定的编辑器来编辑维基百科

[编辑]

GNU Emacs

[编辑]

There are a couple of Emacs major modes available for editing Wikipedia articles:

  • wikipedia-mode.el is a simple major mode that mostly provides syntax highlighting for wikipedia markup.
  • wikipedia.el is a much more advanced major mode which provides WYSIWYG editing of wikipedia articles. Note,however,that it is developed using the current CVS version of GNU Emacs,may not be compatible with older versions,and has been effectively discontinued because it's not being actively maintained. Also,the mode was in the alpha stage of development when it was orphaned,so use it at your own risk.

Since Wikipedia articles don't use line breaks,you may want to install screen-lines.el,which redefines movement commands to work in terms of screen lines as opposed to text lines,or install longlines.el,which implements "word wrap" functionality for Emacs(longlines.el is now part of GNU Emacs). Installation instructions are here.

Eclipse插件

[编辑]

Eclipse(跨平台)有一个专用于维基百科的插件。With an automatically updating outline of the article. It has many features which are very helpful for editing wikipedia. It also downloads articles directly from Wikipedia and has highlighting.

Vim

[编辑]

为使Vim(支持平台:Amiga,Linux,Mac OS X,Windows,OpenVMS,OS/2,Unix)支持维基上所使用的MediaWiKi标记语言,需要把以下代码保存到个人vim目录下的"syntax/MediaWiki.vim"文件中。默认情况下,在Unix系统中,此目录位于"~/.vim/syntax",在Windows系统中,此目录位于"C:\Program Files\Vim\vimfiles\syntax"。如果你的系统中还不存在此目录,新建一个即可(在Unix或Linux中命令是mkdir)。 (若只是需要语法高亮,参见It's All Text查看如何使用这firefox扩展设置vim/gvim来编辑维基页面。)

" Taken from
" http://en.wikipedia.org/wiki/Wikipedia:Text_editor_support#Vim

" Wikipedia syntax file for Vim
" Published on Wikipedia in 2003-04 and declared authorless.
" 
" Based on the HTML syntax file. Probably too closely based, in fact.
" There may well be name collisions everywhere, but ignorance is bliss,
" so they say.
"
" To do: plug-in support for downloading and uploading to the server.

if !exists("main_syntax")
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
let main_syntax = "html"
endif

syntax case ignore
if v:version >= 700
syntax spell toplevel
endif

" Mark illegal characters
sy match htmlError "[<>&]"

" Tags
sy region  htmlString   contained start=+"+                        end=+"+ contains=htmlSpecialChar,@htmlPreproc
sy region  htmlString   contained start=+'+                        end=+'+ contains=htmlSpecialChar,@htmlPreproc
sy match   htmlValue    contained "=[\t ]*[^'" \t>][^ \t>]*"hs=s+1         contains=@htmlPreproc
sy region  htmlEndTag             start=+</+                       end=+>+ contains=htmlTagN,htmlTagError
sy region  htmlTag                start=+<[^/]+                    end=+>+ contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,@htmlPreproc,@htmlArgCluster
sy match   htmlTagN     contained +<\s*[-a-zA-Z0-9]\++hs=s+1               contains=htmlTagName,htmlSpecialTagName,@htmlTagNameCluster
sy match   htmlTagN     contained +</\s*[-a-zA-Z0-9]\++hs=s+2              contains=htmlTagName,htmlSpecialTagName,@htmlTagNameCluster
sy match   htmlTagError contained "[^>]<"ms=s+1

" Allowed HTML tag names
sy keyword htmlTagName contained big blockquote br caption center cite code
sy keyword htmlTagName contained dd del div dl dt font hr ins li
sy keyword htmlTagName contained ol p pre rb rp rt ruby s small span strike sub
sy keyword htmlTagName contained sup table td th tr tt ul var
sy match   htmlTagName contained "\<\(b\|i\|u\|h[1-6]\|em\|strong\)\>"
" Allowed Wiki tag names
sy keyword htmlTagName contained math nowiki references source syntaxhighlight

" Allowed arg names
sy keyword htmlArg contained align lang dir width height nowrap bgcolor clear
sy keyword htmlArg contained noshade cite datetime size face color type start
sy keyword htmlArg contained value compact summary border frame rules
sy keyword htmlArg contained cellspacing cellpadding valign char charoff
sy keyword htmlArg contained colgroup col span abbr axis headers scope rowspan
sy keyword htmlArg contained colspan id class name style title

" Special characters
sy match htmlSpecialChar "&#\=[0-9A-Za-z]\{1,8};"

" Comments
sy region htmlComment                start=+<!+                end=+>+     contains=htmlCommentPart,htmlCommentError
sy match  htmlCommentError contained "[^><!]"
sy region htmlCommentPart  contained start=+--+                end=+--\s*+ contains=@htmlPreProc
sy region htmlComment                start=+<!DOCTYPE+ keepend end=+>+

if !exists("html_no_rendering")
sy cluster htmlTop contains=@Spell,htmlTag,htmlEndTag,htmlSpecialChar,htmlPreProc,htmlComment,htmlLink,@htmlPreproc

sy region htmlBold                          start="<b\>"      end="</b>"me=e-4      contains=@htmlTop,htmlBoldUnderline,htmlBoldItalic
sy region htmlBold                          start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop,htmlBoldUnderline,htmlBoldItalic
sy region htmlBoldUnderline       contained start="<u\>"      end="</u>"me=e-4      contains=@htmlTop,htmlBoldUnderlineItalic
sy region htmlBoldItalic          contained start="<i\>"      end="</i>"me=e-4      contains=@htmlTop,htmlBoldItalicUnderline
sy region htmlBoldItalic          contained start="<em\>"     end="</em>"me=e-5     contains=@htmlTop,htmlBoldItalicUnderline
sy region htmlBoldUnderlineItalic contained start="<i\>"      end="</i>"me=e-4      contains=@htmlTop
sy region htmlBoldUnderlineItalic contained start="<em\>"     end="</em>"me=e-5     contains=@htmlTop
sy region htmlBoldItalicUnderline contained start="<u\>"      end="</u>"me=e-4      contains=@htmlTop,htmlBoldUnderlineItalic

sy region htmlUnderline                     start="<u\>"      end="</u>"me=e-4      contains=@htmlTop,htmlUnderlineBold,htmlUnderlineItalic
sy region htmlUnderlineBold       contained start="<b\>"      end="</b>"me=e-4      contains=@htmlTop,htmlUnderlineBoldItalic
sy region htmlUnderlineBold       contained start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop,htmlUnderlineBoldItalic
sy region htmlUnderlineItalic     contained start="<i\>"      end="</i>"me=e-4      contains=@htmlTop,htmlUnderlineItalicBold
sy region htmlUnderlineItalic     contained start="<em\>"     end="</em>"me=e-5     contains=@htmlTop,htmlUnderlineItalicBold
sy region htmlUnderlineItalicBold contained start="<b\>"      end="</b>"me=e-4      contains=@htmlTop
sy region htmlUnderlineItalicBold contained start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop
sy region htmlUnderlineBoldItalic contained start="<i\>"      end="</i>"me=e-4      contains=@htmlTop
sy region htmlUnderlineBoldItalic contained start="<em\>"     end="</em>"me=e-5     contains=@htmlTop

sy region htmlItalic                        start="<i\>"      end="</i>"me=e-4      contains=@htmlTop,htmlItalicBold,htmlItalicUnderline
sy region htmlItalic                        start="<em\>"     end="</em>"me=e-5     contains=@htmlTop
sy region htmlItalicBold          contained start="<b\>"      end="</b>"me=e-4      contains=@htmlTop,htmlItalicBoldUnderline
sy region htmlItalicBold          contained start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop,htmlItalicBoldUnderline
sy region htmlItalicBoldUnderline contained start="<u\>"      end="</u>"me=e-4      contains=@htmlTop
sy region htmlItalicUnderline     contained start="<u\>"      end="</u>"me=e-4      contains=@htmlTop,htmlItalicUnderlineBold
sy region htmlItalicUnderlineBold contained start="<b\>"      end="</b>"me=e-4      contains=@htmlTop
sy region htmlItalicUnderlineBold contained start="<strong\>" end="</strong>"me=e-9 contains=@htmlTop

sy region htmlH1    start="<h1\>"    end="</h1>"me=e-5    contains=@htmlTop
sy region htmlH2    start="<h2\>"    end="</h2>"me=e-5    contains=@htmlTop
sy region htmlH3    start="<h3\>"    end="</h3>"me=e-5    contains=@htmlTop
sy region htmlH4    start="<h4\>"    end="</h4>"me=e-5    contains=@htmlTop
sy region htmlH5    start="<h5\>"    end="</h5>"me=e-5    contains=@htmlTop
sy region htmlH6    start="<h6\>"    end="</h6>"me=e-5    contains=@htmlTop
endif


" No htmlTop and wikiPre inside HTML preformatted areas, because
" Wikipedia renders everything in there literally (HTML tags and
" entities, too): <pre> tags work as the combination of <nowiki> and
" the standard HTML <pre> tag: the content will preformatted, and it
" will not be parsed, but shown as in the wikitext source.
"
" With wikiPre, indented lines would be rendered differently from
" unindented lines.
sy match htmlPreTag       /<pre>/         contains=htmlTag
sy match htmlPreEndTag    /<\/pre>/       contains=htmlEndTag
sy match wikiNowikiTag    /<nowiki>/      contains=htmlTag
sy match wikiNowikiEndTag /<\/nowiki>/    contains=htmlEndTag
sy match wikiSourceTag    /<source\s\+[^>]\+>/ contains=htmlTag
sy match wikiSourceEndTag /<\/source>/    contains=htmlEndTag
sy match wikiSyntaxHLTag    /<syntaxhighlight\s\+[^>]\+>/ contains=htmlTag
sy match wikiSyntaxHLEndTag /<\/syntaxhighlight>/    contains=htmlEndTag

" Note: Cannot use 'start="<pre>"rs=e', so still have the <pre> tag
" highlighted correctly via separate sy-match. Unfortunately, this will
" also highlight <pre> tags inside the preformatted region. 
sy region htmlPre    start="<pre>"                 end="<\/pre>"me=e-6    contains=htmlPreTag
sy region wikiNowiki start="<nowiki>"              end="<\/nowiki>"me=e-9 contains=wikiNowikiTag
sy region wikiSource start="<source\s\+[^>]\+>"         keepend end="<\/source>"me=e-9 contains=wikiSourceTag
sy region wikiSyntaxHL start="<syntaxhighlight\s\+[^>]\+>" keepend end="<\/syntaxhighlight>"me=e-18 contains=wikiSyntaxHLTag

sy include @TeX syntax/tex.vim
sy region wikiTeX matchgroup=htmlTag start="<math>" end="<\/math>"  contains=@texMathZoneGroup,wikiNowiki,wikiNowikiEndTag
sy region wikiRef matchgroup=htmlTag start="<ref>"  end="<\/ref>"   contains=wikiNowiki,wikiNowikiEndTag

sy cluster wikiTop contains=@Spell,wikiLink,wikiNowiki,wikiNowikiEndTag

sy region wikiItalic        start=+'\@<!'''\@!+ end=+''+    oneline contains=@wikiTop,wikiItalicBold
sy region wikiBold          start=+'''+         end=+'''+   oneline contains=@wikiTop,wikiBoldItalic
sy region wikiBoldAndItalic start=+'''''+       end=+'''''+ oneline contains=@wikiTop

sy region wikiBoldItalic contained start=+'\@<!'''\@!+ end=+''+  oneline contains=@wikiTop
sy region wikiItalicBold contained start=+'''+         end=+'''+ oneline contains=@wikiTop

sy region wikiH1 start="^="      end="="      oneline contains=@wikiTop
sy region wikiH2 start="^=="     end="=="     oneline contains=@wikiTop
sy region wikiH3 start="^==="    end="==="    oneline contains=@wikiTop
sy region wikiH4 start="^===="   end="===="   oneline contains=@wikiTop
sy region wikiH5 start="^====="  end="====="  oneline contains=@wikiTop
sy region wikiH6 start="^======" end="======" oneline contains=@wikiTop

sy region wikiLink start="\[\[" end="\]\]\(s\|'s\|es\|ing\|\)" oneline contains=wikiLink,wikiNowiki,wikiNowikiEndTag

sy region wikiLink start="\[http:"   end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
sy region wikiLink start="\[https:"  end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
sy region wikiLink start="\[ftp:"    end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
sy region wikiLink start="\[gopher:" end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
sy region wikiLink start="\[news:"   end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag
sy region wikiLink start="\[mailto:" end="\]" oneline contains=wikiNowiki,wikiNowikiEndTag

sy region wikiTemplate start="{{" end="}}" contains=wikiNowiki,wikiNowikiEndTag

sy match wikiParaFormatChar /^[\:|\*|;|#]\+/
sy match wikiParaFormatChar /^-----*/
sy match wikiPre            /^\ .*$/         contains=wikiNowiki,wikiNowikiEndTag


" HTML highlighting

if version < 508
command! -nargs=+ HtmlHiLink hi link     <args>
else
command! -nargs=+ HtmlHiLink hi def link <args>
endif

if version >= 508 || !exists("did_html_syn_inits")
HtmlHiLink htmlTag            Function
HtmlHiLink htmlEndTag         Identifier
HtmlHiLink htmlArg            Type
HtmlHiLink htmlTagName        htmlStatement
HtmlHiLink htmlSpecialTagName Exception
HtmlHiLink htmlValue          String
HtmlHiLink htmlSpecialChar    Special

if !exists("html_no_rendering")
HtmlHiLink htmlTitle Title
HtmlHiLink htmlH1    htmlTitle
HtmlHiLink htmlH2    htmlTitle
HtmlHiLink htmlH3    htmlTitle
HtmlHiLink htmlH4    htmlTitle
HtmlHiLink htmlH5    htmlTitle
HtmlHiLink htmlH6    htmlTitle

HtmlHiLink htmlPreProc          PreProc
HtmlHiLink htmlHead             htmlPreProc
HtmlHiLink htmlPreProcAttrName  htmlPreProc
HtmlHiLink htmlPreStmt          htmlPreProc

HtmlHiLink htmlSpecial          Special
HtmlHiLink htmlCssDefinition    htmlSpecial
HtmlHiLink htmlEvent            htmlSpecial
HtmlHiLink htmlSpecialChar      htmlSpecial

HtmlHiLink htmlComment          Comment
HtmlHiLink htmlCommentPart      htmlComment
HtmlHiLink htmlCssStyleComment  htmlComment

HtmlHiLink htmlString           String
HtmlHiLink htmlPreAttr          htmlString
HtmlHiLink htmlValue            htmlString

HtmlHiLink htmlError            Error
HtmlHiLink htmlBadArg           htmlError
HtmlHiLink htmlBadTag           htmlError
HtmlHiLink htmlCommentError     htmlError
HtmlHiLink htmlPreError         htmlError  
HtmlHiLink htmlPreProcAttrError htmlError
HtmlHiLink htmlTagError         htmlError

HtmlHiLink htmlStatement        Statement

HtmlHiLink htmlConstant         Constant

HtmlHiLink htmlBoldItalicUnderline htmlBoldUnderlineItalic
HtmlHiLink htmlUnderlineItalicBold htmlBoldUnderlineItalic
HtmlHiLink htmlUnderlineBoldItalic htmlBoldUnderlineItalic
HtmlHiLink htmlItalicBoldUnderline htmlBoldUnderlineItalic
HtmlHiLink htmlItalicUnderlineBold htmlBoldUnderlineItalic

HtmlHiLink htmlItalicBold          htmlBoldItalic
HtmlHiLink htmlItalicUnderline     htmlUnderlineItalic
HtmlHiLink htmlUnderlineBold       htmlBoldUnderline

HtmlHiLink htmlLink Underlined

if !exists("html_my_rendering")
hi def htmlBold                term=bold                  cterm=bold                  gui=bold
hi def htmlBoldUnderline       term=bold,underline        cterm=bold,underline        gui=bold,underline
hi def htmlBoldItalic          term=bold,italic           cterm=bold,italic           gui=bold,italic
hi def htmlBoldUnderlineItalic term=bold,italic,underline cterm=bold,italic,underline gui=bold,italic,underline
hi def htmlUnderline           term=underline             cterm=underline             gui=underline
hi def htmlUnderlineItalic     term=italic,underline      cterm=italic,underline      gui=italic,underline
hi def htmlItalic              term=italic                cterm=italic                gui=italic
endif

endif " !exists("html_no_rendering")

if version < 508
let did_html_syn_inits = 1
endif

endif " version >= 508 || !exists("did_html_syn_inits")

" Wiki highlighting

HtmlHiLink wikiItalic        htmlItalic
HtmlHiLink wikiBold          htmlBold
HtmlHiLink wikiBoldItalic    htmlBoldItalic
HtmlHiLink wikiItalicBold    htmlBoldItalic
HtmlHiLink wikiBoldAndItalic htmlBoldItalic

HtmlHiLink wikiH1 htmlTitle
HtmlHiLink wikiH2 htmlTitle
HtmlHiLink wikiH3 htmlTitle
HtmlHiLink wikiH4 htmlTitle
HtmlHiLink wikiH5 htmlTitle
HtmlHiLink wikiH6 htmlTitle

HtmlHiLink wikiLink           htmlLink
HtmlHiLink wikiTemplate       htmlSpecial
HtmlHiLink wikiParaFormatChar htmlSpecial
HtmlHiLink wikiPre            htmlConstant
HtmlHiLink wikiRef            htmlComment

HtmlHiLink wikiSource         wikiPre
HtmlHiLink wikiSyntaxHL       wikiPre


let b:current_syntax = "html"

delcommand HtmlHiLink

if main_syntax == "html"
unlet main_syntax
endif

" vim: set et sts=2 sw=2:


要自动检测以".wiki"结尾的文件,在".vim/ftdetect/MediaWiki.vim"或"vimfiles/ftdetect/MediaWiki.vim"中加入下面字段(如果此文件不存在,新建一个):

autocmd BufRead,BufNewFile *.wiki		setfiletype MediaWiki
autocmd BufRead,BufNewFile *.wikipedia.org*	setfiletype MediaWiki

或者,使用":setf Wikipedia"命令,可以临时地为当前文件设置语法类型。

前面提到的Firefox扩展Mozex会使用".txt"扩展名创建临时文件,而不是使用".wiki"作为扩展名,所以上面的自动检测文件类型的方法不能支持此插件。一种解决办法是让Mozex调用vim时加上下面的参数:

-c "setf MediaWiki"

维基百科条目通常在每段结尾只使用断行符,而vim在默认设置下不能完美地处理这种情况。把下面的字段加到"~/.vim/ftplugin/MediaWiki.vim"或"vimfiles\ftplugin\MediaWiki.vim"中会使情况变得好些(别忘了在vimrc中加上"filetype plugin on")。


" Wikipedia prefers line breaks only at the end of paragraphs (like in a text
" processor), which results in long, wrapping lines. 
setlocal wrap linebreak
setlocal textwidth=0

" No auto-wrap at all.
setlocal formatoptions-=tc formatoptions+=l
if v:version >= 602 | setlocal formatoptions-=a | endif

" Make navigation more amenable to the long wrapping lines. 
noremap <buffer> k gk
noremap <buffer> j gj
noremap <buffer> <Up> gk
noremap <buffer> <Down> gj
noremap <buffer> 0 g0
noremap <buffer> ^ g^
noremap <buffer> $ g$
noremap <buffer> D dg$ 
noremap <buffer> C cg$ 
noremap <buffer> A g$a

inoremap <buffer> <Up> <C-O>gk
inoremap <buffer> <Down> <C-O>gj


上面的vim脚本也放在vim.org脚本集合上,也会不时地与这里的最新的版本进行更新。请提醒mvc定期上传最新的版本。

jEdit

[编辑]

For jEdit(Java-supporting OSes)there is a plugin available at http://www.djini.de/software/mwjed/ . Apart from providing syntax highlighting for wikipedia markup,it can communicate directly with the Wikipedia website using the HttpClient component from the Jakarta Project.

Kate/KWrite

[编辑]

关于Kate(GNU/Linux的KDE环境),在维基共享资源有一个XML格式的语法高亮规则。这个规则可以识别出HTML标签和实体、维基语法、模板、变量、关键词、链接、章节标题、表格及<nowiki>部分。

安装这个模板的方法是,将下载的模板复制到你的KDE主目录~/.kde/share/apps/katepart/syntax/实现单用户的设置,或进行全局设置:

  • 大部分情况下,复制到$(PREFIX)/share/apps/katepart/syntax/即可。
  • Ubuntu Linux中,要复制到/usr/share/kde4/apps/katepart/syntax/
  • OpenSUSE-Linux中,要设置PREFIX=/opt/kde3/

另外还有一个导入工具:设置 → 配置Kate → 高亮语法 → 下载

SubEthaEdit

[编辑]

A syntax highlighting mode is available for SubEthaEdit(Mac OS X)as well. After downloading the mode bundle,drop it in /Library/Application Support/SubEthaEdit/Modes/(system-wide)or ~/Library/Application Support/SubEthaEdit/Modes/(user-specific). You may need to create the final two directories by hand. The mode will be automatically selected for files with a .wiki or .wikipedia extension.

TextMate

[编辑]

A "MediaWiki" bundle is available in the TextMate(cross-platform)bundle subversion repository. To learn how to load this bundle,see the TextMate manual page about installing more bundles. The bundle for now(8 August 2006)only does syntax highlighting,but the ability to fetch and post articles is coming soon.

NoteTab

[编辑]

A Clip Library plugin for the NoteTab(Windows)text editor contains some functions to automate Wiki markup.

Notepad++

[编辑]

Notepad++是免费的纯文字原码编辑器,在Windows执行。其可用来自制语法高亮方案,如用mediawiki markup scheme自定新方案,或安装维基百科用户MjolnirPants提供的现有版本;Github都有适用的语法高亮方案:MediaWiki_userDefineLang__Obsidian_Theme_.xmlMediawikiMarkup_Improved_bySaurabhPatil.xmlMediawiki_SL.xml

Notepad++支持扩件;32位版有适用的2009 mediaWiki扩件,可在http://www.cab.i24.cc/projects/wikieditor/下载。

浏览器内的编辑器

[编辑]

wikEd

[编辑]

wikEd是功能强大的浏览器内文本编辑器,增强了大量维基的页面编辑过程中的文本处理功能(目前只适用于Firefox 1.5以上、Mozilla 1.3以上、SeaMonkeyWebKitGoogle ChromeSafari)。

Features include:

  • Powerful search and replace(including Regular expressions)
  • Wikicode syntax highlighting
  • Fullscreen editing mode
  • Edit preview and show changes on the same page without reloading
  • MS-Word and web page import(including tables)
  • Single-click fixing of common mistakes

wikEd can either be installed by pasting a small code snippet to your monobook.js page or locally as a Greasemonkey user script. For detailed installation instructions see the wikEd homepage.

处理特定字符

[编辑]

The English Wikipedia(and most others)are now encoded using the UTF-8 character set,which allows the use of many foreign language characters and special symbols. Such characters may appear even in articles where you wouldn't expect them due to the use of interwiki links to foreign-language versions of the article. Therefore,it's very important to use an editor that does not mangle these characters or replace them with question marks. Check your editor's documentation to make sure that it supports Unicode or UTF-8,and enable it if needed. You don't necessarily need a special editor; recent versions of Notepad and Microsoft Word support Unicode,for example. An extensive list of Unicode-supporting editors is available for Windows and other operating systems(see also:Comparison_of_text_editors).

If your editor does not support UTF-8,then copy-paste from web browser may mangle the characters. For example pasting from Windows Clipboard automatically converts characters to whatever character set is used in your editor and any characters not included in this character set are replaced with question marks. You can avoid this by using one of the helper applications or browser plugins mentioned above. For example It's All Text! does not mangle any characters.

When making an edit to an article with special characters using a new editor,it's a good idea to use the "Show changes" button(next to "Show preview")to see exactly what changes your edit will make - if areas with special characters that you didn't intend to modify are highlighted as red,that means they will be corrupted,even though both versions may look the same to you because you don't have foreign fonts installed.

BabelPad is a free editor for Windows with special support for dealing with Unicode,and is ideal if you need to determine which of several similar-looking characters an article is using,or deal with hard-to-edit Unicode control codes(like for multidirectional text).

参见

[编辑]