分享
 
 
 

错怪了vim的tohtml插件

王朝html/css/js·作者佚名  2008-05-21
窄屏简体版  字體: |||超大  

vim 生成的 HTML 代码很 Ugly,的确错怪它了,不是它不行,只是我不会使用,它可以生成很漂亮的代码,支持CSS和xhtml,感谢 rogerz 的帮助。

原来是由两个参数需要设置,一个 html_use_css,一个是 use_xhtml,更详细的帮助信息请查看 vim 的在线帮组。也贴一份到下面了:-)

看来用 vim 还是不错的选择,source2xhtml 暂时不用继续开发了:) 不同通过它,我的Python又长进不少,基本上掌握正则表达式了

E:\Program Files\Vim\vim63\doc\syntax.txt.html

2HTML *2html.vim* *convert-to-HTML*

This is not a syntax file itself, but a script that converts the current

window into HTML. Vim opens a new window in which it builds the HTML file.

You are not supposed to set the 'filetype' or 'syntax' option to "2html"!

Source the script to convert the current file: >

:runtime! syntax/2html.vim

<

Warning: This is slow!

*:TOhtml*

Or use the ":TOhtml" user command. It is defined in a standard plugin.

":TOhtml" also works with a range and in a Visual area: >

:10,40TOhtml

After you save the resulting file, you can view it with any HTML viewer, such

as Netscape. The colors should be exactly the same as you see them in Vim.

To restrict the conversion to a range of lines set "html_start_line" and

"html_end_line" to the first and last line to be converted. Example, using

the last set Visual area: >

:let html_start_line = line("'<")

:let html_end_line = line("'>")

The lines are numbered according to 'number' option and the Number

highlighting. You can force lines to be numbered in the HTML output by

setting "html_number_lines" to non-zero value: >

:let html_number_lines = 1

Force to omit the line numbers by using a zero value: >

:let html_number_lines = 0

Go back to the default to use 'number' by deleting the variable: >

:unlet html_number_lines

By default, HTML optimized for old browsers is generated. If you prefer using

cascading style sheets (CSS1) for the attributes (resulting in considerably

shorter and valid HTML 4 file), use: >

:let html_use_css = 1

By default "<pre>" and "</pre>" is used around the text. This makes it show

up as you see it in Vim, but without wrapping. If you prefer wrapping, at the

risc of making some things look a bit different, use: >

:let html_no_pre = 1

This will use <br> at the end of each line and use "&nbsp;" for repeated

spaces.

The current value of 'encoding' is used to specify the charset of the HTML

file. This only works for those values of 'encoding' that have an equivalent

HTML charset name. To overrule this set g:html_use_encoding to the name of

the charset to be used: >

:let html_use_encoding = "foobar"

To omit the line that specifies the charset, set g:html_use_encoding to an

empty string: >

:let html_use_encoding = ""

To go back to the automatic mechanism, delete the g:html_use_encoding

variable: >

:unlet html_use_encoding

<

*convert-to-XML* *convert-to-XHTML*

An alternative is to have the script generate XHTML (XML compliant HTML). To

do this set the "use_xhtml" variable: >

:let use_xhtml = 1

To disable it again delete the variable: >

:unlet use_xhtml

The generated XHTML file can be used in DocBook XML documents. See:

http://people.mech.kuleuven.ac.be/~pissaris/howto/src2db.html

Remarks:

- This only works in a version with GUI support. If the GUI is not actually

running (possible for X11) it still works, but not very well (the colors

may be wrong).

- Older browsers will not show the background colors.

- From most browsers you can also print the file (in color)!

Here is an example how to run the script over all .c and .h files from a Unix shell: >

for f in *.[ch]; do gvim -f +"syn on" +"run! syntax/2html.vim" +"wq" +"q" $f; done

如果要用非交互模式把代码文本转化成html呢,如果在vi里面的话必须手动输入TOhtml,不容易实现自动化。我们可以在启动vim的时候可以加参数 -c 来执行一些命令,用如下的命令就可以将一个文件转化为语法加亮后的html文件:

vim -c ":TOhtml" -c ":wq %" -c ":q" filename

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有