Skip to content
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

Documentation does not describe how to use Markdown feature #808

Open
basebox-mt opened this issue Jan 9, 2025 · 3 comments
Open

Documentation does not describe how to use Markdown feature #808

basebox-mt opened this issue Jan 9, 2025 · 3 comments

Comments

@basebox-mt
Copy link

basebox-mt commented Jan 9, 2025

Cursive does have a markdown feature flag, but it is not documented how to display Markdown e.g. in a TextView.

There is also no example code.

This is what I have come up with so far:

use cursive::utils::markup::markdown::parse;

let content = parse(include_str!("LICENSE.md"));
// `content` is a `SpannedString` with styles, I can see that when I dump it
let text_view = TextView::new(content)
  .scrollable()
  [...]

The output is not styled, it is rather garbled, as it strips newlines, see screenshot: The '## Overview' heading should really start on a new line.

Screenshot 2025-01-09 at 14 54 21
@gyscos
Copy link
Owner

gyscos commented Jan 9, 2025

Hi, and thanks for the report!

I agree that the feature (and the entire markdown module) could benefit from better documentation.

Your usage look reasonable though, so I'll need to investigate what's going on. Either the license is not actually proper markdown, or the markdown parser is somehow failing here, or we're not properly handling the events it reports (most likely). Do you have a link to the LICENSE.md file you used?

@gyscos
Copy link
Owner

gyscos commented Jan 9, 2025

Indeed, newlines around heading and code blocks was incorrectly generated for markdown events. This should now be fixed in the latest commit.

Note that single newlines in markdown are ignored (so you can line-wrap the source markdown without affecting the output). You need double newlines for an actual newline (well, a new paragraph) to be generated.

@basebox-mt
Copy link
Author

Thanks for getting back to this.

This is the Markdown I used:

# Commercial Standard License

## Preamble/intro
This software license may be freely used in unmodified form (with exceptions).
A work may only be copyrighted under this license in its unmodified form, or
with some subsections removed or swapped out. Details todo.

## Overview
These are the changes made to this specific license:
Copyright Owner: [NAME HERE]
Product Name: [NAME HERE]
License Modifications
Source code is NOT provided.
Warranty is NOT given.
You are allowed to have this software installed on [NUM] machine(s) at once.
Commercial or educational use is NOT allowed.

## Definitions
"Product", or "software" refers to the work that is copyrighted under this license.

"We", or "us" refer to the copyright owner of this product. That owner is [NAME HERE]

"You" refers to the licensee of this product.

## License, not purchase
By purchasing this license, you are allowed to use this product, but we retain the copyright to the software.

## Redistribution
You may not redistribute or resell the software.

## Warranty
This product does NOT come with any warranty, express or implied, notwithstanding legislation to the contrary.

## Source Code
This software does NOT provide the source code, and it is NOT legal to attempt to acquire it, whether by reverse engineering or otherwise.

Note: If the owner wishes to provide the source code, remove the NOTs in the paragraph above. In either case, remove this notice.

## How to Use This License
To use this license for your software, fill in the required fields, denoted in brackets, like [THIS]. Modifications may be made by removing words in all caps, like THIS. (If this is done, all the words in that section must be removed, and this must match the overview section.)

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

No branches or pull requests

2 participants