Skip to content

Commit

Permalink
manpage: do not skip the last section.
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierog committed Sep 9, 2024
1 parent 88b793e commit c3a53b8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) for its CLI (Command-Line Interface), i.e. for the `moulti` command.
Although Moulti's Python packages, modules and functions are obviously available, they do not constitute a public API yet.

## Unreleased

### Fixed

- `moulti-man` and `moulti manpage` used to ignore the last section of all manpages.

## [1.18.0] - 2024-09-08

### Added
Expand Down
11 changes: 8 additions & 3 deletions src/moulti/manpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,19 @@ def dissect_manpage(filedesc: Any) -> dict:

sections: list[dict] = []
current_section = {'title': '', 'text': ''}

def add_section(section: dict[str, str]) -> None:
section['text'] = section['text'].strip('\n')
if section['title'] or section['text']:
sections.append(section)

for line in all_lines:
if line.startswith(' ') or line == '\n': # regular line
current_section['text'] += line
else: # section title
current_section['text'] = current_section['text'].strip('\n')
if current_section['title'] or current_section['text']:
sections.append(current_section)
add_section(current_section)
current_section = {'title': line.strip('\n'), 'text': ''}
add_section(current_section) # Handle the last section

return {
'title': title,
Expand Down

0 comments on commit c3a53b8

Please sign in to comment.