summaryrefslogtreecommitdiff
path: root/runtime/syntax
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2004-10-11 10:16:09 +0000
committerBram Moolenaar <Bram@vim.org>2004-10-11 10:16:09 +0000
commit7b0294cb9f7cfcd3fcbbaa523578847a3e6d74c5 (patch)
tree5675edfe10a80abd76b307b855858f136c647d32 /runtime/syntax
parent7171abea1ad8d33cce89a9664873417187139a53 (diff)
downloadvim-7b0294cb9f7cfcd3fcbbaa523578847a3e6d74c5.zip
updated for version 7.0018
Diffstat (limited to 'runtime/syntax')
-rw-r--r--runtime/syntax/2html.vim92
-rw-r--r--runtime/syntax/slrnsc.vim6
2 files changed, 73 insertions, 25 deletions
diff --git a/runtime/syntax/2html.vim b/runtime/syntax/2html.vim
index 2afc09f93..25da291bd 100644
--- a/runtime/syntax/2html.vim
+++ b/runtime/syntax/2html.vim
@@ -1,6 +1,6 @@
" Vim syntax support file
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2004 May 31
+" Last Change: 2004 Oct 10
" (modified by David Ne\v{c}as (Yeti) <yeti@physics.muni.cz>)
" (XHTML support by Panagiotis Issaris <takis@lumumba.luc.ac.be>)
@@ -238,40 +238,88 @@ else
let s:end = line("$")
endif
+" Closed folds are kept in the HTML. Prepare the closed fold template text.
+if has('folding')
+ let s:c = &fillchars[matchend(&fillchars, 'fold:')]
+ if s:c == ''
+ let s:c = '-'
+ endif
+ let s:htmlfoldtext = '+' . s:c
+ while strlen(s:htmlfoldtext) < &columns
+ let s:htmlfoldtext = s:htmlfoldtext . s:c
+ endwhile
+ unlet s:c
+endif
+
+
while s:lnum <= s:end
" Get the current line
let s:line = getline(s:lnum)
- let s:len = strlen(s:line)
let s:new = ""
- if s:numblines
- let s:new = '<span class="lnr">' . strpart(' ', 0, strlen(line("$")) - strlen(s:lnum)) . s:lnum . '</span> '
- endif
+ if has('folding') && foldclosed(s:lnum) > -1
+ "
+ " This is the beginning of a folded block
+ "
+ if s:numblines
+ let s:new = strpart(' ', 0, strlen(line("$")) - strlen(s:lnum)) . s:lnum . ' '
+ endif
+ let s:line = foldtextresult(s:lnum)
- " Loop over each character in the line
- let s:col = 1
- while s:col <= s:len
- let s:startcol = s:col " The start column for processing text
- let s:id = synID(s:lnum, s:col, 1)
- let s:col = s:col + 1
- " Speed loop (it's small - that's the trick)
- " Go along till we find a change in synID
- while s:col <= s:len && s:id == synID(s:lnum, s:col, 1) | let s:col = s:col + 1 | endwhile
-
- " Output the text with the same synID, with class set to {s:id_name}
- let s:id = synIDtrans(s:id)
- let s:id_name = synIDattr(s:id, "name", s:whatterm)
- let s:new = s:new . '<span class="' . s:id_name . '">' . substitute(substitute(substitute(substitute(substitute(strpart(s:line, s:startcol - 1, s:col - s:startcol), '&', '\&amp;', 'g'), '<', '\&lt;', 'g'), '>', '\&gt;', 'g'), '"', '\&quot;', 'g'), "\x0c", '<hr class="PAGE-BREAK">', 'g') . '</span>'
+ let s:new = s:new . s:line
+ if !exists("html_no_pre")
+ let s:new = s:new . strpart(s:htmlfoldtext, strlen(s:new))
+ endif
+
+ " Replace the reserved html characters
+ let s:new = substitute(substitute(substitute(substitute(substitute(s:new, '&', '\&amp;', 'g'), '<', '\&lt;', 'g'), '>', '\&gt;', 'g'), '"', '\&quot;', 'g'), "\x0c", '<hr class="PAGE-BREAK">', 'g')
+
+ let s:id_name = "Folded"
+ let s:id = hlID(s:id_name)
+ let s:new = '<span class="' . s:id_name . '">' . s:new . '</span>'
" Add the class to class list if it's not there yet
if stridx(s:idlist, "," . s:id . ",") == -1
let s:idlist = s:idlist . s:id . ","
endif
- if s:col > s:len
- break
+ " Skip to the end of the fold
+ let s:lnum = foldclosedend(s:lnum)
+
+ else
+ "
+ " A line that is not folded.
+ "
+ let s:len = strlen(s:line)
+
+ if s:numblines
+ let s:new = '<span class="lnr">' . strpart(' ', 0, strlen(line("$")) - strlen(s:lnum)) . s:lnum . '</span> '
endif
- endwhile
+
+ " Loop over each character in the line
+ let s:col = 1
+ while s:col <= s:len
+ let s:startcol = s:col " The start column for processing text
+ let s:id = synID(s:lnum, s:col, 1)
+ let s:col = s:col + 1
+ " Speed loop (it's small - that's the trick)
+ " Go along till we find a change in synID
+ while s:col <= s:len && s:id == synID(s:lnum, s:col, 1) | let s:col = s:col + 1 | endwhile
+
+ " Output the text with the same synID, with class set to {s:id_name}
+ let s:id = synIDtrans(s:id)
+ let s:id_name = synIDattr(s:id, "name", s:whatterm)
+ let s:new = s:new . '<span class="' . s:id_name . '">' . substitute(substitute(substitute(substitute(substitute(strpart(s:line, s:startcol - 1, s:col - s:startcol), '&', '\&amp;', 'g'), '<', '\&lt;', 'g'), '>', '\&gt;', 'g'), '"', '\&quot;', 'g'), "\x0c", '<hr class="PAGE-BREAK">', 'g') . '</span>'
+ " Add the class to class list if it's not there yet
+ if stridx(s:idlist, "," . s:id . ",") == -1
+ let s:idlist = s:idlist . s:id . ","
+ endif
+
+ if s:col > s:len
+ break
+ endif
+ endwhile
+ endif
" Expand tabs
let s:pad=0
diff --git a/runtime/syntax/slrnsc.vim b/runtime/syntax/slrnsc.vim
index 3f653cc4e..838af6ad1 100644
--- a/runtime/syntax/slrnsc.vim
+++ b/runtime/syntax/slrnsc.vim
@@ -1,7 +1,7 @@
" Vim syntax file
" Language: Slrn score file (based on slrn 0.9.8.0)
-" Maintainer: Preben 'Peppe' Guldberg <peppe-vim@wielders.org>
-" Last Change: 19 May 2004
+" Maintainer: Preben 'Peppe' Guldberg <peppe@wielders.org>
+" Last Change: 8 Oct 2004
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
@@ -48,7 +48,7 @@ syn region slrnscScoreItem contained matchgroup=Special start="^\s*\~\={::\=" en
syn keyword slrnscScore contained Score
syn match slrnscScoreIdent contained "%.*"
-syn match slrnScoreLine "^\s*Score::\=\s\+=\=-\=\d\+\s*\(%.*\)\=$" skipempty nextgroup=slrnscScoreItem contains=slrnscScore,slrnscDelim,slrnscOper,slrnscNumber,slrnscScoreIdent
+syn match slrnScoreLine "^\s*Score::\=\s\+=\=[-+]\=\d\+\s*\(%.*\)\=$" skipempty nextgroup=slrnscScoreItem contains=slrnscScore,slrnscDelim,slrnscOper,slrnscNumber,slrnscScoreIdent
" Define the default highlighting.
" For version 5.7 and earlier: only when not done already