Conversation
…when configured filename ends with '.md'
for more information, see https://pre-commit.ci
Codecov ReportBase: 100.00% // Head: 100.00% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## trunk #439 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 13 13
Lines 600 610 +10
Branches 144 144
=========================================
+ Hits 600 610 +10
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
for more information, see https://pre-commit.ci
…pty line between bullets to render multi-line bullets correctly
for more information, see https://pre-commit.ci
Ooof I couldn't make it work even with you changes: I also don't think we should care. Changelogs are mainly rendered by web interfaces, so if anything we should focus on CommonMark / GitHub. I would really not want such warts in our APIs. The much more modern So if we decide to move on with this, please don't encode weird behaviors into our defaults, Markdown is weird enough as it is. :) |
|
You couldn't get to work because you didn't lstrip, so it had leading spaces: I assumed since markdown is the common package people install in Python and this is a python package that maybe there'd be some caring... but you're probably right - it's just ugly! It should be easy to just revert that since I did the "warty" fix in one commit :) |
|
Looking closer at the PR, I'm not super excited about this; let me explain: Fact is, you already can do Markdown with Towncrier. What this PR does is making is more convenient / magic-ey – that's fair and entirely desirable! The price though is that the implementation gets even more convoluted. Maybe if you revert the markdown kludges above I might change my view, but as someone who spent the past weeks trying to make towncrier more maintainable this looks like a step back. :( |
There was a problem hiding this comment.
I just did a quick look at this.
Are we using templates/default.rst to generate Markdown output?
I think is best to have a separate templates/default.md Jinja template.
if filename ends with '.md` we can auto-magically set the Mardown defaults.
If template is not defined in the config we use a default markdown specific templat.
So we leave the current rendering engine as it is, as just fiddle with the template and current configs
Would that work?
And many thanks for putting all this together :)
| title_format=config.get("title_format", _title_format), | ||
| issue_format=config.get("issue_format"), | ||
| underlines=config.get("underlines", _underlines), | ||
| underlines=config.get("underlines", _md_underlines if is_md else _underlines), |
There was a problem hiding this comment.
I find it easier to read.
| underlines=config.get("underlines", _md_underlines if is_md else _underlines), | |
| underlines=underlines, |
| ) | ||
|
|
||
| filename = config.get("filename", "NEWS.rst") | ||
| is_md = filename.endswith(".md") |
There was a problem hiding this comment.
Can we have all the if_md values and default selection in a common block.
Is ok to even move this to a separate function like `defaults = _get_missing_defaults(config)"
| is_md = filename.endswith(".md") | |
| underlines = config.get("underlines", "") | |
| title_prefixes=config.get("title_prefixes", "") | |
| if filename.endswith(".md"): | |
| # Try to use markdown default. | |
| if no underlines: | |
| underlliens = ["", "", ""] | |
| if no underlines: | |
| # Fallback to rst defaults. | |
| underlines = ["=", "-", "~"] |
And I hope we don't need md_prefixes and md_bullet, as we can handle all this in the custom tempalates/default.md
What do you think?
|
My suggestion would be at this point:
We must decouple the logic, but first we need to have a common ground zero. Those nested conditionals were a nightmare before and we really ought not make them worse. This needs some bigger refactorings than fiddling with |
|
Let's think about this from what would be best and least convoluted then.
That seems pretty straight forward. How does this approach sound? |
Sound good. Thanks! As @hynek mentions, we should try to keep this code as simple as possible... otherwise we will end up with a lot of bugs. There are not too many automated tests (even with 100% code coverage), and we have limited dev resources. I am looking after this project always in a hurry, trying to help and not to block the development...but I don't have time to sit down and fully evaluate all the changes and think about the side effects So, a code that is simple, is best. |
|
JFTR: having tons of conditionals and prefixed variables is code screaming for polymorphism. I think it would be a strict positive to untangle towncrier from rST (internally for now) and would be happy to help you to do it as part of this PR if you’re willing to play along (or we split the work into this PR only providing a template with the detection and do the refactoring + more comfort in a next PR). it’s the old “make it work, make it right,” and in this case “make it pretty”. 😃 |
Description
Provide markdown compatible formatting.
Fixes #128.
Config values for
underlinesandtitle_prefixesare have different defaults when afilenameis configured that has an.mdfile extension.Oh, and it turns out that python's markdown implementation doesn't handle multi-line bullets unless they are indented and have an empty line between each, so it also renders them like that now.
New configuration options:
title_prefixes(default of["", "", ""]unless in.mdmode, then["# ", "## ", "### "])issues_spaced(defaultFalseunless in.mdmode)bullet(default of"- "unless in.mdmode, then" - ")Checklist
src/towncrier/newsfragments/. Describe yourchange and include important information. Your change will be included in the public release notes.
docs/tutorial.rstis still up-to-date.