picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.81k stars 615 forks source link

Option (or plugin) to change titles level #543

Closed raspbeguy closed 4 years ago

raspbeguy commented 4 years ago

Hello,

I think it would be great to have an option enabling to automatically change title levels.

For now, markdown title levels can only be matched to equivalent HTML levels: # to h1, ## to h2, etc...

But on some cases, with some special templates, we might want to shift down the title levels.

Let's say we have a (weird) template like this:

<h1>{{ meta.title }}</h1>
  <h2>Metadatas</h2>
    <h3>Author</h3>
{{ meta.author }}
    <h3>Tags</h3>
{{ meta.tags }}
  <h2>Content</h2>
{{ content }}

It would make no sense that # in the markdown should become h1. The only solution would be to be aware, as the writer, that you shouldn't use # or ## levels, which I find not very handy, especially if the writers are different people than the webmasters and have no idea how it works.

In this scenario, the feature I dream of would shift # to h3, ## to h4, etc...

It could be materialized with a setting titleshift, which default is 0. In the example I gave, it would be 2.

Thanks for your attention.

PhrozenByte commented 4 years ago

This would require you to write a Parsedown plugin. You can then hook into Pico's onParsedownRegistered event to load the plugin.

raspbeguy commented 4 years ago

I'm not at ease with PHP so that's why I ask here. Else I would have done it already.

raspbeguy commented 4 years ago

Also, I don't see how it would help me...

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! :+1: