Commit 5cbf097ef35a1a3a11e56ec63e4140d7f8511eb1

vimd2h.py: + 1st line help title (CSS "flh")
Rename PAT_TITLE to PAT_VIM_REF
Author: Alin Mr
Author date (UTC): 2024-03-16 14:01
Committer name: Alin Mr
Committer date (UTC): 2024-03-16 14:01
Parent(s): 71fba44ea441d8e469c4e06e72d161f54b43c83b
Signing key:
Tree: ae3c952ce53500724f00d92d2b4d42a6a11ecdb2
File Lines added Lines deleted
vimd2h.py 13 5
File vimd2h.py changed (mode: 100755) (index fa1b0c8..f2541cb)
... ... except:
15 15 import urllib import urllib
16 16
17 17 RE_TAGLINE = re.compile(r'(\S+)\s+(\S+)') RE_TAGLINE = re.compile(r'(\S+)\s+(\S+)')
18 RE_LINE1_HELP = re.compile(r'^\*\S+\*\s.*')
18 19
19 20 PAT_WORDCHAR = '[!#-)+-{}~\xC0-\xFF]' PAT_WORDCHAR = '[!#-)+-{}~\xC0-\xFF]'
20 21
 
... ... PAT_SPECIAL = r'(<.*?>|\{.*?}|' \
29 30 r'\[(?:range|line|count|offset|\+?cmd|[-+]?num|\+\+opt|' \ r'\[(?:range|line|count|offset|\+?cmd|[-+]?num|\+\+opt|' \
30 31 r'arg|arguments|ident|addr|group)]|' \ r'arg|arguments|ident|addr|group)]|' \
31 32 r'(?<=\s)\[[-a-z^A-Z0-9_]{2,}])' r'(?<=\s)\[[-a-z^A-Z0-9_]{2,}])'
32 PAT_TITLE = r'(Vim version [0-9.a-z]+|VIM REFERENCE.*)'
33 PAT_VIM_REF = r'(Vim version [0-9.a-z]+|VIM REFERENCE.*)'
33 34 PAT_NOTE = r'((?<!' + PAT_WORDCHAR + r')(?:note|NOTE|Notes?):?' \ PAT_NOTE = r'((?<!' + PAT_WORDCHAR + r')(?:note|NOTE|Notes?):?' \
34 35 r'(?!' + PAT_WORDCHAR + r'))' r'(?!' + PAT_WORDCHAR + r'))'
35 36 PAT_URL = r'((?:https?|ftp)://[^\'"<> \t]+[a-zA-Z0-9/])' PAT_URL = r'((?:https?|ftp)://[^\'"<> \t]+[a-zA-Z0-9/])'
 
... ... RE_TAGWORD = re.compile(
49 50 PAT_OPTWORD + '|' + PAT_OPTWORD + '|' +
50 51 PAT_CTRL + '|' + PAT_CTRL + '|' +
51 52 PAT_SPECIAL + '|' + PAT_SPECIAL + '|' +
52 PAT_TITLE + '|' +
53 PAT_VIM_REF + '|' +
53 54 PAT_NOTE + '|' + PAT_NOTE + '|' +
54 55 PAT_URL + '|' + PAT_URL + '|' +
55 56 PAT_WORD) PAT_WORD)
 
... ... class VimDoc2HTML(object):
119 120 out = [ ] out = [ ]
120 121
121 122 inexample = 0 inexample = 0
123 lineno = 0
122 124 for line in RE_NEWLINE.split(contents): for line in RE_NEWLINE.split(contents):
125 lineno += 1
123 126 line = line.rstrip('\r\n') line = line.rstrip('\r\n')
127 line1_help = lineno == 1 and RE_LINE1_HELP.match(line)
128 if line1_help:
129 out.append('<span class="flh">')
124 130 line_tabs = line line_tabs = line
125 131 line = line.expandtabs() line = line.expandtabs()
126 132 if RE_HRULE.match(line): if RE_HRULE.match(line):
 
... ... class VimDoc2HTML(object):
148 154 out.append(html_escape[line[lastpos:pos]]) out.append(html_escape[line[lastpos:pos]])
149 155 lastpos = match.end() lastpos = match.end()
150 156 header, graphic, pipeword, starword, command, opt, ctrl, \ header, graphic, pipeword, starword, command, opt, ctrl, \
151 special, title, note, url, word = match.groups()
157 special, vimref, note, url, word = match.groups()
152 158 if pipeword is not None: if pipeword is not None:
153 159 out.append(self.maplink(pipeword, 'l')) out.append(self.maplink(pipeword, 'l'))
154 160 elif starword is not None: elif starword is not None:
 
... ... class VimDoc2HTML(object):
164 170 out.append(self.maplink(ctrl, 'k')) out.append(self.maplink(ctrl, 'k'))
165 171 elif special is not None: elif special is not None:
166 172 out.append(self.maplink(special, 's')) out.append(self.maplink(special, 's'))
167 elif title is not None:
168 out.extend(('<span class="i">', html_escape[title],
173 elif vimref is not None:
174 out.extend(('<span class="i">', html_escape[vimref],
169 175 '</span>')) '</span>'))
170 176 elif note is not None: elif note is not None:
171 177 out.extend(('<span class="n">', html_escape[note], out.extend(('<span class="n">', html_escape[note],
 
... ... class VimDoc2HTML(object):
182 188 out.append(self.maplink(word)) out.append(self.maplink(word))
183 189 if lastpos < len(line): if lastpos < len(line):
184 190 out.append(html_escape[line[lastpos:]]) out.append(html_escape[line[lastpos:]])
191 if line1_help:
192 out.append('</span>')
185 193 out.append('\n') out.append('\n')
186 194 if inexample == 1: inexample = 2 if inexample == 1: inexample = 2
187 195
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vimdoc2html

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vimdoc2html

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master