Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' of github.com:ObsidianPublisher/follow_template
Browse files Browse the repository at this point in the history
  • Loading branch information
Mara-Li committed Oct 30, 2023
2 parents d97a8d9 + a94e042 commit 770bc71
Show file tree
Hide file tree
Showing 5 changed files with 386 additions and 245 deletions.
48 changes: 48 additions & 0 deletions .github/ISSUE_TEMPLATE/Feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: "[Mkdocs Publisher Template] Feature request"
description: "Suggest an idea for the publisher mkdocs template."
title: "[FR]: "
labels: ["✨ Enhancement"]
assignees:
- lisandra-dev
body:
- type: markdown
attributes:
value: |
Thanks for this report!
- type: checkboxes
attributes:
label: Issue validation
description: "Thanks to check if your issue is relative to the repository. Any non relative or duplicate issue will be closed."
options:
- label: "My issue concern strickly the template, adn isn't a question relative to [Material Mkdocs](https://squidfunk.github.io/mkdocs-material/) nor [Mkdocs](https://www.mkdocs.org/)."
required: true
- label: "I checked the issue to prevent duplicate"
required: true
- label: "My issue doesn't concern the **Obsidian Plugin**. Issue regarding the plugin must be [here](https://github.com/ObsidianPublisher/obsidian-github-publisher/issues)
required: true
- type: textarea
id: describe-request
attributes:
label: Is your feature related to a problem ?
description: If you found a solution with the inherent limit I had with Obsidian, please, add it here!
placeholder: "Tell me the original problem"
- type: textarea
id: describe-solution
attributes:
label: What solution do you want to see ?
description: Describe your idea here!
validations:
required: true
- type: textarea
id: alternative
attributes:
label: Describe the alternative you've considered
- type: textarea
attributes:
label: Anything else?
description: |
Links? References? Anything that will give us more context about the issue you are encountering!
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
validations:
required: false

86 changes: 86 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: "[Mkdocs Publisher Template] Bug report"
description: Fill a bug report for the mkdocs publisher template
title: '[Bug]: '
labels: ["🐛 Bug"]
assignees:
- lisandra-dev
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report.
- type: checkboxes
id: terms
attributes:
label: Material General discussion
description: "Thanks to check if your issue is relative to the repository. Any non relative or duplicate issue will be closed."
options:
- label: "My issue is not a question relative to [Material Mkdocs](https://squidfunk.github.io/mkdocs-material/) nor [Mkdocs](https://www.mkdocs.org/) (*[You can open a discussion to get more help!](https://github.com/squidfunk/mkdocs-material/discussions)*)"
required: true
- label: "I checked the issue to prevent duplicate"
required: true
- label: "I checked my configurations files and the documentation"
required: true
- label: "My issue is not relative to the [actions/github Workflow](https://github.com/ObsidianPublisher/actions). If it's the case, you must open an issue [here](https://github.com/ObsidianPublisher/actions/issues)."
required: true
- label: "My issue is not relative to the **Obsidian Plugin**. If it's the case, you must open an issue [here](https://github.com/ObsidianPublisher/obsidian-github-publisher/issues).
required: true
- type: textarea
id: error
attributes:
label: Error
description: Paste the error you got here
render: bash session
validations:
required: true
- type: textarea
id: actual
attributes:
label: Bug description
description: What actually happened?
validations:
required: true
- type: textarea
id: steps
attributes:
label: Steps to reproduce
description: How can we reproduce this issue?
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected behavior
description: What did you expect to happen?
validations:
required: false
- type: textarea
id: screenshots
attributes:
label: Screenshots
description: If applicable, add screenshots to help explain your problem.
validations:
required: false
- type: textarea
id: context
attributes:
label: Additional context
description: Add any other context about the problem here.
validations:
required: false
- type: textarea
id: requirements
attributes:
label: Requirements
description: Paste your `requirements.txt` file here
render: bash session
validations:
required: true
- type: textarea
id: mkdocs-yml
attributes:
label: Mkdocs.yml
description: Paste your `mkdocs.yml` file here
render: YAML
validations:
required: true
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ plugins:
- git-revision-date-localized:
type: date
fallback_to_build_date: true
locale: fr
locale: en
custom_format: "%A %d %B %Y"
enable_creation_date: true
- ezlinks:
Expand Down
49 changes: 26 additions & 23 deletions overrides/hooks/on_page_markdown.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,51 @@
import re


def non_breaking_space(markdown):
return re.sub('[\u00A0\u1680\u180E\u2000-\u200B\u202F\u205F\u3000\uFEFF]', ' ', markdown)
return re.sub(
"[\u00A0\u1680\u180E\u2000-\u200B\u202F\u205F\u3000\uFEFF]", " ", markdown
)


def update_heading(markdown):
file_content = markdown.split('\n')
markdown = ''
file_content = markdown.split("\n")
markdown = ""
code = False
for line in file_content:
if not code:
if line.startswith('```'):
if line.startswith("```"):
code = True
elif line.startswith('#') and line.count('#')<=5:
heading_number = line.count('#') + 1
line = '#' * heading_number + ' ' + line.replace('#', '')
elif line.startswith('```') and code:
elif line.startswith("#") and line.count("#") <= 5:
heading_number = line.count("#") + 1
line = "#" * heading_number + " " + line.replace("#", "")
elif line.startswith("```") and code:
code = True
markdown += line + '\n'
markdown += line + "\n"
return markdown


def strip_comments(markdown):
file_content = markdown.split('\n')
markdown = ''
for line in file_content:
if not re.search(r'%%(.*)%%', line) or not line.startswith('%%') or not line.endswith('%%'):
markdown += line + '\n'
markdown = re.sub(r'%%(.*)%%', '', markdown, flags=re.DOTALL)
return markdown
return re.sub(r"%%.*?%%", "", markdown, flags=re.DOTALL)


def fix_tags(metadata):
tags = metadata.get('tags', None) or metadata.get('tag', None)
tags = metadata.get("tags", None) or metadata.get("tag", None)
if tags and isinstance(tags, str):
tags = tags.split('/')
tags = tags.split("/")
tags = [tag.strip() for tag in tags]
metadata['tags'] = tags
metadata["tags"] = tags
return metadata


def on_page_markdown(markdown, files, page, config, **kwargs):
config_hooks = config['extra'].get('hooks', {'strip_comments': True, 'fix_heading': False})
if config_hooks['strip_comments']:
config_hooks = config.get(
"extra", {"hooks": {"strip_comments": True, "fix_heading": False}}
).get("hooks", {"strip_comments": True, "fix_heading": False})
if config_hooks.get("strip_comments", True):
markdown = strip_comments(markdown)
if config_hooks['fix_heading']:
if config_hooks.get("fix_heading", False):
markdown = update_heading(markdown)
metadata = fix_tags(page.meta)
page.meta = metadata
markdown = non_breaking_space(markdown)
return markdown
return markdown
Loading

0 comments on commit 770bc71

Please sign in to comment.