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

Multiline entry results in multiple entries #31

Open
Mulugruntz opened this issue Jun 7, 2021 · 5 comments
Open

Multiline entry results in multiple entries #31

Mulugruntz opened this issue Jun 7, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@Mulugruntz
Copy link

Let's say I have the following changelog:

# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Changed `f()` and `g()` into `h(b:bool)`.

  **The change is NOT backward compatible!!** 
  
  Please replace `.f()` -> `.h()`
  And replace `.g()` -> `.h(b=True)`

  Reason: There is a bug in `somelib` ...

  More: https://bugs.python.org/issueXXXXX
- Release note 2.

## [1.0.0] - 2017-04-10
### Deprecated
- Known issue 1 (1.0.0)
- Known issue 2 (1.0.0)

[Unreleased]: https://github.test_url/test_project/compare/v1.0.0...HEAD
[1.0.0]: https://github.test_url/test_project/releases/tag/v1.0.0

Rendered as so:

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog,
and this project adheres to Semantic Versioning.

Unreleased

Changed

  • Changed f() and g() into h(b:bool).

    The change is NOT backward compatible!!

    Please replace .f() -> .h()
    And replace .g() -> .h(b=True)

    Reason: There is a bug in somelib ...

    More: https://bugs.python.org/issueXXXXX

  • Release note 2.

1.0.0 - 2017-04-10

Deprecated

  • Known issue 1 (1.0.0)
  • Known issue 2 (1.0.0)

If I run:

import keepachangelog
print(keepachangelog.from_dict(keepachangelog.to_dict('CHANGELOG.md', show_unreleased=True)))

This is what I get:

# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Changed `f()` and `g()` into `h(b:bool)`.
- The change is NOT backward compatible!!**
- Please replace `.f()` -> `.h()`
- And replace `.g()` -> `.h(b=True)`
- Reason: There is a bug in `somelib` ...
- More: https://bugs.python.org/issueXXXXX
- Release note 2.

## [1.0.0] - 2017-04-10
### Deprecated
- Known issue 1 (1.0.0)
- Known issue 2 (1.0.0)

[Unreleased]: https://github.test_url/test_project/compare/v1.0.0...HEAD
[1.0.0]: https://github.test_url/test_project/releases/tag/v1.0.0

Rendered as:

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog,
and this project adheres to Semantic Versioning.

Unreleased

Changed

  • Changed f() and g() into h(b:bool).
  • The change is NOT backward compatible!!**
  • Please replace .f() -> .h()
  • And replace .g() -> .h(b=True)
  • Reason: There is a bug in somelib ...
  • More: https://bugs.python.org/issueXXXXX
  • Release note 2.

1.0.0 - 2017-04-10

Deprecated

  • Known issue 1 (1.0.0)
  • Known issue 2 (1.0.0)

As we can see, each line is managed as a new note.

import keepachangelog, pprint
pprint.pprint(keepachangelog.to_dict('CHANGELOG.md', show_unreleased=True)['unreleased']['changed'])
['Changed `f()` and `g()` into `h(b:bool)`.',
 'The change is NOT backward compatible!!**',
 'Please replace `.f()` -> `.h()`',
 'And replace `.g()` -> `.h(b=True)`',
 'Reason: There is a bug in `somelib` ...',
 'More: https://bugs.python.org/issueXXXXX',
 'Release note 2.']
@Mulugruntz
Copy link
Author

And empty lines (which have their role in Markdown) are striped.

line = line.strip(" \n")

@Colin-b Colin-b added the bug Something isn't working label Jun 7, 2021
@Colin-b
Copy link
Owner

Colin-b commented Jun 7, 2021

Hello @Mulugruntz,

Thanks for reporting.

This is indeed a known issue. Markdown parsing is basic for now as we treat each line as a separate entry.
However I don't have time to handle this for now, if this is urgent feel free to come up with a pull request :)

Thanks again

@Colin-b Colin-b changed the title Multiline is not handled correctly Multiline entry results in multiple entries Jun 8, 2021
@Mulugruntz
Copy link
Author

Sure @Colin-b !

I just finished rewriting the whole parser.
For now, it does almost the same as the current one (there were a few weird behaviours/bugs that made little to no sense, I "fixed" them). These quirks can be seen in the test_ files I modified.

There are still some odd behaviours that could be discussed but I chose to not change them, to be as close as possible to the current one.

Anyway, now there is a whole bunch of objects that handle different parts of the changelog. And they can be serialized/deserialized.

I've seen that you did not have a single dependency, so I kept it this way (would have been so much simpler / faster with pydantic though 😞 ).

This is but a first step towards easier maintenance and future development.
Next, I will handle that multiline thing.

You can check the changes so far.
develop...Mulugruntz:new_object_parser

@Mulugruntz
Copy link
Author

@Mulugruntz
Copy link
Author

Followed-up on #37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants