Skip to content

Commit

Permalink
Merge branch 'release/1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Necriso committed Aug 23, 2024
2 parents 8aed5e8 + e24b35f commit 4ded13f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

This Action copies the contents of a Markdown `.md` file or folder to a Confluence cloud parent page.

It uses the heading in the first line that begins with a single `#` as the Confluence page title otherwise,
it takes the filename of the `.md` file as the page title.

## Getting Started

```yml
Expand Down
6 changes: 5 additions & 1 deletion bin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@ def render_html(md_content):

def get_page_title(md_file):
"""
Extract the page title from the Markdown file title
Extract the page title from the Markdown title if not set use filename
"""
with open(md_file, 'r', encoding='utf-8') as f:
first_line = f.readline().strip()
if first_line.startswith('# '):
return first_line[2:].strip()
return os.path.splitext(os.path.basename(md_file))[0]


Expand Down

0 comments on commit 4ded13f

Please sign in to comment.