Skip to content

Improve table handling and formatting in markdown-to-man conversion #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: markdown-to-man
Choose a base branch
from

Conversation

Sachin-NK
Copy link

@Sachin-NK Sachin-NK commented Mar 27, 2025

This PR enhances the Markdown-to-manpage converter with several improvements:

New Features

  • Added table support – Converts Markdown tables to troff/groff format (.TS/.TE)
  • Better YAML front matter handling – More reliable stripping of metadata

Improvements

  • Added comprehensive table support using groff's TS/TE macros
  • Implemented more robust Markdown formatting handling (bold/italic/combined)
  • Introduced proper groff special character escaping (~, ^, `, etc)
  • Improved list processing with better indentation handling
  • Added paragraph (.PP) and section formatting
  • Simplified YAML front matter removal
  • Implemented block-based parsing architecture
  • Added UTF-8 encoding support for file operations
  • Enhanced code block formatting with proper font switching
  • Unified heading conversion logic
  • Improved text wrapping and whitespace handling
  • Added support for alternative Markdown syntax (bold/italic)
  • Removed fragile regex substitutions in favor of structured parsing
  • Added proper documentation section formatting

@Sachin-NK
Copy link
Author

@petrasovaa could you please check this out

@petrasovaa
Copy link
Owner

@petrasovaa could you please check this out

Sure, I will try to find some time for it

- Add hierarchical section numbering (1., 1.1) with descriptive labels (Main Section/Subsection)
- Implement explicit list nesting markers with level indicators and type detection
- Add space padding  (\fB text \fR) to improve source readability
- Resolve list index error in nested list processing
@petrasovaa
Copy link
Owner

Do you need any help with testing? The results don't look great, maybe you didn't test it?

image

image

image

@Sachin-NK
Copy link
Author

Sachin-NK commented Mar 30, 2025

Do you need any help with testing? The results don't look great, maybe you didn't test it?

I sincerely apologize for any inconvenience caused. I tested the changes manually, and my output seemed correct, but I noticed the differences in the images you shared.

Could you kindly share how you tested it? I’d love to follow the same process to understand where the discrepancy might be. I’ve also attached images of my output file how it appeared on my end for reference.

I truly appreciate your time and guidance on this. I’m really sorry for any trouble this may have caused, and I’ll make sure to get this sorted properly.

image
image

@kritibirda26
Copy link

Hi Sachin,

I saw the screenshots you posted on OSGeo wiki and I think you are seeing different output from Anna because you are directly viewing the content of the file without using the man tool. If you do man PATH_TO_YOUR_OUTPUT_FILE, you should likely be able to see same output.

(To avoid any confusion, I am also a fellow contributor in Grass).

@Sachin-NK
Copy link
Author

Hi Sachin,

I saw the screenshots you posted on OSGeo wiki and I think you are seeing different output from Anna because you are directly viewing the content of the file without using the man tool. If you do man PATH_TO_YOUR_OUTPUT_FILE, you should likely be able to see same output.

(To avoid any confusion, I am also a fellow contributor in Grass).

Thank you so much for the clarification! That makes a lot of sense,
Really appreciate your help! I’ll update here once I check.

- Added table processing functionality with troff/groff table format conversion
- Improved YAML front matter stripping and block parsing logic
- Enhanced special character handling, especially in code blocks
- Better heading and list processing with proper indentation
- Added UTF-8 encoding support for file operations
- Refactored argument parsing and output formatting
@Sachin-NK
Copy link
Author

@petrasovaa , when you have a moment, could you please review my changes? I’d really appreciate your feedback.

@petrasovaa
Copy link
Owner

On the left is the original viewed as man ./dist.x86_64-pc-linux-gnu/docs/man/man1/i.atcorr.1 and on the right is your result:
image

plus the header looks like that:
image

…andling, and groff escapes

- Added comprehensive table support using groff's TS/TE macros
- Implemented more robust Markdown formatting handling (bold/italic/combined)
- Introduced proper groff special character escaping (~, ^, `, etc)
- Improved list processing with better indentation handling
- Added paragraph (.PP) and section formatting
- Simplified YAML front matter removal
- Implemented block-based parsing architecture
- Added UTF-8 encoding support for file operations
- Enhanced code block formatting with proper font switching
- Unified heading conversion logic
- Improved text wrapping and whitespace handling
- Added support for alternative Markdown syntax (bold/italic)
- Removed fragile regex substitutions in favor of structured parsing
- Added proper documentation section formatting
@Sachin-NK
Copy link
Author

@petrasovaa sorry for the bother, can you kindly check the changes , when you have a moment

Image 2025-04-08 at 16 42 09_13e9ab00
Image 2025-04-08 at 16 42 09_88023add
Image 2025-04-08 at 16 42 09_b468f18f
Image 2025-04-08 at 16 42 10_cbc3e711

@petrasovaa
Copy link
Owner

This looks better, but even from your screenshots I can still see some markdown leftovers (headings, formatting, links). Plus you are not converting the right files, the md files in the source code are missing autogenerated headers, so you need to compile GRASS and then use the md files in ./dist.x86_64-pc-linux-gnu/docs/mkdocs/source which have the header, see my previous screenshot.

@Sachin-NK
Copy link
Author

Got it! I’ll make sure to use the correct files from after compiling GRASS and clean up any leftover markdown formatting. Thanks for pointing it out

@Sachin-NK
Copy link
Author

@petrasovaa Kindly review it when you have some time. Please let me know if any updates are required.
Image 2025-04-16 at 18 48 11_370bc8e0
Image 2025-04-16 at 18 48 12_09f79901
Image 2025-04-16 at 18 48 13_3f1b4920

@petrasovaa
Copy link
Owner

Sorry for taking me so long to respond... Looking at your last screenshot, the header is still not there. Have you compiled GRASS to generate the markdown file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants