Modify

Opened 5 years ago

Last modified 3 years ago

#6907 new enhancement

An option to turn off numbering

Reported by: anonymous Owned by: coderanger
Priority: normal Component: TocMacro
Severity: normal Keywords:
Cc: cboos 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 (16)

comment:1 Changed 4 years ago by anonymous

The same request lie partially in ticket #8674.
Could you please provide us some feedback?
Cheers,
M

comment:2 Changed 4 years ago by anonymous

All the more it seems necessary for people using the NumberedHeadlines plugin
http://trac-hacks.org/wiki/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 4 years ago by anonymous

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:4 follow-up: Changed 4 years ago by anonymous

Hi, Is there anyone there? Cheers, M

comment:5 in reply to: ↑ 4 Changed 4 years ago by anonymous

Please...
Cheers,
M

comment:6 Changed 4 years ago by anonymous

Knock knock...
Still no one here?
Cheers,
M

comment:7 Changed 4 years ago by anonymous

Another try... Cheers, M

comment:8 Changed 3 years ago by anonymous

Come on...
Please!
M

comment:9 Changed 3 years ago by anonymous

Is there anyone here?
Cheers,
M

comment:10 Changed 3 years ago by anonymous

The 4th month of expectation is about to begin.
An answer would be so great...
Cheers,
M

comment:11 follow-up: Changed 3 years ago by cboos

  • Cc cboos 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 in reply to: ↑ 11 ; follow-up: Changed 3 years ago by mtrocme

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 in reply to: ↑ 12 ; follow-up: Changed 3 years ago by cboos

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 in reply to: ↑ 13 ; follow-up: Changed 3 years ago by mtrocme

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 in reply to: ↑ 14 ; follow-up: Changed 3 years ago by mtrocme

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 in reply to: ↑ 15 Changed 3 years ago by mtrocme

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

Add Comment

Modify Ticket

Action
as new The owner will remain coderanger.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.