Skip to content

Commit

Permalink
Matcher: fix the nested list selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
brechtm committed Oct 25, 2020
1 parent b6a6d18 commit b3fcc9b
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 59 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ New Features:

Fixed:

* the 'nested bulleted/enumerated list' selectors were broken; their
corresponding styles were never applied
* items inside a table cannot be referenced (issue #174)
* Sphinx frontend: fix handling of relative image paths in .rst files inside
a directory in the Sphinx project root
Expand Down
11 changes: 6 additions & 5 deletions src/rinoh/stylesheets/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,14 @@
# lists

matcher('list item label', ListItemLabel)
matcher('list item body', ListItem / GroupedFlowables)
matcher('list item paragraph', 'list item body' / Paragraph)

matcher('enumerated list', List.like('enumerated'))
matcher('enumerated list item', 'enumerated list' / ListItem)
matcher('enumerated list item label', 'enumerated list item' / ListItemLabel)
matcher('nested enumerated list', ListItem / 'enumerated list')
matcher('nested enumerated list', SelectorByName('list item body')
/ 'enumerated list')

matcher('(table) enumerated list', TableCell / ... / 'enumerated list')
matcher('(table) enumerated list item', '(table) enumerated list' / ListItem)
Expand All @@ -138,7 +141,8 @@
matcher('compact bulleted list', List.like('bulleted', compact=True))
matcher('bulleted list item', 'bulleted list' / ListItem)
matcher('bulleted list item label', 'bulleted list item' / ListItemLabel)
matcher('nested bulleted list', ListItem / 'bulleted list')
matcher('nested bulleted list', SelectorByName('list item body')
/ 'bulleted list')

matcher('(table) bulleted list', TableCell / ... / 'bulleted list')
matcher('(table) bulleted list item', '(table) bulleted list' / ListItem)
Expand All @@ -161,9 +165,6 @@
matcher('choices list item', 'choices list' / ListItem)
matcher('choices list item label', 'choices list item' / ListItemLabel)

matcher('list item body', ListItem / GroupedFlowables)
matcher('list item paragraph', 'list item body' / Paragraph)

matcher('definition list', DefinitionList)
matcher('definition list item', 'definition list' / LabeledFlowable)
matcher('definition term', 'definition list item'
Expand Down
Binary file modified tests_regression/rst/bullet_list.pdf
Binary file not shown.
45 changes: 24 additions & 21 deletions tests_regression/rst/bullet_list.stylelog
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
DocumentTree()
List(style='bulleted') /Users/brechtm/Documents/Code/rinohtype/tests_regression/rst/bullet_list.rst:2 <bullet_list>
> (0,0,1,0,2) bulleted list
ListItem()
ListItem() None:None <list_item>
x (0,0,1,0,4) bulleted list item
> fallback to default style
ListItemLabel('•')
Expand All @@ -18,16 +18,17 @@
SingleStyledText('')
SingleStyledText('•')
SingleStyledText('')
StaticGroupedFlowables() None:None <list_item>
StaticGroupedFlowables()
> (0,0,0,0,3) list item body
Paragraph('A bullet list') /Users/brechtm/Documents/Code/rinohtype/tests_regression/rst/bullet_list.rst:2 <paragraph>
> (0,0,0,0,5) list item paragraph
(0,0,0,0,2) body
MixedStyledText('A bullet list')
SingleStyledText('A bullet list')
List(style='bulleted') /Users/brechtm/Documents/Code/rinohtype/tests_regression/rst/bullet_list.rst:4 <bullet_list>
> (0,0,1,0,2) bulleted list
ListItem()
> (0,0,1,0,5) nested bulleted list
(0,0,1,0,2) bulleted list
ListItem() None:None <list_item>
x (0,0,1,0,4) bulleted list item
> fallback to default style
ListItemLabel('•')
Expand All @@ -37,14 +38,14 @@
SingleStyledText('')
SingleStyledText('•')
SingleStyledText('')
StaticGroupedFlowables() None:None <list_item>
StaticGroupedFlowables()
> (0,0,0,0,3) list item body
Paragraph('Nested bullet list') /Users/brechtm/Documents/Code/rinohtype/tests_regression/rst/bullet_list.rst:4 <paragraph>
> (0,0,0,0,5) list item paragraph
(0,0,0,0,2) body
MixedStyledText('Nested bullet list')
SingleStyledText('Nested bullet list')
ListItem()
ListItem() None:None <list_item>
x (0,0,1,0,4) bulleted list item
> fallback to default style
ListItemLabel('•')
Expand All @@ -54,14 +55,14 @@
SingleStyledText('')
SingleStyledText('•')
SingleStyledText('')
StaticGroupedFlowables() None:None <list_item>
StaticGroupedFlowables()
> (0,0,0,0,3) list item body
Paragraph('Nested item 2') /Users/brechtm/Documents/Code/rinohtype/tests_regression/rst/bullet_list.rst:5 <paragraph>
> (0,0,0,0,5) list item paragraph
(0,0,0,0,2) body
MixedStyledText('Nested item 2')
SingleStyledText('Nested item 2')
ListItem()
ListItem() None:None <list_item>
x (0,0,1,0,4) bulleted list item
> fallback to default style
ListItemLabel('•')
Expand All @@ -71,7 +72,7 @@
SingleStyledText('')
SingleStyledText('•')
SingleStyledText('')
StaticGroupedFlowables() None:None <list_item>
StaticGroupedFlowables()
> (0,0,0,0,3) list item body
Paragraph('Item 2') /Users/brechtm/Documents/Code/rinohtype/tests_regression/rst/bullet_list.rst:7 <paragraph>
> (0,0,0,0,5) list item paragraph
Expand All @@ -84,8 +85,9 @@
MixedStyledText('Paragraph 2 of item 2')
SingleStyledText('Paragraph 2 of item 2')
List(style='bulleted') /Users/brechtm/Documents/Code/rinohtype/tests_regression/rst/bullet_list.rst:11 <bullet_list>
> (0,0,1,0,2) bulleted list
ListItem()
> (0,0,1,0,5) nested bulleted list
(0,0,1,0,2) bulleted list
ListItem() None:None <list_item>
x (0,0,1,0,4) bulleted list item
> fallback to default style
ListItemLabel('•')
Expand All @@ -95,14 +97,14 @@
SingleStyledText('')
SingleStyledText('•')
SingleStyledText('')
StaticGroupedFlowables() None:None <list_item>
StaticGroupedFlowables()
> (0,0,0,0,3) list item body
Paragraph('Nested bullet list') /Users/brechtm/Documents/Code/rinohtype/tests_regression/rst/bullet_list.rst:11 <paragraph>
> (0,0,0,0,5) list item paragraph
(0,0,0,0,2) body
MixedStyledText('Nested bullet list')
SingleStyledText('Nested bullet list')
ListItem()
ListItem() None:None <list_item>
x (0,0,1,0,4) bulleted list item
> fallback to default style
ListItemLabel('•')
Expand All @@ -112,16 +114,17 @@
SingleStyledText('')
SingleStyledText('•')
SingleStyledText('')
StaticGroupedFlowables() None:None <list_item>
StaticGroupedFlowables()
> (0,0,0,0,3) list item body
Paragraph('Nested item 2') /Users/brechtm/Documents/Code/rinohtype/tests_regression/rst/bullet_list.rst:12 <paragraph>
> (0,0,0,0,5) list item paragraph
(0,0,0,0,2) body
MixedStyledText('Nested item 2')
SingleStyledText('Nested item 2')
List(style='bulleted') /Users/brechtm/Documents/Code/rinohtype/tests_regression/rst/bullet_list.rst:14 <bullet_list>
> (0,0,1,0,2) bulleted list
ListItem()
> (0,0,1,0,5) nested bulleted list
(0,0,1,0,2) bulleted list
ListItem() None:None <list_item>
x (0,0,1,0,4) bulleted list item
> fallback to default style
ListItemLabel('•')
Expand All @@ -131,14 +134,14 @@
SingleStyledText('')
SingleStyledText('•')
SingleStyledText('')
StaticGroupedFlowables() None:None <list_item>
StaticGroupedFlowables()
> (0,0,0,0,3) list item body
Paragraph('Third level') /Users/brechtm/Documents/Code/rinohtype/tests_regression/rst/bullet_list.rst:14 <paragraph>
> (0,0,0,0,5) list item paragraph
(0,0,0,0,2) body
MixedStyledText('Third level')
SingleStyledText('Third level')
ListItem()
ListItem() None:None <list_item>
x (0,0,1,0,4) bulleted list item
> fallback to default style
ListItemLabel('•')
Expand All @@ -148,14 +151,14 @@
SingleStyledText('')
SingleStyledText('•')
SingleStyledText('')
StaticGroupedFlowables() None:None <list_item>
StaticGroupedFlowables()
> (0,0,0,0,3) list item body
Paragraph('Item 2') /Users/brechtm/Documents/Code/rinohtype/tests_regression/rst/bullet_list.rst:15 <paragraph>
> (0,0,0,0,5) list item paragraph
(0,0,0,0,2) body
MixedStyledText('Item 2')
SingleStyledText('Item 2')
ListItem()
ListItem() None:None <list_item>
x (0,0,1,0,4) bulleted list item
> fallback to default style
ListItemLabel('•')
Expand All @@ -165,7 +168,7 @@
SingleStyledText('')
SingleStyledText('•')
SingleStyledText('')
StaticGroupedFlowables() None:None <list_item>
StaticGroupedFlowables()
> (0,0,0,0,3) list item body
Paragraph('Nested item 3') /Users/brechtm/Documents/Code/rinohtype/tests_regression/rst/bullet_list.rst:17 <paragraph>
> (0,0,0,0,5) list item paragraph
Expand Down
Binary file modified tests_regression/rst/enumerated_list.pdf
Binary file not shown.
Loading

0 comments on commit b3fcc9b

Please sign in to comment.