Help:文本编辑器支持
此幫助頁目前正依照其他维基百科上的内容进行翻译。 (2019年11月2日) |
通常,使用成熟的文本編輯器編寫維基條目,要比使用瀏覽器中的標凖文本編輯區編寫方便得多。文本編輯器會提供許多非常有用的功能,例如拼寫檢查,查找替換,宏操作和語法高亮等,特別有助於編寫條目,尤其是條目很長的時候。文本編輯器還可以快速、簡單保存條目的本地版本,以方便將來的離線編輯。
本文包含一些用外部編輯器或瀏覽器內建編輯器來編寫維基條目的指南。
怎样在文本编辑器打开条目
[编辑]當然,你可以用手工的方法來使用外部的GUI文本編輯器:首先選擇瀏覽器中文本編輯區的所有內容(比如使用Ctrl-A或⌘A),然後把內容複製並貼到一個外部編輯器當中,開始編輯,最後再把編輯好的內容重新複製並貼回瀏覽器的文本編輯區。
但某些軟件可能會提供更有效的方法:
Mozilla和Mozilla Firefox
[编辑]如果你使用Mozilla或Mozilla Firefox浏览器,你可以使用以下方法来调用外部编辑器编辑网页中的文本框,这就不用在浏览器和编辑器之间复制、粘贴了。
- MozEx. 官方安装包不支持编辑UTF-8编码且不能正常地安装在Mozilla Firefox。但是,修改版没有这问题。参见MozEx的快速教程。
- ViewSourceWith 提供了类似的文字编辑功能。
- Editus Externus. Similar to the others,but the editor blocks the browser,so it is not possible to check other articles while writing.
- TextArea Sputnik,supports nonblocking editing and different encodings in an external editor.(You may see question marks in an edit textbox unrelated to the edits you are making(for example,the Unicode grapheme and other glyphs at the bottom),but your edits won't destroy the characters.)
- It's All Text!,supports nonblocking editing and utf-8 encoding.
当你完成编辑时,你需要在编辑器中保存,然后点击浏览器的文本框,文本框中的文字就会被更新成你在编辑器中编辑的结果。然后你就可以点击“预览”。如果你希望在预览之后继续编辑,点击浏览器中的“后退”,然后在你的编辑器中编辑。你也可以在开始编辑之前就预览,然后在编辑器中编辑,保存,预览,继续编辑,保存,预览,直到你满意,而不需要在这中间点击“后退”。
用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
[编辑]純文本瀏覽器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)的用戶也可以使用基于Python和FUSE的Wikipedia filesystem虛擬文件系統。它可以使用戶在編輯任何基于Mediawiki的系統上的文章,就好像編輯本地文件一樣。
如何设置特定的编辑器来编辑维基百科
[编辑]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_.xml、MediawikiMarkup_Improved_bySaurabhPatil.xml、Mediawiki_SL.xml。
Notepad++支持擴件;32位元版有適用的2009 mediaWiki擴件,可在http://www.cab.i24.cc/projects/wikieditor/下载。
浏览器内的编辑器
[编辑]wikEd
[编辑]wikEd是功能强大的浏览器内文本编辑器,增强了大量维基的页面编辑过程中的文本处理功能(目前只适用于Firefox 1.5以上、Mozilla 1.3以上、SeaMonkey、WebKit、Google Chrome或Safari)。
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).