Skip to content

Commit

Permalink
test: markdown comment
Browse files Browse the repository at this point in the history
  • Loading branch information
lbrealdev committed Jun 24, 2024
1 parent 7f5e0f9 commit 092fd3b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
21 changes: 20 additions & 1 deletion converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import shutil
from pathlib import Path
import pypandoc
import re


if len(sys.argv) < 2:
Expand Down Expand Up @@ -49,6 +50,21 @@ def convert_pandoc(input, output, auth: bool = False):
pypandoc.convert_file(markdown, "pdf", outputfile=pdf, extra_args=args)


def search_markdown(path):
pattern = r'!\[.*?\]\((.*?)\)'
filter_pattern = r'/asset/'

for file in path.rglob("*.md"):
with file.open("r", encoding="utf-8") as f:
content = f.read()

matches = re.findall(pattern, content)

assest_urls = [match for match in matches if re.search(filter_pattern, match)]

for url in assest_urls:
print(url)

# Set the environment variable GITHUB_TOKEN to github authenticate.
# This variable must be set if the markdown files you want
# convert to PDF contain images with URL image referencing an
Expand Down Expand Up @@ -77,7 +93,10 @@ def convert_pandoc(input, output, auth: bool = False):
if not DESTINATION_PATH_TO_PDF.exists():
DESTINATION_PATH_TO_PDF.mkdir()

install_pandoc()
#install_pandoc()

search_markdown(SOURCE_PATH_TO_MD)
sys.exit(1)

print(f"Markdown input directory: {SOURCE_PATH_TO_MD.absolute()}")
print(f"PDF output directory: {DESTINATION_PATH_TO_PDF.absolute()}")
Expand Down
4 changes: 4 additions & 0 deletions test/second/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@

![linux-png-image](https://raw.githubusercontent.com/lbrealdev/private-images/main/linux-tux-cosmos.jpeg)


### IMAGE FROM PRIVATE REPOSITORY JPEG

[comment]: <> (![linux-png-image](https://github.com/repo/images/main/asset/linux-tux-cosmos.jpeg))

0 comments on commit 092fd3b

Please sign in to comment.