Tcl Library Source Code

Check-in [d5f39d22eb]
Login
Bounty program for improvements to Tcl and certain Tcl packages.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Markdown: Fixed paragraph counting when nesting lists. Fix for indenting in progress.
Timelines: family | ancestors | descendants | both | doc-fixup-and-markdown
Files: files | file ages | folders
SHA3-256: d5f39d22eb20d32231754f3c01cb3424715a520d88b700545225fb4b5d2eed23
User & Date: andreask 2019-03-19 23:46:14
Context
2019-03-20
03:51
Markdown: Fixed indenting of example sections (as code blocks) nested in lists. Updated test results. check-in: 5ea283171a user: aku tags: doc-fixup-and-markdown
2019-03-19
23:46
Markdown: Fixed paragraph counting when nesting lists. Fix for indenting in progress. check-in: d5f39d22eb user: andreask tags: doc-fixup-and-markdown
23:45
Text: Fixed paragraph counting when nesting lists check-in: a75ee706ed user: andreask tags: doc-fixup-and-markdown
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to modules/doctools/mpformats/fmt.markdown.

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
..
69
70
71
72
73
74
75
76



77
78


79
80



81
82
83
84
85
86
87
88
89
...
101
102
103
104
105
106
107
108



109
110


111
112



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
...
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
}

proc LB  {} { return "\1\n" }
proc LB. {} { return "\1" }

# # ## ### ##### ########
## Override crucial parts of the regular text formatter











proc NewExample {} {
    return [ContextNew Example {
	VerbatimOn ; Example! ; Prefix! "    "
    }] ; # {}
}

