File: block.lsed

package info (click to toggle)
stx2any 1.56-2.3
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 748 kB
  • sloc: sh: 312; python: 288; lisp: 137; makefile: 126; sed: 1
file content (66 lines) | stat: -rw-r--r-- 1,759 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
w_doc_id(s2aimpl.block)dnl

This file is copyright (c) 2004,2005,2006 by Panu Kalliokoski
and released under the license in ../LICENSE

Block rules.  These are quite simple: we process line at a time,
classifying them by the kind of block-level element they begin.
Grouping these into logical entities is done on the ''m4'' side.

First, because we want to jump to the end immediately after first
matching classification, clear the ''t'' flag of ''sed''.
{{{
t foo
: foo
}}}

Basically, there need not be special support for `w_beg' and `w_end'.
However, if we process them as their own line type, they won't leave
irritating markup in the output (most importantly, no `w_bline') and
there is less need for whitespace-related quirks in the implementing
''m4'' code.
{{{
s#^\( *\)\(w_invoke(`w_beg')(.*)\) *$#w_newindent(len(`\1'))\2`'dnl#
t end
s#^\( *\)\(w_invoke(`w_end')(.*)\) *$#w_newindent(len(`\1'))\2`'dnl#
t end
}}}

Next, there are the syntaxes which take the whole line.  These don't
need a trailing `w_eline'.
{{{
s#^\(!!*\) *\(.*\)$#w_headl(len(\1),`\2')#
t end
s#^ *$#w_para#
t end
s#^---*$#w_sbreak(len(&))#
t end
s#^\( *\)\(.*\)::$#w_term(len(`\1'),`\2')#
t end
}}}

Otherwise, add the end-of-line marker.  Because this is not a
classification, clear the ''t'' flag again.
{{{
s#$#`'w_eline#
t bar
: bar
}}}

Lists are recognised from the beginning of the line.  They induce two
indent levels (one for the list, one for the item text) so we report
both.
{{{
s#^\(\( *\)\*  *\)#w_item(len(`\2'),len(`\1'),*)`'#
t end
s#^\(\( *\)-  *\)#w_item(len(`\2'),len(`\1'),-)`'#
t end
s#^\(\( *\)\#  *\)#w_item(len(`\2'),len(`\1'),\#)`'#
t end
}}}

Everything else is an ordinary text line.  End of classification.
{{{
s#^ *#w_bline(len(`&'))`'#
: end
}}}