Opened 15 years ago
Closed 8 years ago
#6907 closed enhancement (fixed)
An option to turn off numbering
Reported by: | anonymous | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Component: | TocMacro |
Severity: | normal | Keywords: | |
Cc: | Christian Boos | Trac Release: | 0.11 |
Description
It should be useful to have An option to turn off the section numbering. The numbering is always on when 'inline' option is active.
Attachments (0)
Change History (20)
comment:1 Changed 14 years ago by
comment:2 Changed 14 years ago by
All the more it seems necessary for people using the NumberedHeadlinesPlugin.
The numbering being redundant when one calls the "inline TOC":
= main title = ## title1 ## ### title11 ### ### title12 ### ## title2 ##
gives the following inline TOC
1. 1. title1 1. 1.1. title11 2. 1.2. title12 2. 2. title2
Cheers,
M
comment:3 Changed 14 years ago by
An "easy way" to do this would be to replace the <ol> and <li> tags generated by :
- the <dl> and <dd> tags respectively (indentation conserved)
or by
- the <dl> and <dt> tags respectively, if no indentation is desired (see ticket #8674)
Dear developpers, please...
Cheers,
M
comment:10 Changed 13 years ago by
The 4th month of expectation is about to begin.
An answer would be so great...
Cheers,
M
comment:11 follow-up: 12 Changed 13 years ago by
Cc: | Christian Boos added; anonymous removed |
---|
Hello Mathieu,
As Noah told you via PM, if there's no one on CC:, chances are that no one will notice your comments ;-)
Now to the topic itself, it seems a trivial matter of changing the tag.ol()
in source:tocmacro/0.11/tractoc/macro.py#L42 to something configurable (i.e. tag.ol()
or tag.ul()
depending on a macro parameter.
I could try to find a moment to do it, but your best bet is to try by yourself ;-)
comment:12 follow-up: 13 Changed 13 years ago by
Thanks Christian :-)
Actually another tag.ol() should also be replaced (see line 181).
What I'd like to get in the end is a bullet free list.
This can easily be achieved replacing
- all tag.ol() by tag.dl()
- all tag.li() by tag.dd()
Could you please implement this feature through the use of a new control argument (e.g. "nonumbering")?
Cheers,
Mathieu
comment:13 follow-up: 14 Changed 13 years ago by
Replying to mtrocme:
Thanks Christian :-)
Actually another tag.ol() should also be replaced (see line 181).
Feel free to attach your macro.py here... or rather a patch! But first have a look at Trac:TracDev/SubmittingPatches ;-)
In particular, pay attention to whitespace issues (don't use tabs).
What I'd like to get in the end is a bullet free list.
This can easily be achieved replacing
- all tag.ol() by tag.dl()
- all tag.li() by tag.dd()
Could you please implement this feature through the use of a new control argument (e.g. "nonumbering")?
Hm, no, a description list is no good substitute here, as you don't "define" anything. This should rather be achieved with ul/li + some css (e.g. ul.nonumbers li { list-style-type: none }
).
comment:14 follow-up: 15 Changed 13 years ago by
Ok, let's have a try...
Here's what I would do (sorry for any clumsiness, first patch ever and first python contact).
This is just a first (working) shot using tag.dd() instead of css-tuned tag.li():
23c23,24 < def outline_tree(env, ol, outline, context, active, min_depth, max_depth): --- > def outline_tree(env, ol, outline, context, active, min_depth, max_depth, > nonumbering): 39c40,43 < li = tag.li() --- > if nonumbering: > li = tag.dd() > else: > li = tag.li() 42c46,50 < new_ol = tag.ol() --- > new_ol = tag.dl() > if nonumbering: > new_ol = tag.dl() > else: > new_ol = tag.ol() 50,51c58,63 < li = tag.li(tag.a(Markup(heading), href=href), < class_=active and 'active' or None) --- > if nonumbering: > li = tag.dd(tag.a(Markup(heading), href=href), > class_=active and 'active' or None) > else: > li = tag.li(tag.a(Markup(heading), href=href), > class_=active and 'active' or None) 88a101 > || {{{nonumbering}}} || Inhibate automatic numbering (useful for compatibility with the NumberedHeadlines plugin). || 119a133 > nonumbering = False 128a143,144 > elif arg == 'nonumbering': > nonumbering = True 181c197,201 < ol = tag.ol() --- > ol = tag.dl() > if nonumbering: > ol = tag.dl() > else: > ol = tag.ol() 191,193c211,214 < self._render_title_index(formatter, ol, page_resource, < active and pagename == current_page, < params['min_depth'] < 2) --- > self._render_title_index(formatter, ol, page_resource, > active and pagename == current_page, > params['min_depth'] < 2, > nonumbering) 195,196c216,218 < self._render_page_outline(formatter, ol, page_resource, < active, params) --- > self._render_page_outline(formatter, ol, page_resource, > active, params, > nonumbering) 207c229,230 < def _render_title_index(self, formatter, ol, page_resource, active, show_title): --- > def _render_title_index(self, formatter, ol, page_resource, active, show_title, > nonumbering): 219,222c242,251 < ol.append((tag.li(tag.a(page_resource.id, < href=get_resource_url(self.env, page_resource, ctx.href)), < Markup(title), < class_= active and 'active' or None))) --- > if nonumbering: > ol.append((tag.dd(tag.a(page_resource.id, > href=get_resource_url(self.env, page_resource, ctx.href)), > Markup(title), > class_= active and 'active' or None))) > else: > ol.append((tag.li(tag.a(page_resource.id, > href=get_resource_url(self.env, page_resource, ctx.href)), > Markup(title), > class_= active and 'active' or None))) 224c253,254 < def _render_page_outline(self, formatter, ol, page_resource, active, params): --- > def _render_page_outline(self, formatter, ol, page_resource, active, params, > nonumbering): 231,233c261,264 < outline_tree(self.env, ol, fmt.outline, ctx, < active and page_resource.id == formatter.context.resource.id, < params['min_depth'], params['max_depth']) --- > outline_tree(self.env, ol, fmt.outline, ctx, > active and page_resource.id == formatter.context.resource.id, > params['min_depth'], params['max_depth'], > nonumbering)
I'll look at the css thing tomorrow.
In the meanwhile, feel free to share any comments.
Cheers,
Mathieu
comment:15 follow-up: 16 Changed 13 years ago by
Hi there,
Here's a second temporary patch that prevents from using dl/dd markups.
23c23,24 < def outline_tree(env, ol, outline, context, active, min_depth, max_depth): --- > def outline_tree(env, ol, outline, context, active, min_depth, max_depth, > nonumbering): 42c43,46 < new_ol = tag.ol() --- > if nonumbering: > new_ol = tag.ul(class_='nonumbers') > else: > new_ol = tag.ol() 88a93 > || {{{nonumbering}}} || Inhibate automatic numbering (useful for compatibility with the NumberedHeadlines plugin). || 119a125 > nonumbering = False 128a135,136 > elif arg == 'nonumbering': > nonumbering = True 181c189,192 < ol = tag.ol() --- > if nonumbering: > ol = tag.ul(class_='nonumbers') > else: > ol = tag.ol() 195,196c206,208 < self._render_page_outline(formatter, ol, page_resource, < active, params) --- > self._render_page_outline(formatter, ol, page_resource, > active, params, > nonumbering) 224c236,237 < def _render_page_outline(self, formatter, ol, page_resource, active, params): --- > def _render_page_outline(self, formatter, ol, page_resource, active, params, > nonumbering): 231,233c244,247 < outline_tree(self.env, ol, fmt.outline, ctx, < active and page_resource.id == formatter.context.resource.id, < params['min_depth'], params['max_depth']) --- > outline_tree(self.env, ol, fmt.outline, ctx, > active and page_resource.id == formatter.context.resource.id, > params['min_depth'], params['max_depth'], > nonumbering)
Adding the following lines at the end of wiki.css
/* TocMacro hack */ ul.nonumbers { list-style-type: none; }
does the trick (same rendering as the previous patch).
Nevertheless I don't think making a hard change in wiki.css is the right thing to do, especially for people who don't have access to wiki.css.
How could one cope with that?
Adding
<style type="text/css">ul.nonumbers { list-style-type: none; }</style>
within the header markups of all pages?
That does not seem really smarter...
Christian, any clue?
Cheers,
Mathieu
comment:16 Changed 13 years ago by
Hi again,
Here's a way (the way?) to avoid any style sheet:
23c23,24 < def outline_tree(env, ol, outline, context, active, min_depth, max_depth): --- > def outline_tree(env, ol, outline, context, active, min_depth, max_depth, > nonumbering): 42c43,46 < new_ol = tag.ol() --- > if nonumbering: > new_ol = tag.ul(style='list-style-type:none') > else: > new_ol = tag.ol() 88a93 > || {{{nonumbering}}} || Inhibate automatic numbering (useful for compatibility with the NumberedHeadlines plugin). || 119a125 > nonumbering = False 128a135,136 > elif arg == 'nonumbering': > nonumbering = True 181c189,192 < ol = tag.ol() --- > if nonumbering: > ol = tag.ul(style='list-style-type:none') > else: > ol = tag.ol() 195,196c206,208 < self._render_page_outline(formatter, ol, page_resource, < active, params) --- > self._render_page_outline(formatter, ol, page_resource, > active, params, > nonumbering) 224c236,237 < def _render_page_outline(self, formatter, ol, page_resource, active, params): --- > def _render_page_outline(self, formatter, ol, page_resource, active, params, > nonumbering): 231,233c244,247 < outline_tree(self.env, ol, fmt.outline, ctx, < active and page_resource.id == formatter.context.resource.id, < params['min_depth'], params['max_depth']) --- > outline_tree(self.env, ol, fmt.outline, ctx, > active and page_resource.id == formatter.context.resource.id, > params['min_depth'], params['max_depth'], > nonumbering)
What do you guys reckon?
Cheers,
M
comment:17 Changed 10 years ago by
Owner: | Noah Kantrowitz deleted |
---|
comment:18 follow-up: 19 Changed 8 years ago by
This is exactly what I'm looking for to avoid duplicate numbering from already numbered headings.
I have just added the previous code to the current revision of the plugin
Is there any reason why this patch has not been committed ?
-
tractoc/macro.py
34 34 def write(self, *args): pass 35 35 36 36 37 def outline_tree(env, ol, outline, context, active, min_depth, max_depth ):37 def outline_tree(env, ol, outline, context, active, min_depth, max_depth, nonumbering): 38 38 if min_depth > max_depth: 39 39 min_depth, max_depth = max_depth, min_depth 40 40 max_depth = min(6, max_depth) … … 53 53 li = tag.li() 54 54 ol.append(li) 55 55 stack[d] = (li, ol) 56 new_ol = tag.ol() 56 if nonumbering: 57 new_ol = tag.ul(style='list-style-type:none') 58 else: 59 new_ol = tag.ol() 57 60 li.append(new_ol) 58 61 stack[d+1] = (None, new_ol) 59 62 href = get_resource_url(env, context.resource, context.href) … … 103 106 || `notitle` || Supress display of page title. || 104 107 || `reverse` || Display TOC sorted in reversed order. ''(Since 11.0.0.4)'' || 105 108 || `from=page`|| Obtain the list of pages to show from the content (one page name per line) of another wiki page. || 109 || `nonumbering` || Inhibate automatic numbering || 106 110 For `titleindex` argument, an empty pagelist will evaluate to all pages: 107 111 {{{ 108 112 [[TOC(titleindex, notitle, heading=All pages)]] … … 157 161 inline = False 158 162 pagenames = [] 159 163 reverse = False 164 nonumbering = False 160 165 161 166 default_heading = 'Table of Contents' 162 167 params = {'min_depth': 1, 'max_depth': 6} … … 179 184 reverse = True 180 185 elif arg == 'nofloat': 181 186 return '' 187 elif arg == 'nonumbering': 188 nonumbering = True 182 189 elif arg != '': 183 190 pagenames.append(arg) 184 191 heading = kw.pop('heading', '') or default_heading … … 223 230 pagenames = temp_pagenames 224 231 225 232 base = tag.div(class_=inline and 'wiki-toc-inline' or 'wiki-toc') 226 ol = tag.ol() 233 if nonumbering: 234 ol = tag.ul(style='list-style-type:none') 235 else: 236 ol = tag.ol() 227 237 base.append([heading and tag.h4(heading), ol]) 228 238 229 239 active = len(pagenames) > 1 … … 239 249 params['min_depth'] < 2) 240 250 else: 241 251 self._render_page_outline(formatter, ol, page_resource, 242 active, params )252 active, params, nonumbering) 243 253 return base 244 254 245 255 def get_page_text(self, formatter, page_resource): … … 283 293 class_= active and 'active' or None))) 284 294 285 295 def _render_page_outline(self, formatter, ol, page_resource, active, 286 params ):296 params, nonumbering): 287 297 page_text, page_exists = self.get_page_text(formatter, page_resource) 288 298 if page_exists: 289 299 ctx = formatter.context(page_resource) … … 291 301 fmt.format(page_text, NullOut()) 292 302 outline_tree(self.env, ol, fmt.outline, ctx, 293 303 active and page_resource.id == formatter.context.resource.id, 294 params['min_depth'], params['max_depth'] )304 params['min_depth'], params['max_depth'], nonumbering) 295 305 else: 296 306 ol.append(system_message('Error: Page %s does not exist' % 297 307 page_resource.id))
comment:19 Changed 8 years ago by
Replying to ntmlod:
Is there any reason why this patch has not been committed ?
Yes, the plugin has no maintainer.
comment:20 Changed 8 years ago by
Owner: | set to Ryan J Ollos |
---|---|
Status: | new → accepted |
The same request lie partially in ticket #8674.
Could you please provide us some feedback?
Cheers,
M