proc NewUnorderedList {} {
    # Itemized list - unordered list - bullet
    # 1. Base context provides indentation.
    # 2. First paragraph in a list item.
    # 3. All other paragraphs.
    ContextPush




    set base [ContextNew Itemized {
	set bullet "[WPrefix?]  [IBullet]"


    }] ; # {}




    set first [ContextNew First {
	List! bullet $bullet [set ws "[BlankM $bullet] "]
    }] ; ContextSet $base ; # {}

    set next [ContextNew Next {
	WPrefix! $ws
	Prefix!  $ws
    }] ; ContextSet $base ; # {}

................................................................................

proc NewOrderedList {} {
    # Ordered list - enumeration - enum
    # 1. Base context provides indentation.
    # 2. First paragraph in a list item.
    # 3. All other paragraphs.
    ContextPush
    



    set base [ContextNew Enumerated {
	set bullet "[WPrefix?]  [EBullet]"


    }] ; # {}




    set first [ContextNew First {
	List! bullet $bullet [set ws "[BlankM $bullet] "]
    }] ; ContextSet $base ; # {}

    set next [ContextNew Next {
	WPrefix! $ws
	Prefix!  $ws
    }] ; ContextSet $base ; # {}

................................................................................
    # 2. Term context
    # 3. Definition context
    ContextPush

    # Markdown has no native definition lists. We translate them into
    # itemized lists, rendering the term part as the first paragraph
    # of each entry, and the definition as all following.
    



    set base [ContextNew Definitions {
	set bullet "[WPrefix?]  [IBullet]"


    }] ; # {}




    set term [ContextNew Term {
	List! bullet $bullet [set ws "[BlankM $bullet] "]
	VerbatimOn
    }] ; ContextSet $base ; # {}

    set def [ContextNew Def {
	WPrefix! $ws
	Prefix!  $ws
    }] ; ContextSet $base ; # {}

    TD $term $def
    ContextCommit
    
    ContextPop
    ContextSet $base
    return
}

c_pass 1 fmt_usage {cmd args} {c_hold synopsis "[join [linsert $args 0 $cmd] " "][LB.]"}
c_pass 1 fmt_call  {cmd args} {c_hold synopsis "[join [linsert $args 0 $cmd] " "][LB.]"}
................................................................................
    if {$img != {}} {
	if {$label != {}} {
	    return "!\[\]($img \"$label\")"
	} else {
	    return "!\[\]($img)"
	}
    }
    
    set img [dt_imgdata $text {txt}]
    if {$img != {}} {
	# Show ASCII image like an example (code block => fixed font, no reflow)
	# A label is shown as a pseudo-caption (paragraph after image).
	fmt_example $img
	if {$label != {}} {
	    Text [String "IMAGE: $label"]






>
>
>
>
>
>
>
>
>
>













>
>
>
>

|
>
>


>
>
>

|







 







|
>
>
>

|
>
>


>
>
>

|







 







|
>
>
>

|
>
>


>
>
>

|










|







 







|







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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
..
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
...
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
...
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
}

proc LB  {} { return "\1\n" }
proc LB. {} { return "\1" }

# # ## ### ##### ########
## Override crucial parts of the regular text formatter

proc In? {} {
    if {![CAttrHas mdindent]} {
	CAttrSet mdindent ""
    }
    CAttrGet mdindent
}
proc In! {ws} {
    CAttrSet mdindent $ws
}

proc NewExample {} {
    return [ContextNew Example {
	VerbatimOn ; Example! ; Prefix! "    "
    }] ; # {}
}

proc NewUnorderedList {} {
    # Itemized list - unordered list - bullet
    # 1. Base context provides indentation.
    # 2. First paragraph in a list item.
    # 3. All other paragraphs.
    ContextPush

    #puts_stderr "UL [CAttrName]"
    #puts_stderr "UL |[string map {{ } _} [In?]]|outer"

    set base [ContextNew Itemized {
	set bullet "[In?]  [IBullet]"
	set ws     "[BlankM $bullet] "
	In! $ws
    }] ; # {}

    #puts_stderr "UL |[string map {{ } _} $bullet]|[string length $bullet]"
    #puts_stderr "UL |[string map {{ } _} $ws]|[string length $ws]"

    set first [ContextNew First {
	List! bullet $bullet $ws
    }] ; ContextSet $base ; # {}

    set next [ContextNew Next {
	WPrefix! $ws
	Prefix!  $ws
    }] ; ContextSet $base ; # {}

................................................................................

proc NewOrderedList {} {
    # Ordered list - enumeration - enum
    # 1. Base context provides indentation.
    # 2. First paragraph in a list item.
    # 3. All other paragraphs.
    ContextPush

    #puts_stderr "OL [CAttrName]"
    #puts_stderr "OL |[string map {{ } _} [In?]]|outer"

    set base [ContextNew Enumerated {
	set bullet "[In?]  [EBullet]"
	set ws     "[BlankM $bullet] "
	In! $ws
    }] ; # {}

    #puts_stderr "OL |[string map {{ } _} $bullet]|[string length $bullet]"
    #puts_stderr "OL |[string map {{ } _} $ws]|[string length $ws]"

    set first [ContextNew First {
	List! bullet $bullet $ws
    }] ; ContextSet $base ; # {}

    set next [ContextNew Next {
	WPrefix! $ws
	Prefix!  $ws
    }] ; ContextSet $base ; # {}

................................................................................
    # 2. Term context
    # 3. Definition context
    ContextPush

    # Markdown has no native definition lists. We translate them into
    # itemized lists, rendering the term part as the first paragraph
    # of each entry, and the definition as all following.

    #puts_stderr "DL [CAttrName]"
    #puts_stderr "DL |[string map {{ } _} [In?]]|outer"

    set base [ContextNew Definitions {
	set bullet "[In?]  [IBullet]"
	set ws "[BlankM $bullet] "
	In! $ws
    }] ; # {}

    #puts_stderr "DL |[string map {{ } _} $bullet]|[string length $bullet]"
    #puts_stderr "DL |[string map {{ } _} $ws]|[string length $ws]"

    set term [ContextNew Term {
	List! bullet $bullet $ws
	VerbatimOn
    }] ; ContextSet $base ; # {}

    set def [ContextNew Def {
	WPrefix! $ws
	Prefix!  $ws
    }] ; ContextSet $base ; # {}

    TD $term $def
    ContextCommit

    ContextPop
    ContextSet $base
    return
}

c_pass 1 fmt_usage {cmd args} {c_hold synopsis "[join [linsert $args 0 $cmd] " "][LB.]"}
c_pass 1 fmt_call  {cmd args} {c_hold synopsis "[join [linsert $args 0 $cmd] " "][LB.]"}
................................................................................
    if {$img != {}} {
	if {$label != {}} {
	    return "!\[\]($img \"$label\")"
	} else {
	    return "!\[\]($img)"
	}
    }

    set img [dt_imgdata $text {txt}]
    if {$img != {}} {
	# Show ASCII image like an example (code block => fixed font, no reflow)
	# A label is shown as a pseudo-caption (paragraph after image).
	fmt_example $img
	if {$label != {}} {
	    Text [String "IMAGE: $label"]